-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrunMultiplayer-2.java
42 lines (36 loc) · 1.22 KB
/
runMultiplayer-2.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
35
36
37
38
39
40
41
42
import com.diarc.DiarcComponent;
public class runMultiplayer {
public static class AgentThread extends Thread {
private int index;
private int numPlayers;
private Class<? extends DiarcComponent> agentClass;
public AgentThread(Class<? extends com.diarc.DiarcComponent> agentClass, int index, int numPlayers) {
this.index = index;
this.numPlayers = numPlayers;
this.agentClass = agentClass;
}
public void run() {
DiarcComponent.createInstance(this.agentClass, new String[]{
"-agentName", "agent" + index,
"-agentIndex", Integer.toString(index)});
// "-numPlayers", Integer.toString(numPlayers)});
}
}
public static void main(String[] args) {
Thread[] threads;
if (args.length > 0) {
threads = new Thread[args.length];
for(int i=0; i<args.length; i++) {
try {
threads[i] = new AgentThread((Class<? extends com.diarc.DiarcComponent>)java.lang.Class.forName(args[i]),i,args.length);
}
catch(ClassNotFoundException cnfe) {
System.err.println("Could not find " + args[i]);
}
}
for(Thread t:threads) {
t.start();
}
}
}
}