A Stockfish that tries to lose every game of chess

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Madeleine Birchfield
Posts: 512
Joined: Tue Sep 29, 2020 4:29 pm
Location: Dublin, Ireland
Full name: Madeleine Birchfield

A Stockfish that tries to lose every game of chess

Post by Madeleine Birchfield »

Somebody recently modified Stockfish to make it try to lose every game of chess:



Github page:

https://github.com/rotolonico/Badfish
Uri Blass
Posts: 10309
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: A Stockfish that tries to lose every game of chess

Post by Uri Blass »

This person clearly did a bad job because the best way to try to lose is to play well in the first moves and later when the opponent has only 2 pawns and you have a lot of pieces to force the opponent to win the game.

Based on the game that I saw when both sides are supposed to try to lose they did not use this strategy so I am sure that with this strategy it is easy to lose every game against badfish.
User avatar
towforce
Posts: 11589
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK

Re: A Stockfish that tries to lose every game of chess

Post by towforce »

Knowledge and search probably aren't of much value in this quest.

Here's a starter challenge: find a position in which you can force the opponent to beat you!

I don't think it's possible to force a loss against an opponent who refuses to beat you. You might be able to do it in checkers (draughts), but not chess.

Edit: just came up with the solution: resign on your first move.
Writing is the antidote to confusion.
It's not "how smart you are", it's "how are you smart".
Your brain doesn't work the way you want, so train it!
Tord
Posts: 31
Joined: Tue Feb 27, 2018 11:29 am

Re: A Stockfish that tries to lose every game of chess

Post by Tord »

towforce wrote: Fri Jul 02, 2021 10:04 am Here's a starter challenge: find a position in which you can force the opponent to beat you!
That's actually a somewhat common problem type in the world of chess problems. Here are a few examples:

https://www.ozproblems.com/problem-world/selfmates
User avatar
towforce
Posts: 11589
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK

Re: A Stockfish that tries to lose every game of chess

Post by towforce »

Tord wrote: Fri Jul 02, 2021 10:08 am
towforce wrote: Fri Jul 02, 2021 10:04 am Here's a starter challenge: find a position in which you can force the opponent to beat you!
That's actually a somewhat common problem type in the world of chess problems. Here are a few examples:

https://www.ozproblems.com/problem-world/selfmates

Interesting! Maybe a mate solver would be better than Stockfish for this.

Assuming resignation is disallowed, the next most obvious option is a position in which you give check to the opponent's king, and in blocking that check the opponent checkmates you.
Writing is the antidote to confusion.
It's not "how smart you are", it's "how are you smart".
Your brain doesn't work the way you want, so train it!
User avatar
CMCanavessi
Posts: 1142
Joined: Thu Dec 28, 2017 4:06 pm
Location: Argentina

Re: A Stockfish that tries to lose every game of chess

Post by CMCanavessi »

I remember Daniel (author of Andscacs) once "inverted" Andscacs eval so it would always play the worst move and called it Andworst. I tried it and found impossible to even draw with it, it would always lose.
Would be nice to match it up with that version of stockfish.

You can download Andworst here: https://file.io/Lghe5xc5mRxw
Follow my tournament and some Leela gauntlets live at http://twitch.tv/ccls
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: A Stockfish that tries to lose every game of chess

Post by MikeB »

Madeleine Birchfield wrote: Fri Jul 02, 2021 4:42 am Somebody recently modified Stockfish to make it try to lose every game of chess:



Github page:

https://github.com/rotolonico/Badfish
BadChess is alright at not winning , but it's not good at forcing you to win.
Image
Uri Blass
Posts: 10309
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: A Stockfish that tries to lose every game of chess

Post by Uri Blass »

towforce wrote: Fri Jul 02, 2021 10:04 am Knowledge and search probably aren't of much value in this quest.

Here's a starter challenge: find a position in which you can force the opponent to beat you!

I don't think it's possible to force a loss against an opponent who refuses to beat you. You might be able to do it in checkers (draughts), but not chess.

Edit: just came up with the solution: resign on your first move.

I am sure it is easy to force a weak opponent to beat you in chess without resigning.

Here is an easy way to do it against the random mover.
You need only to give the opponent 2 connected pawns

[pgn][Event "?"]
[Site "?"]
[Date "2021.07.03"]
[Round "?"]
[White "����"]
[Black "SxRandom"]
[Result "0-1"]
[ECO "B00"]
[GameDuration "00:09:30"]
[GameEndTime "2021-07-03T23:44:39.575 שעון קיץ ירושלים"]
[GameStartTime "2021-07-03T23:35:09.383 שעון קיץ ירושלים"]
[Opening "King's pawn Opening"]
[PlyCount "130"]
[TimeControl "40/300"]

1. e4 Nh6 {0s} 2. d4 {1.8s} Nc6 {0s} 3. Bxh6 {1.5s} e5 {0s} 4. dxe5 {3.2s}
Qf6 {0s} 5. exf6 {1.4s} Rg8 {0s} 6. fxg7 {3.3s} b5 {0s} 7. Bxb5 {4.3s} Rxg7 {0s}
8. Bxg7 {2.4s} Nd8 {0s} 9. Bxf8 {1.2s} Ne6 {0s} 10. Bc6 {2.9s} Kxf8 {0s}
11. Bxa8 {1.2s} Kg8 {0s} 12. Bd5 {1.3s} Nf8 {0s} 13. Qd4 {3.4s} Bb7 {0s}
14. Bxb7 {1.9s} h5 {0s} 15. Qxa7 {5.9s} Ne6 {0s} 16. Bd5 {3.2s} Nf4 {0s}
17. Nf3 {4.4s} Kf8 {0s} 18. O-O {3.6s} Nxd5 {0s} 19. exd5 {2.2s} f5 {0s}
20. Qd4 {16s} c6 {0s} 21. d6 {3.0s} c5 {0s} 22. Qe5 {2.3s} h4 {0s} 23. c4 {7.0s}
f4 {0s} 24. Nc3 {12s} Kf7 {0s} 25. Rfd1 {17s} Kg8 {0s} 26. h3 {12s} Kf7 {0s}
27. Qe7+ {1.8s} Kg6 {0s} 28. Re1 {12s} Kf5 {0s} 29. Re6 {7.0s} dxe6 {0s}
30. Re1 {3.6s} Kg6 {0s} 31. Ne4 {5.4s} Kh6 {0s} 32. Nxc5 {3.3s} Kg6 {0s}
33. Ne4 {5.4s} Kf5 {0s} 34. Qxh4 {5.9s} Kg6 {0s} 35. Ne5+ {18s} Kf5 {0s}
36. a4 {16s} f3 {0s} 37. g3 {9.8s} Kxe5 {0s} 38. a5 {15s} Kf5 {0s} 39. a6 {1.0s}
Kg6 {0s} 40. a7 {4.1s} e5 {0s} 41. Qe7 {15s} Kh6 {0s} 42. Qg5+ {16s} Kh7 {0s}
43. Qe7+ {20s} Kh8 {0s} 44. Qf8+ {3.2s} Kh7 {0s} 45. h4 {7.9s} Kg6 {0s}
46. a8=Q {16s} Kh5 {0s} 47. Qg8 {8.5s} Kh6 {0s} 48. b4 {3.2s} Kh5 {0s}
49. g4+ {9.2s} Kxh4 {0s} 50. Qg6 {3.5s} Kh3 {0s} 51. Nc3 {17s} Kh4 {0s}
52. Qae4 {47s} Kh3 {0s} 53. Kh1 {9.0s} Kh4 {0s} 54. Rg1 {7.3s} Kh3 {0s}
55. Rg2 {2.9s} fxg2+ {0s} 56. Kg1 {2.3s} Kh4 {0s} 57. f4 {15s} Kg3 {0s}
58. Qe3+ {14s} Kh4 {0s} 59. Qf3 {4.3s} exf4 {0s} 60. Qf2+ {12s} Kh3 {0.001s}
61. d7 {65s} f3 {0s} 62. Qg3+ {7.6s} Kxg3 {0s} 63. Qg5 {16s} Kh3 {0s}
64. Qh5+ {14s} Kg3 {0s} 65. Nd5 {8.1s} f2# {0s, Black mates} 0-1

[/pgn]
User avatar
hgm
Posts: 27811
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A Stockfish that tries to lose every game of chess

Post by hgm »

Uri is right. It is a common misconception to think that playing for the opposit goal requires a negated evaluation. In fact the evaluation initially is pretty much the same, initially: you want to get a large superiority in material, which you can then use to strip the opponent nearly bare, except for a few Pawns and of course a King, which you can then bend to your will.

This is not only true for Chess, but holds for a wide range of games. In the game of Nim it also doesn't matter initially whether the player that takes the last stick wins or loses; the strategies diverge only once the number of heaps with more than a single stick has been reduced to one.
User avatar
CMCanavessi
Posts: 1142
Joined: Thu Dec 28, 2017 4:06 pm
Location: Argentina

Re: A Stockfish that tries to lose every game of chess

Post by CMCanavessi »

Uri Blass wrote: Sat Jul 03, 2021 10:45 pm
towforce wrote: Fri Jul 02, 2021 10:04 am Knowledge and search probably aren't of much value in this quest.

Here's a starter challenge: find a position in which you can force the opponent to beat you!

I don't think it's possible to force a loss against an opponent who refuses to beat you. You might be able to do it in checkers (draughts), but not chess.

Edit: just came up with the solution: resign on your first move.

I am sure it is easy to force a weak opponent to beat you in chess without resigning.

Here is an easy way to do it against the random mover.
You need only to give the opponent 2 connected pawns

[pgn][Event "?"]
[Site "?"]
[Date "2021.07.03"]
[Round "?"]
[White "����"]
[Black "SxRandom"]
[Result "0-1"]
[ECO "B00"]
[GameDuration "00:09:30"]
[GameEndTime "2021-07-03T23:44:39.575 שעון קיץ ירושלים"]
[GameStartTime "2021-07-03T23:35:09.383 שעון קיץ ירושלים"]
[Opening "King's pawn Opening"]
[PlyCount "130"]
[TimeControl "40/300"]

1. e4 Nh6 {0s} 2. d4 {1.8s} Nc6 {0s} 3. Bxh6 {1.5s} e5 {0s} 4. dxe5 {3.2s}
Qf6 {0s} 5. exf6 {1.4s} Rg8 {0s} 6. fxg7 {3.3s} b5 {0s} 7. Bxb5 {4.3s} Rxg7 {0s}
8. Bxg7 {2.4s} Nd8 {0s} 9. Bxf8 {1.2s} Ne6 {0s} 10. Bc6 {2.9s} Kxf8 {0s}
11. Bxa8 {1.2s} Kg8 {0s} 12. Bd5 {1.3s} Nf8 {0s} 13. Qd4 {3.4s} Bb7 {0s}
14. Bxb7 {1.9s} h5 {0s} 15. Qxa7 {5.9s} Ne6 {0s} 16. Bd5 {3.2s} Nf4 {0s}
17. Nf3 {4.4s} Kf8 {0s} 18. O-O {3.6s} Nxd5 {0s} 19. exd5 {2.2s} f5 {0s}
20. Qd4 {16s} c6 {0s} 21. d6 {3.0s} c5 {0s} 22. Qe5 {2.3s} h4 {0s} 23. c4 {7.0s}
f4 {0s} 24. Nc3 {12s} Kf7 {0s} 25. Rfd1 {17s} Kg8 {0s} 26. h3 {12s} Kf7 {0s}
27. Qe7+ {1.8s} Kg6 {0s} 28. Re1 {12s} Kf5 {0s} 29. Re6 {7.0s} dxe6 {0s}
30. Re1 {3.6s} Kg6 {0s} 31. Ne4 {5.4s} Kh6 {0s} 32. Nxc5 {3.3s} Kg6 {0s}
33. Ne4 {5.4s} Kf5 {0s} 34. Qxh4 {5.9s} Kg6 {0s} 35. Ne5+ {18s} Kf5 {0s}
36. a4 {16s} f3 {0s} 37. g3 {9.8s} Kxe5 {0s} 38. a5 {15s} Kf5 {0s} 39. a6 {1.0s}
Kg6 {0s} 40. a7 {4.1s} e5 {0s} 41. Qe7 {15s} Kh6 {0s} 42. Qg5+ {16s} Kh7 {0s}
43. Qe7+ {20s} Kh8 {0s} 44. Qf8+ {3.2s} Kh7 {0s} 45. h4 {7.9s} Kg6 {0s}
46. a8=Q {16s} Kh5 {0s} 47. Qg8 {8.5s} Kh6 {0s} 48. b4 {3.2s} Kh5 {0s}
49. g4+ {9.2s} Kxh4 {0s} 50. Qg6 {3.5s} Kh3 {0s} 51. Nc3 {17s} Kh4 {0s}
52. Qae4 {47s} Kh3 {0s} 53. Kh1 {9.0s} Kh4 {0s} 54. Rg1 {7.3s} Kh3 {0s}
55. Rg2 {2.9s} fxg2+ {0s} 56. Kg1 {2.3s} Kh4 {0s} 57. f4 {15s} Kg3 {0s}
58. Qe3+ {14s} Kh4 {0s} 59. Qf3 {4.3s} exf4 {0s} 60. Qf2+ {12s} Kh3 {0.001s}
61. d7 {65s} f3 {0s} 62. Qg3+ {7.6s} Kxg3 {0s} 63. Qg5 {16s} Kh3 {0s}
64. Qh5+ {14s} Kg3 {0s} 65. Nd5 {8.1s} f2# {0s, Black mates} 0-1

[/pgn]
Well, you can force a random mover to beat you that easily because it has no chess knowledge so you can make it do whatever you want... but with Andworst or a chess engine programmed to try to lose, it won't fall into those easy traps. Try it, I posted a link a couple of posts above. Try to do the same with Andworst.
Follow my tournament and some Leela gauntlets live at http://twitch.tv/ccls