Exemplo n.º 1
0
int declaredraw(chess *q, char *str) {
	int n;
	mvprintw(23, 110, "%s", str);
	getch();
	clear();
	init_pair(13, COLOR_WHITE, COLOR_RED); 
	bkgd(COLOR_PAIR(13));
	mvprintw(LINES / 2 - 4, COLS /2 - 1, "DRAW");
	mvprintw(LINES / 2 - 2, COLS /2 - 6, "Want to resume?");
	mvprintw(LINES / 2, COLS /2 - 5,"1. Yes 2. No");
	mvprintw(LINES / 2 + 2, COLS /2 - 5, "Enter choice");
	curs_set(1);
	mvscanw(LINES / 2 + 4, COLS /2, "%d", &n);
	curs_set(0);
	refresh();
	if(n == 1) {
		undoredo(q, "undo");
		undoredo(q, "undo");
		display(stdscr, q);
		return 0;
	}
	else {
		q->enable = DISABLE;
		savefile(q);
		return 1;
	}
}
Exemplo n.º 2
0
int declarewinner(chess *q) {
	int n; 
	if(q->state == WHITE) {
		clear();
		init_pair(13, COLOR_WHITE, COLOR_RED); 
		bkgd(COLOR_PAIR(13));
		mvprintw(LINES / 2 - 4, COLS /2 - 4, "BLACK WINS");
		mvprintw(LINES / 2 - 2, COLS /2 - 6, "Want to resume?");
		mvprintw(LINES / 2, COLS /2 - 5,"1. Yes 2. No");
		mvprintw(LINES / 2 + 2, COLS /2 - 5, "Enter choice");
		curs_set(1);
		mvscanw(LINES / 2 + 4, COLS /2, "%d", &n);
		curs_set(0);
		refresh();
		display(stdscr, q);
		if(n == 1) {
			undoredo(q, "undo");
			undoredo(q, "undo");
			display(stdscr, q);
			return 0;
		}
		else {
			savefile(q);
			getch();
			return 1;
		}
	}
	else {
		clear();
		init_pair(13, COLOR_WHITE, COLOR_RED); 
		bkgd(COLOR_PAIR(13));
		mvprintw(LINES / 2 - 4, COLS /2 - 4, "WHITE WINS");
		mvprintw(LINES / 2 - 2, COLS /2 - 6, "Want to resume?");
		mvprintw(LINES / 2, COLS /2 - 5,"1. Yes 2. No");
		mvprintw(LINES / 2 + 2, COLS /2 - 5, "Enter choice");
		/* mvprintw(22, 110, "Want to resume?"); */
		/* mvprintw(24, 110, "1. Yes 2. No"); */
		/* mvprintw(26, 110, "Enter choice"); */
		/* mvwaddch(win, 26, 123, ':'); */
		curs_set(1);
		mvscanw(LINES / 2 + 4, COLS / 2, "%d", &n);
		curs_set(0);
		refresh();
		display(stdscr, q);
		if(n == 1) {
			undoredo(q, "undo");
			undoredo(q, "undo");
			display(stdscr, q);
			return 0;
		}
		else {
			savefile(q);
			getch();
			return 1;
		}
	}
}
Exemplo n.º 3
0
int build(chess *q, tree **t, int start) {
	//printw("Entered build");
	//getch();
	tree *p;
	int i, k;
	if(q->depth >= DEPTH) {
		//printw("Ent if q->depth");
		//getch();
		push(q, &q->s, p->loc, &p->loc[4]);
		move1(q, p->loc, &p->loc[4], "exp");
		q->depth--;
		k = eval(q);
		undoredo(q, "undowithoutredo");
		return k;
	}
	inittree(t);
	p = *t;
	initmoveslist(p);
	generatemoves(q, p);
	printmlist(p);
	insertnodes(&p, p->ml, q->depth);
	if(start == 0) {
		start = 1;
	}
	else {
		push(q, &q->s, p->loc, &p->loc[4]);
		move1(q, p->loc, &p->loc[4], "exp");
	}
	for(i = 0; i < p->numchildren; i++) {
		q->depth++;
		p->children[i]->score = build(q, &p->children[i], start);
		if((q->depth % 2) == 1) {
			p->score = min(p->score, p->children[i]->score);
		}
		else {
			p->score = max(p->score, p->children[i]->score);
		}
	}
	p->score = -p->score;
	if(p->parent == NULL) {
		return p->score;
	}
	undoredo(q, "undowithoutredo");
	q->depth--;
}
Exemplo n.º 4
0
//
//	REDO the last UNDO
//
bool sequence::redo ()
{
	debug("Redo\n");
	return undoredo(redostack, undostack);
}
Exemplo n.º 5
0
// 
//	UNDO the last action
//
bool sequence::undo ()
{
	debug("Undo\n");
	return undoredo(undostack, redostack);
}