• 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!

PyOTC - a CLI only (bot-like) OTClient written in Python for use with Neural Networks (AI/ML)

Source

Veteran OT User
Joined
May 31, 2020
Messages
237
Reaction score
340
Location
OpenTibia .dev
GitHub
source61
So I watched this video and was lightly inspired again to create an AI/ML Open Tibia Python client:


So about 4 weeks ago I started rewriting my 3+ years old client.py code in Cython to use my newest libraries written in C++ and fixed a serious bug with large packets not being buffered within the first 3 days.

Here's what I did the first 3 days:
  • RSA encryption/decryption done in mixed C++
  • XTEA encryption/decryption done in mixed C++
  • Using my networkhandle written in C++
  • Buffering large packets exceeding MSS
  • Basics: connect N clients setting, ip setting, ports settings, RSA settings (p,q), account, password, send LS login packet -> store character data -> send GS login packet

Todo:
  • Protocol codes
  • Keeping track of items, map, creatures, containers and optionally chat windows/others in memory
  • AI implementation that plays the game
  • AI hivemind

Since then I've added the following over the last 3 weeks:
  • Added all protocolSend functions
  • Added all protocolParse functions
  • Store, map, and clear tiles incl. rewriting a lot of world (tile) code
  • Keep track of creatures and move and delete creatures and items on and around map
  • Recursively loop through all packet data (rewrote packet header parsing system) and multiple packet fragments when combined
  • Many minor changes and improvements
  • Added !dance, walk and !rainbow commands + onReady message

The idea of the project is to create a CLI based multi-account multi-player (simultaneous, like a magebot) AI/ML/NN agent that plays Open Tibia using reinforcement learning (RL).
Only protocol version currently supported: v7.70.

Timeline: I should be at least halfway now, so got about <4 weeks left hopefully until the CLI client itself is more or less finished, at which point it's time to try to work on adding the AI agent.

No source, no github link, just a discussion thread :-)

I will likely be livestreaming maybe the development of this client, but more importantly the implementation of the AI/ML/NN on Twitch/Youtube at
pretty soon, so stay tuned if you're interested.

Here's the latest video that demonstrates the progress with the client so far:

Cheers, Source.
 
Update: I've now implemented the AI network!

Here's a livestream of the first day of the network being implemented including me coding it (spoiler: this whole stream I hadn't added training yet! Hahaha, so it didn't learn anything, it just did random actions!):

Then after the stream I realized it wasn't training! So the next day I made a recording of the progress of the network after some hours of working with it:

It kind of started to learn to walk!

That's all I have to show for now, I managed after a few days to get it to explore a lot, it walked quickly, within seconds, from one area to another, but I didn't record it as I was too busy/excited getting the network to do even better/add more features/fix more bugs, etc.

Now I'm at a different stage, trying to get the network to work at all, after I added full map parsing (opcode 0x64) to the network!
The issue seem to be that at the beginning of the training the network basically short-circuits from too much information (map data) it doesn't understand yet, and so it refuses to respond to any rewards etc, GPT suggests more technically it might be because the gradients are vanishing, but that means very little to me, so I prefer the explanation that it's short-circuiting :D

That's basically all for now. Lots of technical updates, but it's not that interesting, mostly bug fixes and features to get it to explore more of the map etc by keep track of what tiles it steps on and give it negative rewards for tiles it's already stepped on.

Cheers!
 
Update: I've now implemented the AI network!

Here's a livestream of the first day of the network being implemented including me coding it (spoiler: this whole stream I hadn't added training yet! Hahaha, so it didn't learn anything, it just did random actions!):

Then after the stream I realized it wasn't training! So the next day I made a recording of the progress of the network after some hours of working with it:

It kind of started to learn to walk!

That's all I have to show for now, I managed after a few days to get it to explore a lot, it walked quickly, within seconds, from one area to another, but I didn't record it as I was too busy/excited getting the network to do even better/add more features/fix more bugs, etc.

Now I'm at a different stage, trying to get the network to work at all, after I added full map parsing (opcode 0x64) to the network!
The issue seem to be that at the beginning of the training the network basically short-circuits from too much information (map data) it doesn't understand yet, and so it refuses to respond to any rewards etc, GPT suggests more technically it might be because the gradients are vanishing, but that means very little to me, so I prefer the explanation that it's short-circuiting :D

That's basically all for now. Lots of technical updates, but it's not that interesting, mostly bug fixes and features to get it to explore more of the map etc by keep track of what tiles it steps on and give it negative rewards for tiles it's already stepped on.

Cheers!

Maybe im confused but for what do we need it ?
 
Next to happen; cmd based bots that spawn over 100 players and they play in your game server, and also CHAT with themselves thanks to A.I, also trade stuff up, and walk around...
 
I have a theory. This guy already sold this product to several ots and is now pretending he is "building" it.

To be honest this is pretty cool, however the greatest thing would be if you never ever ever ever fucking E V E R released this or gave it to anyone as it would pretty much kill open tibia in my opinion. Keep working on it and updating us as long as its interesting for you though.

Imagine realesta or kasteria or brazoly ots with this shit, new record of players online every 3 minutes and they fighting for whoevers engine can handle the most players online.
New record: 18095 players are online!

Scary shit man.
 
I have a theory. This guy already sold this product to several ots and is now pretending he is "building" it.

To be honest this is pretty cool, however the greatest thing would be if you never ever ever ever fucking E V E R released this or gave it to anyone as it would pretty much kill open tibia in my opinion. Keep working on it and updating us as long as its interesting for you though.

Imagine realesta or kasteria or brazoly ots with this shit, new record of players online every 3 minutes and they fighting for whoevers engine can handle the most players online.
New record: 18095 players are online!

Scary shit man.
😂

Reinforced learning can be used for waaaaaay more advanced things than spoofing. Imagine having actual challenging enemies for a quest/event.
Imagine having true intelligent monsters that learns your patterns and start avoiding spells...
Imagine having NPCs with true stories and depth, that could walk the map and take decisions based on their lore...

To spoof you literally can do so with way less computer resources, in way less expensive manners. I have shared already 2 ways to spoof and explained in details how you could improve it further a few years ago. Some members contacted me showing they did what I said and using it to bypass otservlist for months before getting caught by manual report, nothing will change for those big servers;
 
Reinforced learning can be used for waaaaaay more advanced things than spoofing. Imagine having actual challenging enemies for a quest/event.
Imagine having true intelligent monsters that learns your patterns and start avoiding spells...
Imagine having NPCs with true stories and depth, that could walk the map and take decisions based on their lore...

Nothing we will ever need in tibia if you ask me
 
Nothing we will ever need in tibia to be honest
Well, if you're doing a 1:1 cheap copy of Global then you're probably right, in my custom server I was already applying IA daily to spot botters.
I had a quest in mind where you'd have a tower to climb against several enemies (similar to arena) and the boss could be yourself (a RL model of yourself, playing exactly like you)

You'd have to literally become better in attempt to fight it, surpassing your own skills to beat it. Amazing concept, no?
 
Well, if you're doing a 1:1 cheap copy of Global then you're probably right, in my custom server I was already applying IA daily to spot botters.
I had a quest in mind where you'd have a tower to climb against several enemies (similar to arena) and the boss could be yourself (a RL model of yourself, playing exactly like you)

You'd have to literally become better in attempt to fight it, surpassing your own skills to beat it. Amazing concept, no?

Sounds pretty cool
 
Maybe im confused but for what do we need it ?
Kind of like asking what do you need a mobile phone for. Before they existed almost no one thought it would be of any use, and right as they started being produced and launched, everyone was like "huh? mobile phones? how silly, I have a phone right at home, who needs a phone OUTSIDE the home? LOL".
I don't mind the question for the record, and it's a good question, but I'd rather answering with this analogy than give a concrete list of ideas.
@nightwolf shared some ideas, but some of that I won't be working on (such as making the character play exactly like you because I'm not using computer vision, etc, because I don't want the bot to have control of my cursor and accidentally leave the game and start messing with my drive or something).

So personally the main usages I have in mind for it is:
1. It's mainly for fun, it's the first time this has ever been done for Tibia, I like exploring new territory (this is what got me into Tibia in the first place as a kid!), challenges and learning new skills; this will teach me how to do RL, which is something I've never done before.
2. As others have mentioned it can be used for spoofing, but that's not the intended usage, in fact you'd need a GPU-farm probably to make the poor network be able to handle that many clients if it's going to do anything interesting! (In other words: it's (fortunately) not very good for spoofing). What I've personally used it for instead is load testing for my server, where I was able to log in 3000 players on my server, which was fun, and it showed me some new bugs on my server by logging into that many different accounts.
3. I want to stream/upload videos about the network playing Tibia, similar to the first video I shared in my main post by a guy that revolutionized TrackMania, a driving game, using RL, which I said I was inspired by, I want to make a similar (but shoddier/simpler) video if I'm able to get the network to play Tibia well.
4. If, or once, the network is good enough at playing Tibia, you can have players compete with the AI(s).
5. AI Hivemind (this is probably one of the least features I will implement, IF and only IF step 4 is already completed): Multiple AI clients collaborate with each other and compete against players ;)

In other words, AI networks can complement both other players and monsters.
They can be a boss fight, they can be a companion or friend, or they can be a competitive player, enemy, or someone to wage war against in PvP/guild wars.
Unlike your enemies on current servers, AIs will never leave the server or sit in depot all day (unless you train it to) if they lose a war or are scared of their enemies.
They will, unless trained otherwise, fight until the end, even if they are rooked they will continue playing, which means endless entertainment for you.

Will you be their enemy or an ally?

PS: I don't promise this project will turn out successful, I will reiterate DeepMind has defeated Dota 2 and SC2, but Open Tibia is more complicated and complex than any of those games. I'm just doing this for fun. But if it turns out successful, yes it might change Tibia forever, and will give you a choice that the IRL robots will never forget: whether you were an ally or a foe in Tibia in the year 2024/2025 ;)

Edit: Actually in theory training the network to play like you or like other players might still be possible without computer vision using cam replaying directly!
So thanks to @nightwolf for the idea!
 
Last edited:
Next to happen; cmd based bots that spawn over 100 players and they play in your game server, and also CHAT with themselves thanks to A.I, also trade stuff up, and walk around...
Funny enough, this is so outrageous here, while this is nothing new in other games.
 
Kind of like asking what do you need a mobile phone for. Before they existed almost no one thought it would be of any use, and right as they started being produced and launched, everyone was like "huh? mobile phones? how silly, I have a phone right at home, who needs a phone OUTSIDE the home? LOL".
I don't mind the question for the record, and it's a good question, but I'd rather answering with this analogy than give a concrete list of ideas.
@nightwolf shared some ideas, but some of that I won't be working on (such as making the character play exactly like you because I'm not using computer vision, etc, because I don't want the bot to have control of my cursor and accidentally leave the game and start messing with my drive or something).

So personally the main usages I have in mind for it is:
1. It's mainly for fun, it's the first time this has ever been done for Tibia, I like exploring new territory (this is what got me into Tibia in the first place as a kid!), challenges and learning new skills; this will teach me how to do RL, which is something I've never done before.
2. As others have mentioned it can be used for spoofing, but that's not the intended usage, in fact you'd need a GPU-farm probably to make the poor network be able to handle that many clients if it's going to do anything interesting! (In other words: it's (fortunately) not very good for spoofing). What I've personally used it for instead is load testing for my server, where I was able to log in 3000 players on my server, which was fun, and it showed me some new bugs on my server by logging into that many different accounts.
3. I want to stream/upload videos about the network playing Tibia, similar to the first video I shared in my main post by a guy that revolutionized TrackMania, a driving game, using RL, which I said I was inspired by, I want to make a similar (but shoddier/simpler) video if I'm able to get the network to play Tibia well.
4. If, or once, the network is good enough at playing Tibia, you can have players compete with the AI(s).
5. AI Hivemind (this is probably one of the least features I will implement, IF and only IF step 4 is already completed): Multiple AI clients collaborate with each other and compete against players ;)

In other words, AI networks can complement both other players and monsters.
They can be a boss fight, they can be a companion or friend, or they can be a competitive player, enemy, or someone to wage war against in PvP/guild wars.
Unlike your enemies on current servers, AIs will never leave the server or sit in depot all day (unless you train it to) if they lose a war or are scared of their enemies.
They will, unless trained otherwise, fight until the end, even if they are rooked they will continue playing, which means endless entertainment for you.

Will you be their enemy or an ally?

PS: I don't promise this project will turn out successful, I will reiterate DeepMind has defeated Dota 2 and SC2, but Open Tibia is more complicated and complex than any of those games. I'm just doing this for fun. But if it turns out successful, yes it might change Tibia forever, and will give you a choice that the IRL robots will never forget: whether you were an ally or a foe in Tibia in the year 2024/2025 ;)

Edit: Actually in theory training the network to play like you or like other players might still be possible without computer vision using cam replaying directly!
So thanks to @nightwolf for the idea!
If you need someone who can run training 24/7, let me know. I'll be happy to help, with a nice PC :)
 
This is so cool! Keep us posted, I'm very curious how far reinforcement learning can go in Tibia.

I have a theory. This guy already sold this product to several ots and is now pretending he is "building" it.

To be honest this is pretty cool, however the greatest thing would be if you never ever ever ever fucking E V E R released this or gave it to anyone as it would pretty much kill open tibia in my opinion. Keep working on it and updating us as long as its interesting for you though.

Imagine realesta or kasteria or brazoly ots with this shit, new record of players online every 3 minutes and they fighting for whoevers engine can handle the most players online.
New record: 18095 players are online!

Scary shit man.

I think the effect of spoofing in Open Tibia has always been exagerated. Sure, you'll appear first in otservlist and whatnot, but human players (you know, the ones servers actually cater to) won't stay for and mostly won't care about online player counts. Retention is mainly tied to that player's individual experiences while playing.

Spinning up a server with 18k bots will achieve exactly one thing, which is to get you a huge AWS bill while not affecting retention at all (or probably hurting it)
 
@everyone talking about spoofing
I get the point you are trying to make but even spoofed servers today dont achieve much since once you log in you realize that the server is dead.
If you however saw players walking around and performing actions it would be really hard to distinguish who is real and not and therefore make this game into a psychoanalytical experience where you have to analyze the behaviour of every single character to assess if they are real or not.
Pretty challenging when you just want to log on and kill some mobs/players.

Actually when I think about it this could be the most revolutionizing thing that has happened in open tibia or tibia ever.
If you could somehow change this into working for creatures instead of players and figure out a way to optimize it enough where it would be feasible to work on all creatures the possibilities are endless.
We could even start advancing tibia into something like warcraft3 and create different maps/types like zombie survival, ctf etc.
I know these things exist already but its not even nearly the same thing. Imagine if you could play tibia solo and have a challenging game that you havent experienced before.

Just a thought, no idea how hard it would be to make but considering that Source seems to be really fucking good at what he does, I wouldnt be surprised if he could make even that work.
 
😂

Reinforced learning can be used for waaaaaay more advanced things than spoofing. Imagine having actual challenging enemies for a quest/event.
Imagine having true intelligent monsters that learns your patterns and start avoiding spells...
Imagine having NPCs with true stories and depth, that could walk the map and take decisions based on their lore...

To spoof you literally can do so with way less computer resources, in way less expensive manners. I have shared already 2 ways to spoof and explained in details how you could improve it further a few years ago. Some members contacted me showing they did what I said and using it to bypass otservlist for months before getting caught by manual report, nothing will change for those big servers;
I'd like a mirrored sparring partner please.
Just don't make me look too bad.
 
Last edited:
iv been waiting for this to see , it has unlimited vast potential in many ways to be used . huge respect
 
Back
Top