# Figuring out evaluator function for best-first search

While running a best-first search from M Tim Jones' *Artificial Intelligence: A Systems Approach*, we're asked to determine how the next moves are generated and why the solution is picked. In order to do that, two code sections are stumping us: #define checkPiece( board, y )((board & (1 << (15-y))) ? 1 : 0) #define MAX_TESTS 14 #define MAX_VECTOR 4 typedef struct { unsigned char len; unsigned char vector[MAX_VECTOR]; } test_t; and const test_t tests[MAX_TESTS]={ { 4, { 0, 4, 8, 12 } }, { 4, { 1, 5, 9, 13 } }, { 4, { 2, 6, 10, 14 } }, { 4, { 3, 7, 11, 15 } }, { 2, { 8, 13 } }, { 3, { 4, 9, 14 } }, { 4, { 0, 5, 10, 15 } }, { 3, { 1, 6, 11 } }, { 2, { 2, 7 } }, { 2, { 1, 4 } }, { 3, { 2, 5, 8 } }, { 4, { 3, 6, 9, 12 } }, { 3, { 7, 10, 13 } }, { 2, { 11, 14 } } }; Both these are used in the EvaluateBoard function void evaluateBoard( node_t *node_p ) { int test, i, check; int cost = 0; for (test = 0 ; test < MAX_TESTS ; test++) { check = 0; for (i = 0 ; i < tests[test].len ; i++) { check += checkPiece( node_p->board, tests[test].vector[i] ); } if (check > 1) cost+= (check-1); } node_p->g = cost; printf(" evaluateBoard %04x = (h %d, g %d)\n", node_p->board, node_p->h, node_p->g); return; } The next move is determined by the Cost int, and is a result of the checkPiece result. In this case, board== 1288, but how is the y value chosen from `test_t tests`? Also, just what is the structure `test_t tests`? We've never seen anything similar in C code. Is it a form of multi-dimensional array?