Code Monkey home page Code Monkey logo

Comments (6)

MarkZH avatar MarkZH commented on July 28, 2024

Specifically, what is up with this game?

[White "Genetic AI 10"]
[Black "Genetic AI 51"]
[Round "30"]
[Result "0-1"]

1. e3 d5 { d5 d4 }
2. Bb5+ Qd7 { Qd7 a4 }
3. g4 e5 { e5 d4 }
4. Bxd7+ Kxd7 { Kxd7 d4 }
5. b4 Bxb4 { Bxb4 f4 }
6. c4 dxc4 { dxc4 f4 }
7. Qa4+ Kd6 { Kd6 Qxa7 }
8. Qxb4+ c5 { c5 Qxc4 }
9. Qxb7 Bxg4 { Bxg4 Qxa7 }
10. d3 cxd3 { cxd3 Qxa7 }
11. Nc3 a5 { a5 Qxf7 }
12. Qd7+ Bxd7 { Bxd7 a3 }
13. e4 h5 { h5 a4 }
14. Bg5 c4 { c4 f4 }
15. Nb5+ Kc5 { Kc5 f4 }
16. Rd1 f5 { f5 Rxd3 }
17. Bf6 fxe4 { fxe4 Rxd3 }
18. h3 Bxh3 { Bxh3 Rxd3 }
19. f3 exf3 { exf3 Rxd3 }
20. Rxd3 cxd3 { cxd3 Nxf3 }
21. Kf2 g5 { g5 Kxf3 }
22. Nxf3 e4 { e4 Nxg5 }
23. Bd4+ Kc6 { Kc6 Nxg5 e3+ }
24. Nc7 g4 { g4 a4 }
25. Rf1 a4 { a4 Bxh8 }
26. Rc1+ Kd6 { Kd6 a3 }
27. Ne8+ Ke7 { Ke7 a3 }
28. Rc2 dxc2 { dxc2 Bxh8 }
29. Nd6 exf3 { exf3 Bxh8 }
30. a3 Rh6 { Rh6 Bc3 }
31. Kg3 h4+ { h4+ Kf4 g3 }
32. Kh2 g3+ { g3+ Kg1 }
33. Kxh3 { Kxh3 c1=Q } g2 { g2 Be5 }
34. Bg7 Rh8 { Rh8 Bxh8 Ke6 }
35. Bc3 Rh6 { Rh6 Bb2 }
36. Bg7 Rh8 { Rh8 Bxh8 Ke6 }
37. Bc3 Rh5 { Rh5 Be5 Rxe5 }
38. Bf6+ Nxf6 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4 Kh3 Rh1#	0-1 }
128. Kh3 Rb5 { Rb5 Kh2 Rh1#	0-1 }
129. Kh2 Rh1#	0-1
{ Initial time: 30 }
{ Moves to reset clocks: 0 }
{ Time left: White: 16.3977 }
{            Black: 16.4917 }
ID: 10

Name: Piece Strength Gene
B: -4.28278
N: 4.20362
P: 4.31581
Q: -0.467074
R: 1.97916
INACTIVE

Name: Look Ahead Gene
Mean Game Length: 49.0315
Positions Per Second: 13.9335
INACTIVE

Name: Branch Pruning Gene
Minimum Score Change: 3.91
ACTIVE

Name: Total Force Gene
Scalar: 25.0486
ACTIVE

Name: Freedom to Move Gene
Scalar: 54.1913
INACTIVE

Name: Pawn Advancement Gene
Scalar: -21.6998
INACTIVE

Name: Opponent Pieces Targeted Gene
Scalar: -75.9957
ACTIVE

Name: Sphere of Influence Gene
Legal Bonus: 1.55887
Scalar: 8.41038
ACTIVE

Name: King Confinement Gene
Scalar: 114.206
ACTIVE

Name: King Protection Gene
Scalar: 40.655
ACTIVE

Name: Castling Possible Gene
Scalar: 37.7902
INACTIVE

END
ID: 51

Name: Piece Strength Gene
B: 1.11332
N: -4.43488
P: 5.73435
Q: -3.43708
R: 1.53077
ACTIVE

Name: Look Ahead Gene
Mean Game Length: 51.7647
Positions Per Second: 52.405
ACTIVE

Name: Branch Pruning Gene
Minimum Score Change: -8.23496
ACTIVE

Name: Total Force Gene
Scalar: 26.6085
ACTIVE

Name: Freedom to Move Gene
Scalar: 2.21285
INACTIVE

Name: Pawn Advancement Gene
Scalar: 39.7031
ACTIVE

Name: Opponent Pieces Targeted Gene
Scalar: -21.1828
INACTIVE

Name: Sphere of Influence Gene
Legal Bonus: 3.73808
Scalar: -35.3508
INACTIVE

Name: King Confinement Gene
Scalar: -60.9795
INACTIVE

Name: King Protection Gene
Scalar: -3.68461
ACTIVE

Name: Castling Possible Gene
Scalar: 38.0428
INACTIVE

END

from genetic_chess.

MarkZH avatar MarkZH commented on July 28, 2024

First hypothesis:

The problem occurs when there is more than one path to checkmate. If the longer path is found first, the search cuts off due to alpha-beta pruning since wins are given a score of +infinity. First change is to make wins worth std::numeric_limits<double>::max() to keep the score finite and within the initial alpha and beta limits to allow for shorter paths to checkmate to be found.

from genetic_chess.

MarkZH avatar MarkZH commented on July 28, 2024

Above fix seems to have fixed the major problem.

Now, when a Genetic_AI tries to distance itself from losing, it seems to return a line that misses the vulnerability to a nearer checkmate. See below for an example:

[White "Genetic AI 668"]
[Black "Genetic AI 576"]
[Round "811"]
[Result "1-0"]

1. d4 { d4 d5 } d5 { d5 e4 }
2. a4 a5
3. g4 { g4 Bxg4 } Bxg4 { Bxg4 e4 }
4. Na3 b5
5. Nxb5 f5 { f5 e4 }
6. b4 axb4
7. a5 g5 { g5 e4 }
8. a6 Nxa6 { Nxa6 e4 }
9. Bxg5 { Bxg5 e5 } Nc5
10. Rxa8 Nd3+
11. cxd3 { cxd3 Qxa8 } Qxa8 { Qxa8 f4 }
12. Nxc7+ Kd7 { Kd7 Qa4+ }
13. Nxa8 e5 { e5 Qa4+ }
14. Qa4+ { Qa4+ Kc8 } Kc8 { Kc8 dxe5 }
15. Qxb4 Bxb4+ { Bxb4+ Bd2 }
16. Bd2 { Bd2 Bxd2+ } Bxd2+ { Bxd2+ Kxd2 }
17. Kxd2 { Kxd2 exd4 f4 } exd4 { exd4 e4 }
18. f4 { f4 Bxe2 } h5 { h5 e4 }
19. h4 { h4 Kb7 } Rh6 { Rh6 Nc7 }
20. Nb6+ { Nb6+ Kb8 } Rxb6 { Rxb6 Kc2 Kc7 }
21. Kc1 { Kc1 Bxe2 } Kc7 { Kc7 e4 }
22. Nh3 { Nh3 Rb1+ } Ra6
23. Kb1 { Kb1 Bxe2 } Ra5
24. Bg2 { Bg2 Ra1+ } Rb5+ { Rb5+ Kc2 }
25. Kc1 { Kc1 Rb1+ } Rc5+ { Rc5+ Kb1 }
26. Kb2 { Kb2 Rc2+ } Rb5+ { Rb5+ Ka3 }
27. Ka3 { Ka3 Ra5+ } Ra5+ { Ra5+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kf6 { Kf6 Kd6 Kg7 f6+ }
54. Rh8 { Rh8 Ke5 f6 } Ke5 { Ke5 h5 Ke4 }
55. Ra8 { Ra8 Kf6 Ra2 } Ke4 { Ke4 f6 Kd3 }
56. f6 { f6 Kd3 Ra2 } Ke5 { Ke5 f7 Kxe6 h5 }
57. f7 { f7 Kxe6 h5 } Kxe6 { Kxe6 Ra7 Ke5 }
58. f8=Q { f8=Q Ke5 Re8#	1-0 } Kd7 { Kd7 Re8 Kc7 Re7#	1-0 }
59. Qd6#	1-0
{ Initial time: 30 }
{ Moves to reset clocks: 0 }
{ Time left: White: 4.67683 }
{            Black: 8.20148 }

Move 58 for Black seems too optimistic. It may actually be that the alpha-beta pruning is working and there really is nothing better. Every move is a loss and any move is returned. It may just be the commentary that is misleading due to the early break.

from genetic_chess.

MarkZH avatar MarkZH commented on July 28, 2024

Instead of alpha and beta just being numbers, they should be Game_Tree_Node_Results and compared the same way. Create

bool operator>(const Game_Tree_Node_Result&, const Game_Tree_Node_Result&)

bool operator==(const Game_Tree_Node_Result&, const Game_Tree_Node_Result&)

bool operator>=(const Game_Tree_Node_Result&, const Game_Tree_Node_Result&)

As well as corresponding +/-infinte values for Game_Tree_Node_Result. The inequality comparisons should act the same as the current game_tree_search() comparison:

  1. Prefer the higher score.
  2. Else, prefer a win at shallower depths.
  3. Else, prefer a loss at greater depths.

from genetic_chess.

MarkZH avatar MarkZH commented on July 28, 2024

Above comment implemented in commit 22fdb00.

from genetic_chess.

MarkZH avatar MarkZH commented on July 28, 2024

Logic errors discovered without this capability. Analyzing game records and commentary is enough. The Game_Tree_Node_Result comparisons fixed the original problem in commit 22fdb00.

from genetic_chess.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.