jonthysell / Mzinga

Open-source software to play the board game Hive.
MIT License
82 stars 9 forks source link

Creating custom game AI #104

Closed ForkMeSpoon closed 3 years ago

ForkMeSpoon commented 3 years ago

Hello, I have been looking into using the Mzinga engine to test different game AI algorithms, but I cant seem to understand the program structure and how the game AI is integrated.

Is it possible to write my own custom AI and import it into this project?

Thanks in advance. 😄

ForkMeSpoon commented 3 years ago

Sorry, i forgot to state that I would like to use Mzinga's built in functions to do tasks such as generate moves for the AI and check whether a board position is won/lost.

jonthysell commented 3 years ago

Mzinga's board evaluation function is parameterized - so you can change the relative weights of say, a certain piece having moves is more or less valuable than another, or more or less valuable than another piece being surrounded. However the overall algorithm of Mzinga's AI is pretty set.

If you want to build your own AI with a simpler staring point, check out https://github.com/jonthysell/UHPSampleCode

There are "starter" engines which only implement the base game logic - and the "AI" just randomly picks from the set of valid moves. It's up to you to make that AI better, however you see fit.

jonthysell commented 3 years ago

Sorry, i forgot to state that I would like to use Mzinga's built in functions to do tasks such as generate moves for the AI and check whether a board position is won/lost.

Yes, you could use MzingaEngine for that, by sending the right commands and parsing the output.

However, by default MzingaEngine will try to run its AI in the background, which may sap CPU cycles from whatever you're trying to run. So you'll want to use options set PonderDuringIdle Disabled before you start a new game.