Beispiel #1
0
int main()
{
	board_position *spot;
	value *now;
	int i,j;
	sudoku_board * f;
	f = (sudoku_board *) sudokucreator();
	srand(time(NULL));
	random_board(f);
	/*j=0;
	for(i=0;i<1000;i++)
	{
		value_filler(f);
		j +=random_board(f);
	}
	printf("%d out of %i",j,i);
	*///generic_board(f);
	//spot = (board_position *) get_unfilled_space(f);
	//fill_with_random_sudoku_value(spot);
	//remove_same_from_row(f,spot);
	
	
	
	
	
	/*for(i=0;i<10000000;i++)
	{
		fill_with_random_sudoku_value(spot);
		j = spot->value+j;
	}

	printf("j/%lf = %lf",i,j/i);
	fflush(stdout);
	*/
	
	/*
	printf("\nRemoving %d\n",spot->value);
	for(i=0;i<9;i++)
	{
		printf("\n %d  ",i);
		for(now=f->values[i][spot->j]->first; now != NULL; now = (value *) now->next)
		{
			printf("%d",now->available);
		}
	}
	*/
	//generic_board(f);
	boardprint(f);
	
	return 0;
}
Beispiel #2
0
static void
gameplay(void)
{
	char	buf[MAXLINE];

	while(fgets(buf, MAXLINE, stdin)){
		switch(buf[0]){
		default: help(); break;
		case 'f': game_findmove(buf+1); break;
		case 'm': game_makemove(buf+1); break;
		case 's': game_scoremove(buf+1); break;
		case 'p': boardprint(); break;
		}
	}
}
Beispiel #3
0
static void
game_makemove(char*s)
{
	char	buf[MAXLINE];
	int	x,y;
	Ori	o;
	char	c;
	Play	p;

	sscanf(s, "%d %d %c %s\n", &x, &y, &c, buf);
	o = c2ori(c);
	printf("makemove [%d %d %c %s]\n", x,y,c, buf);
	initplay(&p, x, y, o, buf);
	wordprint(&p.word);

	if(!valid(&p)) {
		printf("play not valid\n");
		return;
	}
	play(&p);
	boardprint();
}
Beispiel #4
0
    void pturn() {

        while (true) {


            if (checkmate() == 1) {
                printf("Checkmate!");
                break;
            }


            if (checkcheck(-1, -1))
                printf("Check!\n");

            char *boardchk[8][8];

            memcpy(boardchk, board, sizeof(board));
            
            boardprint();
            char move[10];
            printf("Please type a move in standard chess notation: ");
            scanf("%s", move);
            turn(move);

            if (checkcheck(-1, -1)) {
                memcpy(board, boardchk, sizeof(board));
                printf("Can not move into check!\n");
            }


            if (memcmp(board, boardchk, sizeof(board)) != 0)
                (wturn == 1) ? (wturn = 0) : (wturn = 1);


        }
    }