Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

The find_best_move test sometimes fails. #5

Closed
kennytm opened this issue Aug 29, 2017 · 1 comment
Closed

The find_best_move test sometimes fails. #5

kennytm opened this issue Aug 29, 2017 · 1 comment

Comments

@kennytm
Copy link

kennytm commented Aug 29, 2017

Repro steps:

  1. cargo test find_best_move
  2. Repeat 10 times
  3. 30% of the time it will fail at src/minimax_test.rs:26:2 (depth = 7), usually finding Some(37) (6, 2) or Some(26) (5, 1) instead of the expected Some(36) (5, 2).
Logs for a failing case.
Starting minimax with depth 7 and player Red.
Calculating of our estimation. Player is Red
Starting parellel alpha beta with depth 7, player Red and beta 2147483647.
Moves in consideration: [(5, 3), (3, 5), (3, 1), (4, 1), (4, 6), (5, 1), (6, 2), (6, 4), (5, 2), (1, 3), (2, 2), (5, 5), (2, 4), (4, 2), (6, 3)].
Estimation for move (3, 5) is -2147483647, alpha is -2147483647, beta is 2147483647.
Estimation for move (5, 3) is 0, alpha is -2147483647, beta is 2147483647.
Estimation for move (3, 1) is 0, alpha is -2147483647, beta is 2147483647.
Estimation for move (4, 6) is 0, alpha is -2147483647, beta is 2147483647.
Estimation for move (6, 4) is 0, alpha is 0, beta is 2147483647.
Estimation for move (4, 1) is 0, alpha is -2147483647, beta is 2147483647.
Estimation for move (1, 3) is 0, alpha is 0, beta is 2147483647.
Estimation for move (5, 1) is 1, alpha is 0, beta is 2147483647.
Estimation for move (2, 2) is 0, alpha is 0, beta is 2147483647.
Estimation for move (2, 4) is -2147483647, alpha is 1, beta is 2147483647.
Estimation for move (5, 5) is 1, alpha is 1, beta is 2147483647.
Estimation for move (4, 2) is 1, alpha is 1, beta is 2147483647.
Estimation for move (6, 3) is 1, alpha is 1, beta is 2147483647.
Estimation for move (6, 2) is 1, alpha is 0, beta is 2147483647.
Estimation for move (5, 2) is 1, alpha is 0, beta is 2147483647.
Best move is (5, 1).
Estimation is 1.
Calculating of enemy estimation with upper bound 0. Player is Black
Starting parellel alpha beta with depth 6, player Black and beta 0.
Moves in consideration: [(2, 4), (5, 2), (6, 3), (5, 3), (3, 1), (5, 5), (6, 4), (4, 2), (1, 3), (4, 6), (4, 1), (2, 2), (3, 5)].
Estimation for move (6, 3) is 0, alpha is -1, beta is 0.
Estimation for move (2, 4) is -1, alpha is -1, beta is 0.
Best move is (6, 3).
Estimation is 0.
Estimation is greater than enemy estimation. So the best move is Some((5, 1)), estimation is 1.

thread 'minimax_test::find_best_move' panicked at 'assertion failed: `(left == right)`
  left: `Some(26)`,
 right: `Some(36)`', src/minimax_test.rs:29:2
note: Run with `RUST_BACKTRACE=1` for a backtrace.
test minimax_test::find_best_move ... FAILED

Tested on master.

$ rustc -vV
rustc 1.21.0-nightly (e26688824 2017-08-27)
binary: rustc
commit-hash: e2668882406b68739c6ed33d420358d5d710e67b
commit-date: 2017-08-27
host: x86_64-apple-darwin
release: 1.21.0-nightly
LLVM version: 4.0
@kurnevsky
Copy link
Member

Thanks, the test shouldn't fail now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants