Skip to content
Permalink
Browse files

Change client so it takes time into account

  • Loading branch information
joesweeney committed May 1, 2017
1 parent 3dd9976 commit 25feb38bedb18de47cba4fc2ed7f9e34af697afd
Showing with 17 additions and 4 deletions.
  1. +17 −4 src/RmCheckersClient.java
@@ -55,7 +55,7 @@
public RmCheckersClient(){
_socket = openSocket();
//e = new Evaluator00();
e = new BaseEvaluator("weights/beta.csv");
e = new BaseEvaluator("weights/beta-history.csv");
endEval = new EndEvaluator("../src/weights/endbeta.csv");
currentState = new CheckersGameState3();
user = _user1;
@@ -152,8 +152,10 @@ public static void main(String[] argv){
}

public void playGame(int player) {
int minPly = 8;
int maxPly = 12;
int minPly = 10;
int maxPly = 13;
boolean switched = false;
int time = 180;
try {
String msg = readAndEcho(); // initial message
if(player == 1) { // black
@@ -165,10 +167,14 @@ else if(player == 2) { // white
readAndEcho(); // move query
}
while(currentState.actions().size()>0){
if(currentState.isEndGame() && minPly < maxPly){
if(currentState.isEndGame() && !switched){
minPly = maxPly;
switched = true;
ai.eval = endEval;
}
if(time < 30) {
minPly = 8;
}
currentState.printState();
Move myMove = ai.minimax(currentState, minPly);
writeMessageAndEcho(myMove.toString());
@@ -188,6 +194,7 @@ else if(player == 2) { // white
break;
}
msg = readAndEcho(); // move query
time = parseTime(msg);
if(msg.contains("Result")) {
System.out.println("Done.");
break;
@@ -199,6 +206,12 @@ else if(player == 2) { // white
}
}

public int parseTime(String msg) {
String time = msg.substring(msg.indexOf("(")+1,msg.indexOf(")"));
return Integer.parseInt(time);
}


public String parseMove(String msg) {
return msg.substring(11,msg.length());
}

0 comments on commit 25feb38

Please sign in to comment.
You can’t perform that action at this time.