Machine Learning AI [ Help with current VCMI code needed ]

me and my friend would like to create ML AI for vcmi.
Obviously our language of choice is python :grinning: (At least for now, for teaching ai and experimenting, later we would port taught agent to c). Using C++ (on scale of whole project, for parts we could use it) is not an option for us. However that creates problems with interaction with game. In this post we would like to consult with you ways of making this interaction possible.

We’ve thought about few ways of connecting game with out python ai:

  • Option one - own client. As we’ve studied codebase of project we’ve found that it would be possible to just start server and then interact with it as vcmi client would. However our attempt in deserialising data in python failed miserably.
    Here’s what we’ve tried and questions we have:
    • We’ve tried to deserialise binary data in packets - it failed because we would need to map them on c++ specific data structures, is that right?
    • Then we’ve tried to rewrite server and client to use JsonSerializers. We failed because we are really bad at c++
  • Option two - write simple ai the same way as current ais are written - but instead of implementing functions in c++ we would connect to our agent by socket and transfer to it current state of the game and receive instructions from it.
    Problems and questions:
    • Is it possible to automate starting game and run it without gui at high speeds?

We have some background in ML which could make it possible for such AI to exist but we need directions and/or help to connect it to game. Please, if you could guide us or help implementing (or show us ready implementation) such connector, your help would be indispensable.

1 Like

Yes it is. It`s almost impossible to write vcmi protocol handler from scratch.

This should be done at some point, but it is not a simple task.

No idea what speed is high for you but you should try vcmiclient --enable-shm-uuid --headless --testmap Maps/mapname.h3m

Instead of connecting to your agent via socket, you could embed calls to python into the C++ AI code. See

I am also having the same issue Regarding Machine learning codes, thanks for the solution.

Hosting provided by DigitalOcean