Creating position that is difficult to assess

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

Moderator: Ras

Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Creating position that is difficult to assess

Post by Ferdy »

I am trying some experiment on how a computer might choose a move
to make such that the human opponent will experience a somewhat complicated or perhaps a position that is not that easy to calculate. This is from an inspiration of the match Komodo giving knight odds to a human master.

Given a position, a computer will search for a move that it considered best for him, considering contempt and other things.

I am examining game 4 of that match. Say white to play (Komodo) at move 12.

Code: Select all

Calculate complexity at move no. 12

FEN: 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
Player move: g3
[d]2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
White played g3 in actual game.
To see the possible alternative moves here I let SF6 analyze this position for 5 minutes at multipv 5 on 4 threads, and it comes up with.

Code: Select all

engine  : id name Stockfish 6 64 POPCNT
hash    : 256 MB
threads : 4

Top pv at 300s of analysis on multipv 5

[30, 1, 190170, -322, 'g2g3 h7h5 f3f4 e5f6 f1d3', 'g2g3']
[30, 2, 263947, -331, 'f1d3 h7h5 h3h4 g8e7 g2g3', 'f1d3']
[30, 3, 263947, -338, 'h3h4 d4d3 b2e5 c6e5 c2c3', 'h3h4']
[30, 4, 263947, -346, 'a1e1 h7h5 h3h4 g8h6 g2g3', 'a1e1']
[30, 5, 263947, -348, 'f1b5 g8e7 h3h4 a7a6 b5d3', 'f1b5']

Code: Select all

[30, 1, 190170, -322, 'g2g3 h7h5 f3f4 e5f6 f1d3', 'g2g3']
Format is just.
depth, multipv num, time in ms, eval in cp, pv in uci format, first move in pv in uci format.
Important to look here is the eval and the move, since we will not choose a move whose score is too far from the best score of the best move found in multipv 1. This early into the game the eval is minus because Komodo is giving a knight at the start of the game.
Here I set an eval margin of 30 cp, meaning that any move score that is more than 30 cp worst from the bestmove will not be considered in the calculation of complexity.

Code: Select all

analyze each move at 75s on multipv 1
eval margin   : +30cp
ref. score    : -322cp
Each move in the 5 pvs will be evaluated to get the complexity score and move changes. The ref. score is the score of the move with multipv 1. So to determine if the move in multipv 2 is a good alternative move, we will check its score and compare with the ref. score.
gap = score_in_pv1 - score_in_pv2
gap = -322 - (-331) = 9
This would mean that move2 is not that bad, and it will be included in the calculation of complexity. If the gap > eval margin 30cp in this case then it will not be included in complexity calculation.
In the calculation of complexity we will save two things, one is the number of move changes during engine analysis, and second the complexity number that is the sum of the depth at which there is move change.
Example, comparison starts at depth 3. At depth 4 the pv move has changed from g8e7 to d4d3, that would count move_change = 1, and complexity_value of 4, because of depth 4. Then suceeding moves will be examined as we go deeper.
info depth 1 seldepth 1 multipv 1 score cp 336 nodes 38 nps 19000 tbhits 0 time 2 pv g8e7
info depth 2 seldepth 2 multipv 1 score cp 373 nodes 86 nps 43000 tbhits 0 time 2 pv g8e7 d2d3
info depth 3 seldepth 3 multipv 1 score cp 374 nodes 152 nps 76000 tbhits 0 time 2 pv g8e7 d2d3 g7g6
info depth 4 seldepth 4 multipv 1 score cp 339 nodes 467 nps 233500 tbhits 0 time 2 pv d4d3 b2e5 c6e5 c2d3

info depth 5 seldepth 6 multipv 1 score cp 248 nodes 1565 nps 521666 tbhits 0 time 3 pv d4d3 b2e5 c6e5 f3f4 d3c2
info depth 6 seldepth 6 multipv 1 score cp 248 nodes 1957 nps 652333 tbhits 0 time 3 pv d4d3 b2e5 c6e5 f3f4 d3c2 f4e5
info depth 7 seldepth 8 multipv 1 score cp 248 nodes 3268 nps 817000 tbhits 0 time 4 pv d4d3 b2e5 c6e5 f3f4
info depth 8 seldepth 9 multipv 1 score cp 289 nodes 5269 nps 1053800 tbhits 0 time 5 pv d4d3 b2e5 c6e5 f3f4 g8e7 f4e5
info depth 9 seldepth 12 multipv 1 score cp 246 nodes 52209 nps 3263062 tbhits 0 time 16 pv g8f6 f1c4 c8b8 h1e1 h8f8 f3f4

info depth 10 seldepth 12 multipv 1 score cp 272 nodes 82703 nps 3308120 tbhits 0 time 25 pv d4d3 c2c3 g8e7 f3f4
info depth 11 seldepth 12 multipv 1 score cp 280 nodes 93505 nps 3339464 tbhits 0 time 28 pv d4d3 c2c3 g8e7 f3f4
info depth 12 seldepth 14 multipv 1 score cp 287 nodes 140187 nps 3594538 tbhits 0 time 39 pv d4d3 b2e5 c6e5 f3f4
info depth 13 seldepth 20 multipv 1 score cp 277 nodes 639221 nps 5113768 tbhits 0 time 125 pv e5f6 f3f4 g8e7 b3b4 e7d5
info depth 14 seldepth 20 multipv 1 score cp 269 nodes 889843 nps 5265343 tbhits 0 time 169 pv e5f6 b3b4 h7h5 b4b5
info depth 15 seldepth 20 multipv 1 score cp 281 nodes 1464434 nps 5464305 tbhits 0 time 268 pv g8e7 f3f4 e5f6 b3b4 e7d5
info depth 16 seldepth 20 multipv 1 score cp 282 nodes 1868486 nps 5447481 tbhits 0 time 343 pv g8e7 f3f4 e5f6 b3b4 e7d5
info depth 17 seldepth 20 multipv 1 score cp 284 nodes 2929273 nps 5665905 tbhits 0 time 517 pv g8e7 f1c4 e7d5 a1e1
info depth 18 seldepth 23 multipv 1 score cp 287 nodes 4306924 nps 5828043 tbhits 0 time 739 pv g8e7 f3f4 e5f6 f1c4 e7d5
info depth 19 seldepth 25 multipv 1 score cp 294 nodes 6630447 nps 5920041 tbhits 0 time 1120 pv g8e7 f1c4 e7d5 h3h4 h7
info depth 20 seldepth 27 multipv 1 score cp 297 nodes 9457413 nps 5918280 tbhits 0 time 1598 pv g8e7 f3f4 e5f6 b3b4 e7d5 b4b5
info depth 21 seldepth 29 multipv 1 score cp 292 nodes 13887733 nps 5912189 tbhits 0 time 2349 pv g8e7 f1c4 e7d5 h3h4 h7
Once completed we have move changes and complexity value. The idea is that whenever an engine changes its bestmove, it has difficulties assessing the position. Best move changes that happened at higher depths is an indication that there is something in the position that is difficult to evaluate, and we covered it by adding the depth to complexity value.

To get the complexity for our opponent (human) we will give the engine the current position + the move in each of the 5 pvs, because the engine will calculate the complexity of the position when the computer is to move.
Example.

Code: Select all

multipv num   : 1
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : g2g3
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3PPP/1BPP1K2/R4B1R b - - 0 12
move changes  : 5
complexity    : 51
expected reply: g8e7 a1e1 h7h5 f3f4 e5f6
The old fen is the current position that white is to play.
The new move is the move in one of the move in the 5 pvs.
The new fen is the old fen + the new move, meaning we make the move in the board and get the fen.
This new fen is the fen that we sent to the engine to get the complexity, and it is opponent to play, meaning human to play, we try to determine if the engine difficulties could also be a difficulty to the human opponent.
The move changes 5 is what we get when we let SF6 on 4 threads analyze the position at 75s on multipv 1.
Complexity is the sum of depth where move changed has happened.
expected reply is the a move or pv output of the engine analyzing the given new fen. It is this line that has the complexity.
After analyzing those alternatives the tool will give us the move that would generate high complexity among the moves.

Here is the complete analysis at move no. 12.
[d]2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12

Code: Select all

Calculate complexity at move no. 12

FEN: 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
Player move: g3

engine  : id name Stockfish 6 64 POPCNT
hash    : 256 MB
threads : 4

Top pv at 300s of analysis on multipv 5

[30, 1, 190170, -322, 'g2g3 h7h5 f3f4 e5f6 f1d3', 'g2g3']
[30, 2, 263947, -331, 'f1d3 h7h5 h3h4 g8e7 g2g3', 'f1d3']
[30, 3, 263947, -338, 'h3h4 d4d3 b2e5 c6e5 c2c3', 'h3h4']
[30, 4, 263947, -346, 'a1e1 h7h5 h3h4 g8h6 g2g3', 'a1e1']
[30, 5, 263947, -348, 'f1b5 g8e7 h3h4 a7a6 b5d3', 'f1b5']

analyze each move at 75s on multipv 1
eval margin   : +30cp
ref. score    : -322cp

multipv num   : 1
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : g2g3
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3PPP/1BPP1K2/R4B1R b - - 0 12
move changes  : 5
complexity    : 51
expected reply: g8e7 a1e1 h7h5 f3f4 e5f6

multipv num   : 2
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : f1d3
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP1B1P1P/1BPP1KP1/R6R b - - 3 12
move changes  : 3
complexity    : 29
expected reply: h7h5 h3h4 g7g6 g2g3 e5f6

multipv num   : 3
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : h3h4
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p3P/PP3P2/1BPP1KP1/R4B1R b - - 0 12
move changes  : 1
complexity    : 5
expected reply: d4d3 b2e5 c6e5 c2c3 g8f6

multipv num   : 4
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : a1e1
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/4RB1R b - - 3 12
move changes  : 5
complexity    : 43
expected reply: h7h5 h3h4 g8h6 g2g3 h6f5

multipv num   : 5
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : f1b5
new fen       : 2kr2nr/ppp2ppp/2n5/1B2b3/3p4/PP3P1P/1BPP1KP1/R6R b - - 3 12
move changes  : 0
complexity    : 0
expected reply: g8e7 g2g3 d4d3 b2e5 c6e5

The move that will generate the most complex position is: g2g3 
Here is a puzzle at move no. 14.
Which move you would like to make so that your human opponent will have difficulties assessing the position when it his turn to move. Note in the actual game white played Bd3.
[d]2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R w - - 0 14

Code: Select all

Calculate complexity at move no. 14

FEN: 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R w - - 0 14
Player move: Bd3

engine  : id name Stockfish 6 64 POPCNT
hash    : 256 MB
threads : 4

Top pv at 300s of analysis on multipv 5

[29, 1, 260229, -286, 'h4g5 h6g5 h1h8 e5h8 f1h3', 'h4g5']
[29, 2, 287739, -307, 'a1b1 g8e7 f1d3 a7a6 h1h2', 'a1b1']
[29, 3, 298724, -310, 'a1d1 g8e7 f1d3 a7a6 d1e1', 'a1d1']
[29, 4, 298724, -312, 'a1e1 g8e7 f1d3 a7a6 h1h3', 'a1e1']
[29, 5, 298724, -316, 'f1d3 g8e7 h1h2 d8g8 h4g5', 'f1d3']
I will post in the next page what SF6 had calculated from move 12 to move 15.

This is the record in game 4.
[pgn]
[Event "Computer chess game"]
[Site "Brussels"]
[Date "2015.08.02"]
[Round "4"]
[White "Kt-1460.00"]
[Black "Bolzoni, V"]
[Result "0-1"]
[BlackElo "2189"]
[BlackType "human"]
[FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/R1BQKBNR w KQkq - 0 1"]
[SetUp "1"]
[Termination "abandoned"]
[Time "13:57:30"]
[TimeControl "2700+15"]
[WhiteElo "3300"]
[WhiteType "program"]

1.f4 d5 2.b3 e5 3.fxe5 Nc6 4.Bb2 d4 5.Nf3 Bg4 6.a3 Qd5 7.h3 Bxf3 8.exf3 Qxe5+
9.Qe2 Bd6 10.Qxe5+ Bxe5 11.Kf2 O-O-O 12.g3 g5 13.h4 h6 14.Bd3 Nge7 15.Rag1
Rdg8 16.Bb5 a6 17.Bd3 Kd7 18.h5 f5 19.Rd1 Rf8 20.Bc4 Nd8 21.Rhe1 Nec6 22.b4
b5 23.Ba2 Re8 24.Bb1 Rhf8 25.Bc1 Re7 26.d3 Rfe8 27.Bd2 Ne6 28.Re2 Ng7 29.f4
gxf4 30.gxf4 Bd6 31.Rxe7+ Rxe7 32.Rh1 Ne6 33.Rh4 Rg7 34.Ba2 Ncd8 35.Bd5 c6
36.Bg2 Nc7 37.c3 Nd5 38.Bxd5 cxd5 39.cxd4 Ne6 40.Be3 Rg8 41.Rh1 Bxf4 42.Bxf4
Nxf4 43.Ke3 Ne6 44.Kf2 Rg4 45.a4 Rxd4 46.axb5 Rxb4 47.bxa6 Ra4 48.Kg3 Rxa6
49.Rf1 f4+ 50.Kg4 Ra3 51.Kf5 Rxd3 52.Ra1 f3 53.Ra7+ Nc7 54.Ra2 Re3 55.Rf2 Ne6
56.Kg6 Nf4+ 57.Kg7 0-1[/pgn]
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Creating position that is difficult to assess

Post by Ferdy »

Calculations on move 12 to 15.

Code: Select all

Cpu   : Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz

pgn file game 1

Calculate complexity at move no. 12

FEN: 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
Player move: g3

engine  : id name Stockfish 6 64 POPCNT
hash    : 256 MB
threads : 4

Top pv at 300s of analysis on multipv 5

[30, 1, 190170, -322, 'g2g3 h7h5 f3f4 e5f6 f1d3', 'g2g3']
[30, 2, 263947, -331, 'f1d3 h7h5 h3h4 g8e7 g2g3', 'f1d3']
[30, 3, 263947, -338, 'h3h4 d4d3 b2e5 c6e5 c2c3', 'h3h4']
[30, 4, 263947, -346, 'a1e1 h7h5 h3h4 g8h6 g2g3', 'a1e1']
[30, 5, 263947, -348, 'f1b5 g8e7 h3h4 a7a6 b5d3', 'f1b5']

analyze each move at 75s on multipv 1
eval margin   : +30cp
ref. score    : -322cp

multipv num   : 1
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : g2g3
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3PPP/1BPP1K2/R4B1R b - - 0 12
move changes  : 5
complexity    : 51
expected reply: g8e7 a1e1 h7h5 f3f4 e5f6

multipv num   : 2
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : f1d3
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP1B1P1P/1BPP1KP1/R6R b - - 3 12
move changes  : 3
complexity    : 29
expected reply: h7h5 h3h4 g7g6 g2g3 e5f6

multipv num   : 3
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : h3h4
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p3P/PP3P2/1BPP1KP1/R4B1R b - - 0 12
move changes  : 1
complexity    : 5
expected reply: d4d3 b2e5 c6e5 c2c3 g8f6

multipv num   : 4
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : a1e1
new fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/4RB1R b - - 3 12
move changes  : 5
complexity    : 43
expected reply: h7h5 h3h4 g8h6 g2g3 h6f5

multipv num   : 5
old fen       : 2kr2nr/ppp2ppp/2n5/4b3/3p4/PP3P1P/1BPP1KP1/R4B1R w - - 2 12
new move      : f1b5
new fen       : 2kr2nr/ppp2ppp/2n5/1B2b3/3p4/PP3P1P/1BPP1KP1/R6R b - - 3 12
move changes  : 0
complexity    : 0
expected reply: g8e7 g2g3 d4d3 b2e5 c6e5

The move that will generate the most complex position is: g2g3

Calculate complexity at move no. 13

FEN: 2kr2nr/ppp2p1p/2n5/4b1p1/3p4/PP3PPP/1BPP1K2/R4B1R w - g6 0 13
Player move: h4

engine  : id name Stockfish 6 64 POPCNT
hash    : 256 MB
threads : 4

Top pv at 300s of analysis on multipv 5

[27, 1, 182708, -277, 'h3h4 g5h4 h1h4 h7h5 f3f4', 'h3h4']
[27, 2, 188004, -322, 'a1e1 h7h5 h3h4 g5h4 h1h4', 'a1e1']
[27, 3, 197178, -350, 'f1d3 e5f6 b3b4 g8e7 a1e1', 'f1d3']
[27, 4, 294698, -352, 'a1b1 e5f6 b1e1 h7h5 b3b4', 'a1b1']
[27, 5, 297071, -355, 'f1b5 g8e7 a1e1 e5f6 b3b4', 'f1b5']

analyze each move at 75s on multipv 1
eval margin   : +30cp
ref. score    : -277cp

multipv num   : 1
old fen       : 2kr2nr/ppp2p1p/2n5/4b1p1/3p4/PP3PPP/1BPP1K2/R4B1R w - g6 0 13
new move      : h3h4
new fen       : 2kr2nr/ppp2p1p/2n5/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R b - - 0 13
move changes  : 6
complexity    : 91
expected reply: g5h4 h1h4 h7h5 a1e1 g8e7

The move that will generate the most complex position is: h3h4

Calculate complexity at move no. 14

FEN: 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R w - - 0 14
Player move: Bd3

engine  : id name Stockfish 6 64 POPCNT
hash    : 256 MB
threads : 4

Top pv at 300s of analysis on multipv 5

[29, 1, 260229, -286, 'h4g5 h6g5 h1h8 e5h8 f1h3', 'h4g5']
[29, 2, 287739, -307, 'a1b1 g8e7 f1d3 a7a6 h1h2', 'a1b1']
[29, 3, 298724, -310, 'a1d1 g8e7 f1d3 a7a6 d1e1', 'a1d1']
[29, 4, 298724, -312, 'a1e1 g8e7 f1d3 a7a6 h1h3', 'a1e1']
[29, 5, 298724, -316, 'f1d3 g8e7 h1h2 d8g8 h4g5', 'f1d3']

analyze each move at 75s on multipv 1
eval margin   : +30cp
ref. score    : -286cp

multipv num   : 1
old fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R w - - 0 14
new move      : h4g5
new fen       : 2kr2nr/ppp2p2/2n4p/4b1P1/3p4/PP3PP1/1BPP1K2/R4B1R b - - 0 14
move changes  : 0
complexity    : 0
expected reply: h6g5 h1h8 e5h8 f1b5 g8e7

multipv num   : 2
old fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R w - - 0 14
new move      : a1b1
new fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/1R3B1R b - - 1 14
move changes  : 1
complexity    : 5
expected reply: g8e7 b1e1 c8b8 f1d3 a7a6

multipv num   : 3
old fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R w - - 0 14
new move      : a1d1
new fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/3R1B1R b - - 1 14
move changes  : 3
complexity    : 43
expected reply: g5h4 h1h4 d4d3 c2c3 h6h5

multipv num   : 4
old fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R w - - 0 14
new move      : a1e1
new fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/4RB1R b - - 1 14
move changes  : 1
complexity    : 5
expected reply: g8e7 f1d3 c8b8 h1h2 d8g8

multipv num   : 5
old fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP3PP1/1BPP1K2/R4B1R w - - 0 14
new move      : f1d3
new fen       : 2kr2nr/ppp2p2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/R6R b - - 1 14
move changes  : 0
complexity    : 0
expected reply: g8e7 a1e1 e5f6 h4g5 h6g5

The move that will generate the most complex position is: a1d1


Calculate complexity at move no. 15

FEN: 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/R6R w - - 2 15
Player move: Rag1

engine  : id name Stockfish 6 64 POPCNT
hash    : 256 MB
threads : 4

Top pv at 300s of analysis on multipv 5

[28, 1, 161973, -308, 'a1e1 c8b8 h1h2 d8g8 h4g5', 'a1e1']
[28, 2, 165255, -312, 'h1h2 d8g8 h4g5 h6g5 h2h1', 'h1h2']
[28, 3, 180673, -312, 'a1c1 a7a6 c1b1 c8b8 h4g5', 'a1c1']
[28, 4, 269576, -315, 'a1f1 e5d6 f1e1 c6e5 d3f1', 'a1f1']
[28, 5, 269576, -312, 'a1c1 a7a6', 'a1c1']

analyze each move at 75s on multipv 1
eval margin   : +30cp
ref. score    : -308cp

multipv num   : 1
old fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/R6R w - - 2 15
new move      : a1e1
new fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/4R2R b - - 3 15
move changes  : 6
complexity    : 65
expected reply: e5f6 h4g5 h6g5 d3e4 f6e5

multipv num   : 2
old fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/R6R w - - 2 15
new move      : h1h2
new fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K1R/R7 b - - 3 15
move changes  : 8
complexity    : 117
expected reply: d8g8 a1g1 a7a6 h4g5 h6g5

multipv num   : 3
old fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/R6R w - - 2 15
new move      : a1c1
new fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/2R4R b - - 3 15
move changes  : 4
complexity    : 42
expected reply: e5d6 c1e1 c8b8 h4g5 h6g5

multipv num   : 4
old fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/R6R w - - 2 15
new move      : a1f1
new fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/5R1R b - - 3 15
move changes  : 4
complexity    : 63
expected reply: e5d6 h4g5 h6g5 f2g2 c8b8

multipv num   : 5
old fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/R6R w - - 2 15
new move      : a1c1
new fen       : 2kr3r/ppp1np2/2n4p/4b1p1/3p3P/PP1B1PP1/1BPP1K2/2R4R b - - 3 15
move changes  : 6
complexity    : 81
expected reply: e5d6 h4g5 h6g5 f2g2 a7a6

The move that will generate the most complex position is: h1h2
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Creating position that is difficult to assess

Post by Ferdy »

Sample run below, it will ask for the engine exe file, then ask the pgn and others. At the moment the hash of engine is set at 256mb, and will only analyze if side to move is white. Try to clean your pgn file, remove comments and variations. If there are more than 1 game in the pgn file, it will also be evaluated on same start move no. and end move no. so better to have only one game in a pgn file if you want different move range to be analyzed.
Two output files will be generated, the engine_log.txt and the analysis_log.txt, all are append mode, so be sure to delete the engine_log.txt when you don't need it anymore, or just make a copy for backup since it will easily gets bigger. Summaries are in analysis_log.txt
Only tested on windows 7 with SF6 and H4 engines. Engine that supports multipv could probably be used too.
If you want to analyze only move 20, just enter 20 to start and end move no.

Code: Select all

Move Complexity Generator v1.0

enter engine filename? sf6.exe
enter pgn filename? komodo-bolzoni-r4.pgn
enter number of threads to be used by the engine? 4
enter analysis time/pos in ms? 300000
enter the move number to start the analysis? 12
enter the move number to end the analysis? 15
Download:
http://www.mediafire.com/download/cpa3a ... tor_v1.rar
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Creating position ... nimzo-indian at move 4

Post by Ferdy »

What is the best move for white to complicate the position according to SF6?

[d]rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PP2PPPP/R1BQKBNR w KQkq - 2 4

Code: Select all

Cpu   : Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz

pgn file game 1


Calculate complexity at move no. 4

FEN: rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PP2PPPP/R1BQKBNR w KQkq - 2 4
Player move: Nf3

engine  : id name Stockfish 6 64 POPCNT
hash    : 256 MB
threads : 4


Top pv at 300s of analysis on multipv 5

[28, 1, 256872, 18, 'g1f3 e8g8 e2e3 c7c5 f1d3', 'g1f3']
[28, 2, 256872, 15, 'e2e3 e8g8 g1f3 c7c5 f1d3', 'e2e3']
[28, 3, 256872, 8, 'c1f4 b7b6 g1f3 c8b7 e2e3', 'c1f4']
[28, 4, 256872, 7, 'c1d2 b7b6 g1f3 c8b7 e2e3', 'c1d2']
[28, 5, 256872, 5, 'd1c2 d7d5 e2e3 e8g8 g1f3', 'd1c2']

analyze each move at 75s on multipv 1
eval margin   : +30cp
ref. score    : +18cp

multipv num   : 1
old fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PP2PPPP/R1BQKBNR w KQkq - 2 4
new move      : g1f3
new fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N2N2/PP2PPPP/R1BQKB1R b KQkq - 3 4
move changes  : 9
complexity    : 122
expected reply: b7b6 e2e3 e8g8 f1d3 c8b7

multipv num   : 2
old fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PP2PPPP/R1BQKBNR w KQkq - 2 4
new move      : e2e3
new fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N1P3/PP3PPP/R1BQKBNR b KQkq - 0 4
move changes  : 5
complexity    : 74
expected reply: e8g8 f1d3 d7d5 g1e2 b7b6

multipv num   : 3
old fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PP2PPPP/R1BQKBNR w KQkq - 2 4
new move      : c1f4
new fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP1B2/2N5/PP2PPPP/R2QKBNR b KQkq - 3 4
move changes  : 9
complexity    : 140
expected reply: b7b6 g1f3 f6e4 d1c2 c8b7

multipv num   : 4
old fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PP2PPPP/R1BQKBNR w KQkq - 2 4
new move      : c1d2
new fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PP1BPPPP/R2QKBNR b KQkq - 3 4
move changes  : 5
complexity    : 71
expected reply: e8g8 e2e3 b7b6 g1f3 d7d5

multipv num   : 5
old fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PP2PPPP/R1BQKBNR w KQkq - 2 4
new move      : d1c2
new fen       : rnbqk2r/pppp1ppp/4pn2/8/1bPP4/2N5/PPQ1PPPP/R1B1KBNR b KQkq - 3 4
move changes  : 3
complexity    : 48
expected reply: e8g8 a2a3 b4c3 b2c3 c7c5

The move that will generate the most complex position is: c1f4
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Creating position that is difficult to assess

Post by Ferdy »

Code: Select all

Version 2
1. Added hash size option
2. Added what color to analyze option
3. Improve engine_log.txt, added reformatted multipv lines
also it is now deleted at program startup so its size
will not increase in every run.
4. Improve parsing of multipv lines, it may happen that there are
two moves in the multipv lines that are the same, I hope this version
will finally fixed this issue. Parsing SF6 pv lines on multipv mode is a challenge since it sends pv at anytime, on different depths and multipv numbers.
Note:
The analysis time you input at the prompt will be the time to analyze the given position at multipv 5.
But during analysis of complexity for each move at multipv 1,
the time used is user_input_time_in_ms/4. You may notice this in the analysis_log.txt

Download:
http://www.mediafire.com/download/8pw7i ... tor_v2.rar
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Creating position that is difficult to assess

Post by Ferdy »

Here is version 3.0
Changes:
1. Make move candidate eval margin as a user option
2. Calculation of complexity value starts at iteration 7, meaning check if best move at iteration 8 is not the same at iteration 7, then, 9 vs 8 and so on.

Download:
http://www.mediafire.com/download/3dp2b ... tor_v3.rar

Note better to have 1 game only in a pgn file.
User avatar
Laskos
Posts: 10948
Joined: Wed Jul 26, 2006 10:21 pm
Full name: Kai Laskos

Re: Creating position that is difficult to assess

Post by Laskos »

Ferdy wrote:Here is version 3.0
Changes:
1. Make move candidate eval margin as a user option
2. Calculation of complexity value starts at iteration 7, meaning check if best move at iteration 8 is not the same at iteration 7, then, 9 vs 8 and so on.

Download:
http://www.mediafire.com/download/3dp2b ... tor_v3.rar

Note better to have 1 game only in a pgn file.
Great Ferdy. This can be very helpful to play against humans. Would be fun to test SF at rook odds against a 2000 engine, if it would be possible to embed SF in an exe playing the most complex reasonable moves. Also, maybe to build nasty opening books against humans and weak engines.
Vinvin
Posts: 5311
Joined: Thu Mar 09, 2006 9:40 am
Full name: Vincent Lejeune

Re: Creating position that is difficult to assess

Post by Vinvin »

Laskos wrote:
Ferdy wrote:Here is version 3.0
Changes:
1. Make move candidate eval margin as a user option
2. Calculation of complexity value starts at iteration 7, meaning check if best move at iteration 8 is not the same at iteration 7, then, 9 vs 8 and so on.

Download:
http://www.mediafire.com/download/3dp2b ... tor_v3.rar

Note better to have 1 game only in a pgn file.
Great Ferdy. This can be very helpful to play against humans. Would be fun to test SF at rook odds against a 2000 engine, if it would be possible to embed SF in an exe playing the most complex reasonable moves. Also, maybe to build nasty opening books against humans and weak engines.
It would be even better if someone could modify the SF code to use this feature ! 8-)
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Creating position that is difficult to assess

Post by Ferdy »

Laskos wrote:
Ferdy wrote:Here is version 3.0
Changes:
1. Make move candidate eval margin as a user option
2. Calculation of complexity value starts at iteration 7, meaning check if best move at iteration 8 is not the same at iteration 7, then, 9 vs 8 and so on.

Download:
http://www.mediafire.com/download/3dp2b ... tor_v3.rar

Note better to have 1 game only in a pgn file.
Great Ferdy. This can be very helpful to play against humans. Would be fun to test SF at rook odds against a 2000 engine, if it would be possible to embed SF in an exe playing the most complex reasonable moves. Also, maybe to build nasty opening books against humans and weak engines.
Instead of reading from pgn file, I create a uci interface that accepts position fen .. and go movetime ... commands then just call the real uci engine to do the job :). This is how it would look so far.

[d]r2qk2r/pp2bppp/2n1pn2/3p4/3P4/2N2BP1/PP2PP1P/R1BQ1RK1 w kq - 0 10

Code: Select all

UCI Engine Interface v1.0

uci
id name UCI Engine Interface v1.0
id author Ferdinand Mosca
position fen r2qk2r/pp2bppp/2n1pn2/3p4/3P4/2N2BP1/PP2PP1P/R1BQ1RK1 w kq - 0 10 
go movetime 30000

engine  : id name Stockfish 6 64 POPCNT
hash    : 64 MB
threads : 1

Top pv at 30s of analysis on multipv 5

1  +11/21    21.2s pv c1f4 a8c8 e2e3 e8g8 a1c1 h7h6 h2h4
2  +11/21    23.1s pv b2b3 d8a5 c1b2 e7a3 b2a3 a5a3 e2e4
3   +6/21    24.5s pv a2a3 a8c8 b2b4 d8b6 c1e3 e8g8 c3a4
4   +2/21    24.5s pv e2e3 a8c8 c1d2 e8g8 a1c1 a7a6 c3e2
5   -1/21    28.2s pv d1d3 e8g8 c1f4 h7h6 a1c1 a8c8 f1d1

analyze each move at 7s on multipv 1
eval margin   : +50cp
ref. score    : +11cp

multipv num   : 1
old fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P4/2N2BP1/PP2PP1P/R1BQ1RK1 w kq - 0 10
make move     : c1f4
new fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P1B2/2N2BP1/PP2PP1P/R2Q1RK1 b kq - 1 10
move changes  : 2
complexity    : 21
expected reply: e8g8 d1d2 e7d6 f4d6 d8d6 a1c1 a8c8

multipv num   : 2
old fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P4/2N2BP1/PP2PP1P/R1BQ1RK1 w kq - 0 10
make move     : b2b3
new fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P1B2/1pN2BP1/P3PP1P/R2Q1RK1 w kq - 0 11
move changes  : 2
complexity    : 18
expected reply: a2b3 e8g8 d1d2 e7b4 d2d3 h7h6 h2h4

multipv num   : 3
old fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P4/2N2BP1/PP2PP1P/R1BQ1RK1 w kq - 0 10
make move     : a2a3
new fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P1B2/PpN2BP1/4PP1P/R2Q1RK1 b kq - 0 11
move changes  : 2
complexity    : 25
expected reply: d8b6 a1b1 c6d4 f4e3 d4f3 e2f3 b6d8

multipv num   : 4
old fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P4/2N2BP1/PP2PP1P/R1BQ1RK1 w kq - 0 10
make move     : e2e3
new fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P1B2/PpN1pBP1/5P1P/R2Q1RK1 w kq - 0 12
move changes  : 2
complexity    : 20
expected reply: f4e3 c6a5 d1d3 e8g8 f1b1 d8b6 f3d1

multipv num   : 5
old fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P4/2N2BP1/PP2PP1P/R1BQ1RK1 w kq - 0 10
make move     : d1d3
new fen       : r2qk2r/pp2bppp/2n1pn2/3p4/3P1B2/PpNQpBP1/5P1P/R4RK1 b kq - 1 12
move changes  : 2
complexity    : 19
expected reply: e3f2 f1f2 e8g8 a1b1 d8b6 f4e3 c6a5

The move that will generate the most complex position is: a2a3

bestmove a2a3
User avatar
Marek Soszynski
Posts: 587
Joined: Wed May 10, 2006 7:28 pm
Location: Birmingham, England

Re: Creating position that is difficult to assess

Post by Marek Soszynski »

Intriguing program!

Who'd have thought that after 1.e4
"The move that will generate the most complex position is: c7c6"!

I can't wait to get my hands on UCI Engine Interface v1.0.
Marek Soszynski