Esempio n. 1
0
File: test.c Progetto: mkghub/pachi
static bool
test_sar(struct board *b, char *arg)
{
	enum stone color = str2stone(arg);
	arg += 2;
	coord_t *cc = str2coord(arg, board_size(b));
	coord_t c = *cc; coord_done(cc);
	arg += strcspn(arg, " ") + 1;
	int eres = atoi(arg);

	board_print_test(2, b);
	if (DEBUGL(1))
		printf("sar %s %s %d...\t", stone2str(color), coord2sstr(c, b), eres);

	assert(board_at(b, c) == S_NONE);
	int rres = is_bad_selfatari(b, color, c);

	if (rres == eres) {
		if (DEBUGL(1))
			printf("OK\n");
	} else {
		if (debug_level <= 2) {
			board_print_test(0, b);
			printf("sar %s %s %d...\t", stone2str(color), coord2sstr(c, b), eres);
		}
		printf("FAILED (%d)\n", rres);
	}
	return rres == eres;
}
Esempio n. 2
0
static bool
can_play_on_lib(struct board *b, group_t g, enum stone to_play)
{
    coord_t capture = board_group_info(b, g).lib[0];
    if (DEBUGL(6))
        fprintf(stderr, "can capture group %d (%s)?\n",
                g, coord2sstr(capture, b));
    /* Does playing on the liberty usefully capture the group? */
    if (board_is_valid_play(b, to_play, capture)
            && !is_bad_selfatari(b, to_play, capture))
        return true;

    return false;
}