Skip to content
Snippets Groups Projects
Commit acca6108 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

changes for running

parent 48bb10fa
Branches master
No related tags found
No related merge requests found
target/ target/
*.txt
# Intellij # Intellij
*.iml *.iml
......
...@@ -3,7 +3,6 @@ package com.fossgalaxy.games.fireworks; ...@@ -3,7 +3,6 @@ package com.fossgalaxy.games.fireworks;
import com.fossgalaxy.games.fireworks.human.ui.UIPlayer; import com.fossgalaxy.games.fireworks.human.ui.UIPlayer;
import com.fossgalaxy.games.fireworks.human.ui.pretty.HumanUIAgent; import com.fossgalaxy.games.fireworks.human.ui.pretty.HumanUIAgent;
import com.fossgalaxy.games.fireworks.state.actions.Action; import com.fossgalaxy.games.fireworks.state.actions.Action;
import com.fossgalaxy.games.fireworks.utils.AgentUtils;
import java.io.IOException; import java.io.IOException;
...@@ -18,12 +17,11 @@ import java.net.UnknownHostException; ...@@ -18,12 +17,11 @@ import java.net.UnknownHostException;
public class NetClient { public class NetClient {
public static void main(String[] args) { public static void main(String[] args) {
try ( try (
Socket socket = new Socket("localhost", NetServer.FIREWORKS_SERVER_PORT); Socket socket = new Socket(args[0], NetServer.FIREWORKS_SERVER_PORT);
) { ) {
UIPlayer player = new UIPlayer("iggi", new HumanUIAgent(), true); UIPlayer player = new UIPlayer("human", new HumanUIAgent(), true);
//important, this MUST be the other way round to the server or they deadlock. //important, this MUST be the other way round to the server or they deadlock.
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
......
package com.fossgalaxy.games.fireworks; package com.fossgalaxy.games.fireworks;
import com.fossgalaxy.games.fireworks.ai.AgentPlayer;
import com.fossgalaxy.games.fireworks.cluster.PredictorRunnerSingle; import com.fossgalaxy.games.fireworks.cluster.PredictorRunnerSingle;
import com.fossgalaxy.games.fireworks.players.Player; import com.fossgalaxy.games.fireworks.players.Player;
import com.fossgalaxy.games.fireworks.utils.AgentUtils;
import com.fossgalaxy.games.fireworks.utils.SetupUtils;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -20,6 +23,8 @@ public class NetServer { ...@@ -20,6 +23,8 @@ public class NetServer {
public static void main(String[] args) throws FileNotFoundException { public static void main(String[] args) throws FileNotFoundException {
boolean running = true; boolean running = true;
int nPlayers = 2;
int nAI = 1;
Random r = new Random(); Random r = new Random();
try ( try (
...@@ -32,11 +37,11 @@ public class NetServer { ...@@ -32,11 +37,11 @@ public class NetServer {
System.out.println("Waiting for players"); System.out.println("Waiting for players");
String[] agentNames = new String[4]; String[] agentNames = new String[nPlayers+nAI];
ServerNetworkPlayer[] networkPlayers = new ServerNetworkPlayer[4]; Player[] networkPlayers = new Player[nPlayers+nAI];
for (int playerID = 0; playerID < agentNames.length; playerID++) { for (int playerID = 0; playerID < nPlayers; playerID++) {
try { try {
Socket socket = serverSocket.accept(); Socket socket = serverSocket.accept();
...@@ -52,6 +57,11 @@ public class NetServer { ...@@ -52,6 +57,11 @@ public class NetServer {
} }
} }
for (int i=0; i<nAI; i++) {
agentNames[nPlayers+i] = "iggi";
networkPlayers[nPlayers+i] = new AgentPlayer("iggi", AgentUtils.buildAgent("iggi"));
}
System.out.println("The game is ready to start"); System.out.println("The game is ready to start");
playGame(agentNames, networkPlayers, r.nextLong(), statOut); playGame(agentNames, networkPlayers, r.nextLong(), statOut);
...@@ -69,7 +79,7 @@ public class NetServer { ...@@ -69,7 +79,7 @@ public class NetServer {
} }
public static void playGame(String[] agentNames, ServerNetworkPlayer[] players, long seed, PrintStream out) { public static void playGame(String[] agentNames, Player[] players, long seed, PrintStream out) {
String gameID = "net-"+System.currentTimeMillis(); String gameID = "net-"+System.currentTimeMillis();
GameRunner runner = new GameRunner(gameID, players.length); GameRunner runner = new GameRunner(gameID, players.length);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment