Skip to content

Commit

Permalink
Reworked the initialization mechanics
Browse files Browse the repository at this point in the history
Reworked client pipeline management
Added 10 minute game mark (tested)
Added level choosing to player after the initial levels have been played

TODO: Add forced level 3 and 4
  • Loading branch information
dvionit committed May 5, 2017
1 parent 910653c commit 00a5547
Show file tree
Hide file tree
Showing 19 changed files with 42,405 additions and 247 deletions.
423 changes: 229 additions & 194 deletions .idea/workspace.xml

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion clients/GVGAI-JavaClient/src/ClientComm.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class ClientComm {

public static enum COMM_STATE {
START, INIT, INIT_END, ACT, ACT_END, ENDED, ENDED_END
START, INIT, INIT_END, ACT, ACT_END, ENDED, ENDED_END, CHOOSE
}

/**
Expand Down Expand Up @@ -130,6 +130,13 @@ private void listen() throws IOException {
writeToFile("action: " + rndAction);
writeToServer(rndAction);

}else if(commState == COMM_STATE.CHOOSE)
{
//This is the place to pick a level to be played after the initial 2 levels have gone through
Random r = new Random();
Integer message = r.nextInt(2);
writeToServer(message.toString());

}else if(commState == COMM_STATE.ENDED_END)
{
// TODO: 27/03/2017 Daniel: is the game stopped ?
Expand Down Expand Up @@ -201,6 +208,10 @@ public COMM_STATE processCommandLine() throws IOException {
game.remMillis = sso.elapsedTimer;
return COMM_STATE.ACT_END;

}else if(sso.gameState == SerializableStateObservation.State.CHOOSE_LEVEL) {
game.remMillis = sso.elapsedTimer;
return COMM_STATE.CHOOSE;

}
return commState;
}
Expand All @@ -209,6 +220,15 @@ public void processLine(String json) throws IOException{
writeToFile("initializing gson");
try {
Gson gson = new Gson();

// Debug line
//fileOutput.write(json);

if (json.equals("INIT_START")){
this.sso.gameState = SerializableStateObservation.State.INIT_STATE;
return;
}

this.sso = gson.fromJson(json, SerializableStateObservation.class);
writeToFile("gson initialized");
} catch (Exception e){
Expand Down
31 changes: 31 additions & 0 deletions debugClientLog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Listening for transport dt_socket at address: 8000
INIT_DONE
ACTION_RIGHT
ACTION_RIGHT
ACTION_LEFT
ACTION_RIGHT
ACTION_LEFT
ACTION_RIGHT
ACTION_RIGHT
ACTION_LEFT
ACTION_RIGHT
ACTION_LEFT
ACTION_RIGHT
ACTION_RIGHT
ACTION_LEFT
ACTION_RIGHT
ACTION_RIGHT
ACTION_RIGHT
ACTION_LEFT
ACTION_LEFT
ACTION_LEFT
ACTION_LEFT
ACTION_RIGHT
ACTION_RIGHT
ACTION_RIGHT
ACTION_LEFT
ACTION_RIGHT
ACTION_LEFT
ACTION_RIGHT
ACTION_RIGHT
ACTION_LEFT
Loading

0 comments on commit 00a5547

Please sign in to comment.