예제 #1
0
int UCTSearch(int MSQ[M_Sequence_Limit], int hn,int *wins,int *visits)
{
	if (hn > Open_Step_Limit)
	{
		if (MSQ[hn-1] == PASS && MSQ[hn-3] == PASS)
		{
			return PASS;
		}
	}

	Board new_board(MSQ, hn, UCT_Komi); // 取得當前盤面資訊

	if (new_board.get_LegalNum() == 0) //若沒有著手可下,則虛手
	{
		return PASS;
	}

	root = new Node(-new_board.get_color(), 0, MSQ[hn]); // color, level, move
	create_Tree(root, &new_board, hn);
	build_Tree(root, &new_board);

	int result = root->get_NodesValues(wins,visits);//最佳落子點 root沒小孩為0,有為1
    root->delete_Tree();

	return  result;
}
예제 #2
0
Tree
add_brother_Tree(Tree t, char* type){
    if (!t) {
        fprintf(stderr, "add_brother_Tree : NULL is not a correct parameter.\n");
        return NULL;
    }

    Tree tmp = create_Tree(type);

    while (t->brother) {
        t = t->brother;
    }
    t->brother = tmp;

    return tmp;
}
예제 #3
0
Tree
add_son_Tree(Tree t, char* type){
    if (!t) {
        fprintf(stderr, "add_son_Tree : NULL is not a correct parameter.\n");
        return NULL;
    }

    Tree tmp = create_Tree(type);

    if (!(t->sons))
        t->sons = tmp;

    else {
        t = t->sons;
        while (t->brother)
            t = t->brother;
        t->brother = tmp;
    }

    return tmp;
}
예제 #4
0
int UCTSearch(int MSQ[M_Sequence_Limit], int hn, float *winrate)
{
	if (hn > 40)
	{
		if (MSQ[hn-1] == PASS && MSQ[hn-3] == PASS)
		{
			return PASS;
		}
	}

	Board new_board(MSQ, hn, UCT_Komi); // 取得當前盤面資訊

	if (new_board.get_LegalNum() == 0) //若沒有著手可下,則虛手
	{
		return PASS;
	}

	root = new Node(-new_board.get_color(), 0, MSQ[hn]); // color, level, move
	create_Tree(root, &new_board, hn);
	build_Tree(root, &new_board);

	return get_BestMove(root);
}
예제 #5
0
int main()
{
	printf("main\n");
	node * root = create_Tree();
	char fname[30];
	char * word = (char *)malloc(sizeof(char)*MAXLENGTH);
	int i;
	char k[3];
	do
	{
		printf("\n1. Check a file for spelling errors.\n2. Word lookup.\n3. Add a word to dictionary.\n4. Exit.\nEnter your choice: ");
		scanf("%d",&i);
		if (i==1)
		{
			printf("Enter the name of the file you wish to run spell check on : ");
			scanf("%s", fname);
			spell_Check(fname, root);
		}
		else if (i==2)
		{
			printf("Enter the word you wish to look up : ");
			scanf("%s",word);
			if (search(root,word))
			{
				printf("The word is correctly spelled.\n");
			}
			else
			{
				printf("The word is misspelt.\n");
				printf("Word correction suggestions:\n");
				fix(word, root);
				printf("Would you like to add your word to the dictionary? Type y/n: ");
				scanf("%s", k);
				if (k[0] == 'y')
				{
					insert(root,word);
					printf("Word added\n");
				}
					
			}
		}
		
		else if (i==3)
		{
			printf("Enter the word to be added\n");
			char str[100];
			scanf("%s",str);
			if(search(root,str) == 0)
			{
				insert(root,str);
				insert_file(str);
				printf("Word added\n");
			}
			else
				printf("Already exists in dictionary\n");
		}
		
		if (i > 4 || i < 1)
			printf("Invalid choice. Enter again.\n");
	}while (i != 4);
	deleteTree(root);
	return 0;
}