Open Tibia Python client (CLI | AI/ML inspired)

Source

Administrator
Staff member
I watched this video and was lightly inspired again to create an AI/ML Open Tibia Python client:

So yesterday night 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 today.

Done so far:
* 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 😈

Demo of my client.pyx attached.
View attachment 2024-07-27 05-27-30.mp4
 
Last edited:
Tons of improvements to PyOTC has been done since the initial post approximately 3 weeks ago. Here's a few to mention:
* 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

:D

 

Attachments

Last edited:
Wednesday 4th of September 2024:

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!

Edit: At this point (ca. Thursday/Friday) I have fixed the network and it's working again walking around. Saturday: I also fixed parseFloorUp and parseFloorDown, so the agent can walk up/downstairs without exiting! :)
 
Back
Top