-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHumanPlayer.java
34 lines (30 loc) · 925 Bytes
/
HumanPlayer.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
/****************************************************************
* HumanPlayer.java
* Do not modify this file!
* This file is for humanPlayer.
*/
public class HumanPlayer extends Player {
public static final int SLEEP_TIME = 10;
public static int choice = -1;
public void move(BoardState context) {
//reset the choice from board
choice = -1;
//select the first legal move to be safe
for (int i = 0; i < 6; i++) {
if (context.isLegalMove(1, i)) {
move = i;
break;
}
}
//try to get the choice from GUI
while (choice == -1) {
Utility.tSleep(SLEEP_TIME);
}
//transform from the index of the bins to the choice
if (choice < 6)
move = choice;
else
move = choice - 6;
choice = -1;
}
}