• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

artificial intelligence in a monster?

i dont have minotaurs in game nor spiders nor dragons.
I do have a scripting service and can make it to any server you want.

not underrating, just thinking ideas what should be done.
I myself no clue how to train map maker. I only know how to generate item and tile and environment sprites.

onThink() function on monsters without having a player nearby
can be bypassed with condition. My npc's in game kill monsters even if no players around.
 
I know at least 5 servers which have custom AI made in Lua.
Publicly released ones? Can you give at least one example?
Either way, TFS, OTHive and most modern distros does not appear to have this (I've never seen it anyway, but I haven't kept up the last 5+ years, just taken peaks at 3-4 big distros).

And just to be clear, obviously the point wasn't to say that it's not possible or that it hasn't been done, the point is that imo. this should be a feature by default if we intend not to merely replicate Tibia (which is a very boring and uninteresting project imo; what's the point of making a literal copy of something that already exists? the interesting thing is to replicate old versions and/or change stuff, and the community seem to agree with me considering that the overwhelming majority of OTs are to SOME degree intentionally modified, e.g. higher XP rates or whatever), but to extend it.
And if not in Lua (might be resource-ineffective? I don't know whether Lua scripts are loaded and parsed mainly on boot or if it's continuously executed for e.g. every monster respawn; I'm not an OT developer), at least there should be some config'ish file (e.g. INI or XML file) that the engine parses on boot that configures the AI of various monsters to some degree.

That's my opinion anyway, and this thread is in the Discussion section after all.

And btw this answer of yours to downloadnow made no sense imo
quite easy to implement, just a simple table to increase spell powers.
Most servers on TFS 1.x can make that with like 5 lines of code.
How does "a table to increase spell powers" relate in any way whatsoever to monsters running around killing each other in groups as if they were players ???

There's no challenge in making your sole targeted 5 group of monsters smarter, but try it with 10k creatures on the map?
Hivemind :)
 
How does "a table to increase spell powers" relate in any way whatsoever to monsters running around killing each other in groups as if they were players ???
It doesn't, didn't answer to that.

Publicly released ones? Can you give at least one example?
Idk public codes or released ones. Only read what others have done and what I have done.
I also offer some selected people my engine where they can use such features, but they don't have access to full code, only configurations.

we have enough tools to make all you said in Lua.
 
Last edited:
I was thinking maybe split the map into several servers, each controlling their set of creatures in them.

(The sheer scale of 10k creatures "thinking" all the time would be too much for a single node...)

Then have a centralized server which runs querires between these servers (think exiva, messages, etc, you still want it to be seamless for players in one server to query state on the rest of the servers). Using a boat will require your connection to hop, yes, but you should be willing to accept this (even think of it as "travel" time!)
 
It doesn't, didn't answer to that.

You kind of did quote the whole sentence there including the "monsters organizing into groups to take on bigger monsters" part... but that's ok. I think I get the idea of what you say is trivial to implement, no worries!
 
You kind of did quote the whole sentence there including the "monsters organizing into groups to take on bigger monsters"
Ah yea, my answer was meant only for first part, which was for monsters leveling up and improving their fighting powers as time goes on.

Its not that monster organizing is hard to do, its that it requires more time to create such interactions against something.
And as I see it, nobody cares about such details. Not worth spending ~6 hours to script 1 encounter, where monsters team up to take on bigger monster like professionals.

Its already quite interesting enough to just drop x amount of monsters into 1 zone and give them all 1 enemy.
That random mess already is funny to look at for some time.
(no clue can monsters even attack each other in default TFS, but seen it on several servers so I guess its default)

The sheer scale of 10k creatures "thinking" all the time would be too much for a single node...
Why would you need to activate that many monsters?
If the monster AI is mostly written on C++ (into source) then I don't think that would be problem anyway.
But there are so many ways to reduce the think amount anyway.
If no players around, algorithms can continue which calculate the passed time and what groups of monster could have done and where they are now.
There is no need to access monsters every second and give them commands if there is nobody to see them. If player gets online or gets nearby to their passing zones then the area and monsters will get updated and activated.


If I would have more players in my server, I could put that theory in practice as I already have entire map divided into areas which are also linked to monsters.
All I would need to do is add a algorithm and parameters to monsters what are they capable of doing and which are their goals on the map to go to.
+ A function to trigger update when player walks near or in the area
 
Last edited:
There is no need to access monsters every second and give them commands if there is nobody to see them. If player gets online or gets nearby to their passing zones then the area and monsters will get updated and activated.

Unless there is a special event which takes too long to resolve with just calculation or has random elements to it.

Similar to the 2 warring demon tribes in tibia (forgot their names, red and blue demons), if left alone it will auto-resolve but players can intervene to shift the tides of the war.

whitevo said:
can be bypassed with condition. My npc's in game kill monsters even if no players around.

I can't thank you enough for this tip. You've opened a whole new development path for me.
 
Unless there is a special event which takes too long to resolve with just calculation or has random elements to it.
Well the idea of algorithm is to simplify the outcome.
The encounters wouldn't be that random. We already know how many attackers there are, how many defenders there are. each monster has its own heuristics.
In the end you simply calculate out the simple result which side wins and how many of winner team is left.
If player activates the zone when the outcome is not finished or in middle, then I would simply skip calculating the fighting result and just put the monsters next to eachother and brawl it out "live" from the start.

As soon as players leave the zone, once again we already know when new monsters spawn, where they spawn, how many of each monster is there, when monster reach to next goal, etc. And this is enough information to make next predictions based on how much time is passed. Time is passed* time come from when another player enters area again. If its like 1 minute or something small like that, might aswell not even calculate anything and just continue from where other player left off.
 
Just throwing this out there, but maybe not all monsters need to act like PCs and run around leveling up. I would think that without a whole lot of effort you could create special player accounts that look like monsters and connect those accounts to bots running on another computer. Then as far as your server is concerned, these "monsters" are just players running around doing player things. You wouldn't have to off load sections of the map to a farm of computers that way, but you would still get some semi-intelligent monsters that leveled up.
 
Just throwing this out there, but maybe not all monsters need to act like PCs and run around leveling up. I would think that without a whole lot of effort you could create special player accounts that look like monsters and connect those accounts to bots running on another computer. Then as far as your server is concerned, these "monsters" are just players running around doing player things. You wouldn't have to off load sections of the map to a farm of computers that way, but you would still get some semi-intelligent monsters that leveled up.

It would be better to just have it running on the same computer. You do not want to have extra networking just for monsters.

Once the new AMD Datacenter Chips come out, we will be able to do just about anything we want and it won't slow down the server.
This means, we could literally have hundreds of monsters controlled by advanced AI going at all times, and it shouldn't be a problem.

Well... As long as TFS can utilize all 32 cores/64 threads.
 
Well the idea of algorithm is to simplify the outcome.
The encounters wouldn't be that random. We already know how many attackers there are, how many defenders there are. each monster has its own heuristics.
In the end you simply calculate out the simple result which side wins and how many of winner team is left.
If player activates the zone when the outcome is not finished or in middle, then I would simply skip calculating the fighting result and just put the monsters next to eachother and brawl it out "live" from the start.

As soon as players leave the zone, once again we already know when new monsters spawn, where they spawn, how many of each monster is there, when monster reach to next goal, etc. And this is enough information to make next predictions based on how much time is passed. Time is passed* time come from when another player enters area again. If its like 1 minute or something small like that, might aswell not even calculate anything and just continue from where other player left off.

From an algorithmic perspective, you're right in that constantly thinking is probably unnecessary, but I still think there are some flaws in your approach:
  • Your solution takes a huge dependency on knowing everything beforehand, and therefore it kind of deterministic.
  • It also depends on you having setup "zones" beforehand, and making scripts for each "zone"
  • But most importantly, your solution does not scale. Like you mentioned, you need to put in 6h+ into a script just to program a single encounter, let alone make them travel the map and "attack" a different "zone".
Also, I believe your vision and (at least) my vision are different in the sense that, I'm expecting such group of monsters to leave a trail of bodies (decaying etc) where they pass by and that, as a player, I would feel most immersed if I were to walk in the middle of the actual fight (creatures mid health, running, arrows flying, etc), just like you may sometime walk into a cat gathering in real life by accident. It would feel awfully suspicious that every time, you see either the outcome or the beginning of the brawls.
 
  • Your solution takes a huge dependency on knowing everything beforehand, and therefore it kind of deterministic.
  • It also depends on you having setup "zones" beforehand, and making scripts for each "zone"
  • But most importantly, your solution does not scale. Like you mentioned, you need to put in 6h+ into a script just to program a single encounter, let alone make them travel the map and "attack" a different "zone".
Ehm, well but we already do know everything beforehand and the outcome is determined ofc, thats the whole point of it. We can throw in some RNG too, but heuristics will make more sense.

Well in Whi World, I already have all zones set up and scripts are initialized automatically.

I does scale, like I said I will not use the approach to script every single encounter, but instead just let monsters themselves attack eachother same way they would attack players.

What i meant about 6hours scripting encounters. Is that specific monsters would group up to do a quest or boss fight with a plan of taking the least damage as possible. (in Whi World bosses are a bit different, much harder to fight them when you don't know what to do)

I'm expecting such group of monsters to leave a trail of bodies
yes that is calculated already when you entered zone, the body locations are RNG, but they have some kind of logical area where the fight was encountered.

It would feel awfully suspicious that every time, you see either the outcome or the beginning of the brawls.
just few lines of code to throw in random damages to all monsters.
 
what you're talking about is not artifical intelligence. What you're talking about is programmed behavior. The way I interpreted it, TS is asking about actual AI.
 
Ehm, well but we already do know everything beforehand and the outcome is determined ofc, thats the whole point of it. We can throw in some RNG too, but heuristics will make more sense.

Well in Whi World, I already have all zones set up and scripts are initialized automatically.

I does scale, like I said I will not use the approach to script every single encounter, but instead just let monsters themselves attack eachother same way they would attack players.

What i meant about 6hours scripting encounters. Is that specific monsters would group up to do a quest or boss fight with a plan of taking the least damage as possible. (in Whi World bosses are a bit different, much harder to fight them when you don't know what to do)


yes that is calculated already when you entered zone, the body locations are RNG, but they have some kind of logical area where the fight was encountered.


just few lines of code to throw in random damages to all monsters.

What I mean by scale, is that:

For starters, when you want to 2X the size of your map, you will need to script the zones.

And so given your solution (or the way I understand you built it), say I have 2 zones with scripts, one with group A and B and the other with group C and D. They brawl. The winner of each one goes from their origin zone, to city X and Y respectively.
What does your solution do to handle if they cross paths and kill each other?
What if they cross paths with a player, o 10 other groups?
Would you have to know, before hand, what the state of the other groups is, to calculate the outcome and just present the final winner group at location Z?

That kind of combination problems, imo, would not scale with your solution.

Also how do you handle "activation" of a player walking into the path of the "group in motion", given that your zones are fixed?
How often will you need to check the activation rule?
How is that different from "thinking" the whole time?
 
what you're talking about is not artifical intelligence. What you're talking about is programmed behavior. The way I interpreted it, TS is asking about actual AI.
I know right, but that I'm just going with the flow, but programmed behavior is also AI. It just not self learning AI.

What I mean by scale, is that:

For starters, when you want to 2X the size of your map, you will need to script the zones.

And so given your solution (or the way I understand you built it), say I have 2 zones with scripts, one with group A and B and the other with group C and D. They brawl. The winner of each one goes from their origin zone, to city X and Y respectively.
What does your solution do to handle if they cross paths and kill each other?
What if they cross paths with a player, o 10 other groups?
Would you have to know, before hand, what the state of the other groups is, to calculate the outcome and just present the final winner group at location Z?

That kind of combination problems, imo, would not scale with your solution.

Also how do you handle "activation" of a player walking into the path of the "group in motion", given that your zones are fixed?
How often will you need to check the activation rule?
How is that different from "thinking" the whole time?
Yes you would need to script the zones again, but trust me that's much better approach compared to what we have right now. (setting up monsters on map and whenever we want to do add something unique there, we need to do it manually anyway)

The difference with thinking is, in this solution the thinking if zone should be activated or not happens only on players and on an event schedule.
In your first solution the thinking was done by all monsters.

kill eachother outcome is not possible. There will always be winner, even if its a 1 hp rat. if you thinking about some damage over time spells on close matches. I'd say fuck that, lets not over complicate it, like I said player would never know the difference.
All we care about is where the event happened and what were the mathematical outcomes.

You are right doe, would be kinda hard to make algorithm which on activation calculates like 10 battles of 1 group and then leaves a trail and either puts the group somewhere or realizes they all died at the 10th fight.
Instead, since we already have all the data, would be smart predict next encounter and update the area state when predicted time has passed.
Then predict next conflict on the area and set another event to happen, unless no player interactions happen meanwhile.
Granted this on populated areas can invoke a mathematical prediction like every minute, but hey still better than activate 100+ monsters every second
 
Last edited:
As Yamaken said, it can be done in Lua. It will require monsters to be redesigned and restructured.

I'm actually glad I stumbled upon this thread. We were in the process of developing a system introducing AI in monsters for events and battles between species. The idea was originally designed for events, but I then came to the realization it can easily be applied elsewhere. We were beginning to restructure the source code. Anyway, I realized we could apply this as a method of enticing players to be more involved in team game-play, as that aspect of Tibia and OpenTibia has faltered.
 
Personally, I prefer to let everything actually happen.

If I have orcs that live in one castle, and elves that live in another, and they are constantly fighting each other. Well.. they will be constantly fighting each other.

By this, I simply mean I will have 2 different classes of monster.
  1. Always Active Monsters (Never Idle)
  2. Idle Monsters (Active when a Player, or Always Active Monster is nearby, but otherwise Idle)
So, I will just make normal monsters be Idle Monsters, and then monsters that move around, or complete tasks are Always Active Monsters.

This way, the Orcs could send a small army to attack the Elves, and only the Orcs, and nearby monsters to the orcs will become active.

I also increased the range at which Idle Monsters will become Active. So instead of them having to be on screen, they can be up to 40 sqm away.
This allows monsters like wolves to sniff you out and follow you from off-screen. Then if you get low, or go to sleep, they might attack. (There will be ways to see if someone, or something is following you, using tracking skills. Or you can just set traps as you go, and anyone following you might fall into your trap)

To me, all AI does is make monsters FEEL they are smart. They don't actually have to be smart.

And the reason you wouldn't just "Simulate" the wolves following you, is because it is more interesting to be actually able to counter them BEFORE they attack.
 
actual AI

What exactly is that?

I mean there is no true AI yet. No where. Every implementation of "AI" is exactly what is being discussed here, the appearance of intelligence, not actual intelligence. No one has made Artificial Intelligence with lines of code. Something like that would require biochemistry.
 
Back
Top