-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoc.java
133 lines (112 loc) · 2.7 KB
/
Loc.java
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
public class Loc {
private int r;
private int c;
public Loc(int rin, int cin) {
if(rin > -1 && rin < 4 && cin > -1 && cin < 8) {
r = rin;
c = cin;
}
}
public Loc() {
r = -1;
c = -1;
}
public boolean isInner() {
if(r == 1 || r == 2) {
return true;
}
return false;
}
public Loc getLocAcross() {
if(r == 1) {
return new Loc(2, c);
} else if(r == 2) {
return new Loc(1, c);
} else {
return null;
}
}
public int getKichwaSowDir() {
//1 is from left kichwas from perspective of player 2,
//-1 is from right kichwas
if(c == 0) {
return 1;
} if(c == 7) {
return -1;
}
return 0;
}
public int getRow() {
return r;
}
public int getCol() {
return c;
}
public Loc getNearestKichwa() {
if(c < 4) {
return new Loc(r, 0);
} else {
return new Loc(r, 7);
}
}
public boolean isKichwa(int player) {
if(player + 1 == r && (c == 0 || c == 7)) {
return true;
}
return false;
}
public boolean isKichwa() {
if((r == 1 || r == 2) && (c == 0 || c == 7)) {
return true;
}
return false;
}
public boolean isKimbi() {
if((r == 1 || r == 2) && (c == 1 || c == 6)) {
return true;
}
return false;
}
public boolean isKimbi(int player) {
if(player + 1 == r && (c == 1 || c == 6)) {
return true;
}
return false;
}
public boolean isNyumba() {
if((r == 1 && c == 3) || (r == 2 && c == 4)) {
return true;
}
return false;
}
public boolean isNyumba(int p) {
if(r == p + 1 && c == p + 3) {
return true;
}
return false;
}
public int whosePit() {
if(r == 0 || r == 1) {
return 0;
} else if(r == 2 || r == 3) {
return 1;
} else {
return -1;
}
}
/*
public Loc getNextLoc(int dir) { //-1 is player's left kichwa, 1 is right kichwa
int add = 1;
int nr = r;
int nc = c;
if(nr < 2) { //Player 1
if(dir == 1) { //CW
nc += add;
if(nc > 7 || nc < 0) {
add *= -1;
nc--;
nr--;
}
} else { //Player 2
}*/
}