ElTh0r0 / stackandconquer

A challenging tower conquest board game inspired by "Mixtour".
GNU General Public License v3.0
3 stars 3 forks source link

Add two new CPU players: MinimaxCPU.js and MonteCarloCPU.js. #16

Closed maksverver closed 1 month ago

maksverver commented 1 month ago

Another attempt to add new CPU players. This includes two players which share some code:

Both players work on arbitrary boards. MinimaxCPU only works for two-player games (since minimax is designed for zero-sum games), while MonteCarloCPU works for any number of players.

MinimaxCPU is the stronger player. MonteCarloCPU inherently uses more randomness, so its play style might be more fun to play against. (Also, having a player that is harder to beat than AdvancedCPU but not as tough as MinimaxCPU might be fun for human players whose skill level falls somewhere in the middle.)

Since the players share some code, and I wanted to be able to add unit tests, I created a separate repository for my code. The Javascript files in this pull request contain just the player code, and are compiled automatically by Rollup, but without minification, so the source code is still human-readable.

The source code is generated from commit 11bf5c8 in the original repository: https://github.com/maksverver/stackandconquer-ai

ElTh0r0 commented 1 month ago

Wow, many thanks! I would never had been able to implement such a CPU player!

I'm just thinking about adding a hint about the players strength into the CPU player selection dropdown box, but that is no blocker for the merge. I need to think about simple solution. I am targeting to publish new release including your CPU players most likely week after next.

(Side note/reminder for me: Number of supported players should be caught/visible when trying to create a new game instead of running into an exception at game start - once more than 2 players are officially enabled; referencing #14)

maksverver commented 1 month ago

Another limitation of the new CPU players is that they currently don't support custom boards with more than 30 accessible fields.

I might be able to lift that specific limitation, though I think unusually large boards will stretch the AI past its limits anyway. For example, the Minimax player currently uses a fixed search depth of 4 plies. On an open 100x100 board the performance would be so bad to be unusable. That could perhaps be fixed by limiting the search depth dynamically, but before diving into that rabbit hole, I would like to know that people are actually interested in playing those type of boards, otherwise it seems like a lot of effort for nothing.

ElTh0r0 commented 1 month ago

Another limitation of the new CPU players is that they currently don't support custom boards with more than 30 accessible fields.

No worries! At the moment I have no intention of making larger boards, but just experimenting with different board shapes (like the shared triangle; not sure yet if this board will be included in the next release).