giewev / Classy

MIT License
1 stars 0 forks source link

Preserve danger calculations when possible #10

Open giewev opened 7 years ago

giewev commented 7 years ago

Currently we have to calculate the checks, pins, and discoveries for each board position we reach. However, on average it is likely that 2 consecutive positions have the same dangers. There are two ways that we can take advantage of this.

  1. The easy way: Come up with some ways to rule out moves as not affecting the existing danger state. Using that, simple use the previous board state's danger state whenever a move is guaranteed not to invalidate it.
  2. The right way: Fully figure out how a move affects an existing danger state and leverage the old danger, old board state, move info, and new board state to calculate the new danger efficiently (When necessary, and only for those pins, discoveries etc which may be affected)
giewev commented 7 years ago

I think there may also be duplication of effort where the evaluator and move generators are both calculating danger values for a position. Additionally, danger values may be being recalculated in general, so including it in the hash lookup would be helpful. I'm not sure if I want to pass the whole transposition table into the evaluator (For both performance and code complexity). But ultimately it's probably the best way to avoid global state.