forked from ulthiel/polyglot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colour.c
55 lines (30 loc) · 718 Bytes
/
colour.c
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
// colour.c
// includes
#include "colour.h"
#include "util.h"
// functions
// colour_is_ok()
bool colour_is_ok(int colour) {
return colour == Black || colour == White;
}
// colour_is_white()
bool colour_is_white(int colour) {
ASSERT(colour_is_ok(colour));
return colour == White;
}
// colour_is_black()
bool colour_is_black(int colour) {
ASSERT(colour_is_ok(colour));
return colour == Black;
}
// colour_equal()
bool colour_equal(int colour_1, int colour_2) {
ASSERT(colour_is_ok(colour_2));
return (colour_1 & colour_2) != 0;
}
// colour_opp()
int colour_opp(int colour) {
ASSERT(colour_is_ok(colour));
return colour ^ (BlackFlag^WhiteFlag);
}
// end of colour.cpp