# Phil 5.28.20

GPT-2 Agents

• Back to bug hunting today’s job is to figure out why this:
```1. Nf3 Nf6 2. g3 c5 3. Bg2 Nc6 4. O-O e5 5. e4 Nxe4 6. Re1 Nf6 7. Nxe5 Be7 8. c4
O-O 9. Nc3 Nxe5 10. Rxe5 d6 11. Re1 Be6 12. Bxb7 Rb8 13. Bg2 Bxc4 14. d4 Be6 15.
b3 Rb4 16. dxc5 dxc5 17. Qxd8 Rxd8 18. Ba3 Rbb8 19. Na4 Rdc8 20. Rac1 Nd7 21.
Bd5 Bxd5 22. Rxe7 Bc6 23. Nxc5 Nxc5 24. Rxc5 a6 25. f4 h6 26. Kf2 Bb5 27. Ke3
Rd8 28. Rcc7 Rd3+ 29. Ke4 Rd2 30. Rxf7 Re8+ 31. Kf5 Bd3+ 32. Kg4 Rxh2 33. Rxg7+
Kh8 34. Bd6 Rf2 35. Bc5 Rd2 36. Bb4 Rc2 37. Rxc2 Kxg7 38. Rc7+ Kg6 39. Rc6+ Kf7
40. Rxh6 Re2 41. Rd6 Re3 42. Kh4 Be2 43. g4 Rf3 44. Rd4 Rf2 45. Kg5 1-0```
• breaks the system.
• So I never added logic to see if the path was clear for a move. The game has a move where white rook moves from e1 to e5 and then back. For the move back, the system looks for the closest rook, which is actually at a1, as the search algorithm works. But that way is actually blocked by the white bishop and white queen. It should take the clear path and discard blocked paths. I think this fix is pretty straightforward • Wrote the test, but I’m not sure if it’s right. We’ll test tomorrow:
```    def check_if_clear(self, loc:Tuple, candidate:Tuple, piece:PIECES) -> bool:
if piece == PIECES.WHITE_PAWN or piece == PIECES.BLACK_PAWN:
return True
if piece == PIECES.WHITE_KNIGHT or piece == PIECES.BLACK_KNIGHT:
return True
if piece == PIECES.WHITE_KING or piece == PIECES.BLACK_KING:
return True

c_col_i = self.char_index.index(candidate)
c_row_i = self.num_index.index(candidate)
l_col_i = self.char_index.index(loc)
l_row_i = self.num_index.index(loc)
col_dist = l_col_i - c_col_i
row_dist = l_row_i - c_row_i
dist = max(abs(col_dist), abs(row_dist))
col_vec = 0
row_vec = 0
if col_dist != 0:
col_vec = col_dist/dist
if row_dist != 0:
row_vec = row_dist/dist

col_i = l_col_i
row_i = l_row_i
for i in range(dist):
num = self.num_index[row_i]
char = self.char_index[col_i]
pos = (char, num)
p = self.get_piece_at(pos)
if p != PIECES.NONE:
return False
col_i += col_vec
row_i += row_vec

return True```

GOES

• More paper writing
• Finished the first pass of section 2, which describes the whole model.