jackadamson / onitama

Play Onitama in your browser, compete with friends or lose to a bot
MIT License
79 stars 14 forks source link

AIs #5

Closed truchi closed 2 years ago

truchi commented 2 years ago

Hey bro,

Can I ask what were the technical resources you used to implement the AI algos? Also I'm very interested to know how did you rank your AIs? Did they battle against each other? What are your findings?

I want to make AIs fight to death on this game (in Rust), started reading your code! Playing with friend on your website gave us the idea :)

Thanks

PS: Do you plan to implement the extensions?

jackadamson commented 2 years ago

I wrote some code to benchmark the AIs against each other, which you can find in benchmarkagents.rs You can tweak the numbers and run it to play a number of matches between all pairs of AIs.

eg. with the settings as is, and running it with the command

RUST_LOG=error cargo run --release --bin benchmarkagents --features="agent benchmark"

Which runs 200 matches, with a maximum game length of 250 turns, 100ms per turn and running 14 matches at once. The results are:

Alphabeta win 57
Minimax win 36
Greedy win 29
HybridMonteCarlo win 70
PureMonteCarlo win 2

You can check the mapping from easy/medium/hard in onitamalib/src/gamemodes/singleplayer.rs

But it's:

jackadamson commented 2 years ago

For resources, I spent a fair amount of time reading the Chess Programming Wiki (https://www.chessprogramming.org/Alpha-Beta) as well as the Wikipedia page for AlphaBeta pruning.

Though I had come across some of these when I was at University for a first year assignment, so it involved a lot of just remembering what I'd learnt then from discussions.

jackadamson commented 2 years ago

I started on a project to make the board game engine generic enough to easily use with more games, but then became to busy, so don't think I'm likely to spend too much time in the next while on this.

jackadamson commented 2 years ago

I've kicked off the benchmark with much longer turns and will comment with the results when it finishes, but would encourage you to have a crack at tinkering with implementing an agent of your own and comparing it!

jackadamson commented 2 years ago

Interestingly, allowing 5 seconds per turn, narrowed the gap between Alphabeta and Alphabeta+MonteCarlo

PureMonteCarlo win 4
HybridMonteCarlo win 67
Greedy win 23
Minimax win 36
Alphabeta win 63
truchi commented 2 years ago

Wow great!

Did some agent on my own. Minimax with simple metrics, plus genetic algorithm to find the weights :) Was fun but I need to improve the code a lot. Will share when I'll have time to get back to it.

Thanks!

jackadamson commented 2 years ago

Closing this for now, but if you do end up implementing Genetic Algorithms or similar I'd love to hear your results!