Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Final parameters set
  • Loading branch information
joesweeney committed May 2, 2017
1 parent 25feb38 commit 1c14746
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/CheckersAI.java
Expand Up @@ -56,6 +56,9 @@ public class CheckersAI{
double check; double check;
Move max = null; Move max = null;
for(Move a: s.actions()){ for(Move a: s.actions()){
if(s.actions().size() == 1) {
return a;
}
check = minValue(s.result(a), alpha, beta, depth + 1, a.isJump(), min_ply); check = minValue(s.result(a), alpha, beta, depth + 1, a.isJump(), min_ply);
if(check > v){ if(check > v){
v = check; v = check;
Expand Down
14 changes: 8 additions & 6 deletions src/RmCheckersClient.java
Expand Up @@ -55,7 +55,7 @@ public class RmCheckersClient {
public RmCheckersClient(){ public RmCheckersClient(){
_socket = openSocket(); _socket = openSocket();
//e = new Evaluator00(); //e = new Evaluator00();
e = new BaseEvaluator("weights/beta-history.csv"); e = new BaseEvaluator("weights/beta.csv");
endEval = new EndEvaluator("../src/weights/endbeta.csv"); endEval = new EndEvaluator("../src/weights/endbeta.csv");
currentState = new CheckersGameState3(); currentState = new CheckersGameState3();
user = _user1; user = _user1;
Expand Down Expand Up @@ -152,10 +152,10 @@ public class RmCheckersClient {
} }


public void playGame(int player) { public void playGame(int player) {
int minPly = 10; int minPly = 8;
int maxPly = 13; int maxPly = 8;
boolean switched = false; boolean switched = false;
int time = 180; int time = 150;
try { try {
String msg = readAndEcho(); // initial message String msg = readAndEcho(); // initial message
if(player == 1) { // black if(player == 1) { // black
Expand All @@ -170,7 +170,9 @@ public class RmCheckersClient {
if(currentState.isEndGame() && !switched){ if(currentState.isEndGame() && !switched){
minPly = maxPly; minPly = maxPly;
switched = true; switched = true;
ai.eval = endEval; if(currentState.pieceRatio(player) < 0.5){
ai.eval = endEval;
}
} }
if(time < 30) { if(time < 30) {
minPly = 8; minPly = 8;
Expand All @@ -194,11 +196,11 @@ public class RmCheckersClient {
break; break;
} }
msg = readAndEcho(); // move query msg = readAndEcho(); // move query
time = parseTime(msg);
if(msg.contains("Result")) { if(msg.contains("Result")) {
System.out.println("Done."); System.out.println("Done.");
break; break;
} }
time = parseTime(msg);
} }
} catch (IOException e) { } catch (IOException e) {
System.out.println("Failed in read/close"); System.out.println("Failed in read/close");
Expand Down

0 comments on commit 1c14746

Please sign in to comment.