-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdraw.cpp
More file actions
61 lines (50 loc) · 1.24 KB
/
Copy pathdraw.cpp
File metadata and controls
61 lines (50 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//===========================================================//
//
// Maverick Chess Engine
// Copyright 2013 Steve Maughan
//
//===========================================================//
#include <assert.h>
#include <stdio.h>
#include "defs.h"
#include "data.h"
#include "procs.h"
BOOL repetition_draw(struct t_board *board)
{
int i;
int reps = 0;
if (board->fifty_move_count >= 4) {
if (board->fifty_move_count >= 100) return !is_checkmate(board);
i = 4;
do
{
if (draw_stack[draw_stack_count - i] == board->hash) {
if (TRUE || draw_stack_count - i > search_start_draw_stack_count)
return TRUE;
reps++;
if (reps == 2)
return TRUE;
}
i += 2;
} while (board->fifty_move_count >= i);
}
return FALSE;
}
BOOL is_checkmate(struct t_board *board)
{
if (!board->in_check)
return FALSE;
struct t_move_list moves[1];
generate_evade_check(board, moves);
if (moves->count > 0)
return FALSE;
return TRUE;
}
BOOL is_stalemate(struct t_board *board)
{
struct t_move_list moves[1];
generate_legal_moves(board, moves);
if (moves->count > 0)
return FALSE;
return TRUE;
}