nknguyenhc / CS3263-project

Xiangqi engine using principal variation search
0 stars 0 forks source link

Sacrifice piece for nothing in midgame #9

Closed nknguyenhc closed 7 months ago

nknguyenhc commented 7 months ago

This bug is due to the progression of the game, not due to calculation error.

Player's side: red, engine's side: black

Game progression:

  1. E3+5 R2+3
  2. P7+1 E7+5
  3. H8+7 H8+6
  4. R9+1 R1+1
  5. R9.6 C2.1
  6. H7+8 C1+4
  7. P3+1 P1+1
  8. H2+3 P1+1
  9. H8+7 R1+2
  10. C8.7 C1.3
  11. R6+7 C3-3
  12. C7+4 R1.3
  13. R6.4 P9+1
  14. C2.1 C8+6
  15. A4+5 C8-1
R1 -- -- -- K1 A1 E1 -- --
-- -- -- -- A1 -- -- -- --
C1 C0 H1 -- E1 -- -- -- --
P1 -- -- -- P1 -- -- -- --
-- -- P1 -- -- -- P1 -- P0
P0 -- -- -- -- -- -- -- --
-- -- P0 -- P0 -- R0 -- --
-- -- -- -- E0 -- H0 -- --
-- -- -- R1 -- -- -- -- --
R0 -- -- A0 K0 A0 E0 -- --

The above board is reverted for the perspective of the engine.

At this state, red can simply capture black's cannon by R4.2.

When re-inputting the same board, engine chooses R9+2.

nknguyenhc commented 7 months ago

Engine is red, player is black

  1. H8+7 P3+1
  2. E3+5 P7+1
  3. H2+4 H8+7
  4. C8+3 E3+5
  5. R9+1 H2+3
  6. C8-1 C2.1
  7. C8.1 C8.9
  8. C2+5 R9.8
  9. R1.2 R1.2
  10. C2+1 R2+1
  11. C2-1 R8+1
  12. R2+6 R2+6
  13. R9+1 R2+1
  14. H4+2 H3+4
  15. E5-3 H4+3
  16. R9-1 R2-1
  17. R9.7 C1.3
  18. A6+5 H3-2
-- -- -- A1 K1 A1 E1 -- --
-- -- -- -- -- -- -- R1 --
-- -- C1 -- E1 -- H1 C0 --
P1 -- -- -- P1 -- -- R0 P1
-- H1 P1 -- -- -- P1 -- --
-- -- -- -- -- -- -- -- P0
P0 -- -- -- P0 -- P0 -- --
-- R1 H0 -- -- -- -- H0 --
-- -- R0 -- A0 -- -- -- --
-- -- E0 -- K0 A0 E0 -- --

The algo at this point chose R2.1 sacrificing the cannon for nothing?

Inputtting the same board afresh gives rise to the same move. There is likely a calculation error.

nknguyenhc commented 7 months ago

Resolved for now, but the engine sometimes still make the same mistake. Decision seems not to be consistent across all tries.