Example #1
0
int main(void){
    //initialize stuff
    init_zobrist();
    srand(time(NULL));
    //create a new board
    Board_t* goal = newBoard();
    //create a new visited cache
    HashTable_t* visited = newHashTable(32);
    //create a cloned state of the board and scrable it
    Board_t* scrabled = cloneBoard(goal);
    scramble_times(scrabled, TIMES_TO_SCRAMBLE);

    printf("Starting search...\n");
    SearchNode_t* root = newSearchNode(scrabled, 0, NULL);
    SearchNode_t* result = idf_search(root, goal, visited, 30);

    //print out the search
    if(result!=NULL){
        printf("Search Path:\n");
        printSearchNode(result);
    }
    else
        printf("Search failed.\n");

    //clean up
    deleteSearchNode(root, visited);
    assert(TOTAL_SEARCH_NODES==0);
    assert(TOTAL_HASH_NODES==0);
    deleteHashTable(visited);
    deleteBoard(goal);
    return 0;
}
Example #2
0
File: perft.cpp Project: pd/benthos
int
main(int argc, char *argv[])
{
	position_t *pos = (position_t *)malloc(sizeof(position_t));
	rootPosition = pos;

	init_bitboards();
	init_mersenne();
	init_zobrist();

	for (int i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-help"))
			usage();
		else if (!strcmp(argv[i], "-noit"))
			iterate = 0;
		else if (!strcmp(argv[i], "-all"))
			test_all(pos);
		else if (!strcmp(argv[i], "-test")) {
			if (argc <= i + 2)
				usage();
			test(pos, argv[i+1], atoi(argv[i+2]));
			exit(0);
		} else
			usage();
	}

	if (argc == 1)
		test(pos, names[0], depths[0][0]);

	return 0;
}
Example #3
0
void new_hash_table()
{
    init_zobrist();
    
    hash_mask = HASH_TABLE_SIZE - 1;
    hash_table = (hash_node *)malloc(HASH_TABLE_SIZE * sizeof(hash_node));
    reset_hash_table();
}
Example #4
0
void demo() {
    int repeat = 500;
    zobrist_t k;
    init_zobrist(& k);
    for(int size = 1; size < MAX_ZOBRIST_LENGTH; ++size) {
      char * data = malloc(size);
      for(int z = 0; z < size; ++z) data[z] = (char) rand();
      uint64_t expected = zobrist (data, size, &k);
      printf(" repeatedly hashing the same string  : ");
      BEST_TIME(zobrist (data, size, &k), expected, repeat, , size);
      free(data);
    }
}