Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Self play? #2

Closed
pcholt opened this issue Jul 26, 2022 · 2 comments · Fixed by #3
Closed

Self play? #2

pcholt opened this issue Jul 26, 2022 · 2 comments · Fixed by #3
Assignees
Labels
bug Something isn't working

Comments

@pcholt
Copy link

pcholt commented Jul 26, 2022

I'm a little surprised that this self-play test doesn't work?

    #[test]
    fn test_should_always_tie_a_3_by_3_after_9_moves_at_depth_9() {
        let mut ttt = TicTacToe::create_game(3, None, None, None);
        for move_number in 0..=8 {
            let is_maximising = move_number%2 == 0;
            let i = ttt.get_best_move(9, is_maximising);
            ttt.play(&i, is_maximising);
            ttt.print_board();
        }
        assert!(ttt.is_game_complete());
        assert!(ttt.is_game_tied());
    }
@aalekhpatel07 aalekhpatel07 added the bug Something isn't working label Jul 26, 2022
@aalekhpatel07 aalekhpatel07 self-assigned this Jul 26, 2022
@aalekhpatel07
Copy link
Owner

That looks like an interesting test case. My initial guess is get_best_move spits out an invalid move but I'm not too sure.
I'll investigate it further soon.

Thanks for creating the issue!

@aalekhpatel07
Copy link
Owner

aalekhpatel07 commented Aug 2, 2022

Yep that was indeed an error in the implementation of Alpha-Beta pruning. Thank you for bringing it to light. #3 fixes it.
You may use the version 0.2.0 by installing with cargo install minimax-alpha-beta --version 0.2.0

@aalekhpatel07 aalekhpatel07 linked a pull request Aug 2, 2022 that will close this issue
aalekhpatel07 added a commit that referenced this issue Aug 2, 2022
* Refactor into modules.

Signed-off-by: Aalekh Patel <aalekh.gwpeck.7998@icloud.com>

* Bug fix: wrong maximizer flag in alpha-beta minimax algorithm.

Signed-off-by: Aalekh Patel <aalekh.gwpeck.7998@icloud.com>

* Add some setup for Chess using Shakmaty.

Signed-off-by: Aalekh Patel <aalekh.gwpeck.7998@icloud.com>

* Add Clap cli. Make chess non-default.

Signed-off-by: Aalekh Patel <aalekh.gwpeck.7998@icloud.com>

* Add a proper testing workflow.

Signed-off-by: Aalekh Patel <aalekh.gwpeck.7998@icloud.com>

* Bump to v0.2.0 and remove tests.rs empty file.

Signed-off-by: Aalekh Patel <aalekh.gwpeck.7998@icloud.com>

* Rustfmt.

Signed-off-by: Aalekh Patel <aalekh.gwpeck.7998@icloud.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants