aole / evolchess

Automatically exported from code.google.com/p/evolchess
0 stars 0 forks source link

Implement book moves #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Algo
====

at load default book
--------------------
1. if file default.ectb is present in path.
1.5 create a null move and point top and current to it.
2. loop each line and remove comments
2.5 set current to top
3. split line by spaces
4. 1st word is white's first move next word is blacks' first move and so on.
5. loop thru' each word
6. convert word to 64bit move
8. if current is not null and current->next is null, set curent->next to this 
move and current to current->next and continue loop.
9. if current->next is not null, loop thru all siblings of current->next
10. if move is same as one of the siblings set current to that move and 
continue loop
11. if move is not found add the move to current->next's siblings. set current 
to that move and continue loop.

data structure
--------------
struct bkmove {
  64bit move;
  bkmove *next;
  bkmove *sibling;
}

bkmove *top; // first move
bkmove *current; // current move while storing/moving book moves

default.ectb (sample)
---------------------
e2e4 e7e5 g1f3 b8c6 f1c4 -- guico piano
e2e4 e7e5 g1f3 g8f6 -- petroff

at new game
-----------
1. set in book variable
2. set current to top.

at each move
------------
1. if in book proceed otherwize get from from AI
2. if user's move, find move in current->next or its siblings
3. if move found, set current to that move, if not set out of book variable
4. if computer's move and current->next is null, ask AI to get the move
5. else set current to random sibling of current->next and return current move.

Original issue reported on code.google.com by bhupendr...@gmail.com on 2 Sep 2011 at 8:45

GoogleCodeExporter commented 8 years ago

Original comment by bhupendr...@gmail.com on 4 Sep 2011 at 5:14