Skip to content

Commit

Permalink
Merge pull request #123 from ggp-org/random
Browse files Browse the repository at this point in the history
Add basic support for random roles.
  • Loading branch information
samschreiber committed Sep 6, 2016
2 parents c706bb0 + 9d4d7bd commit e2cb168
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/java/org/ggp/base/server/GameServer.java
Expand Up @@ -25,6 +25,7 @@
import org.ggp.base.server.threads.RandomPlayRequestThread;
import org.ggp.base.server.threads.StartRequestThread;
import org.ggp.base.server.threads.StopRequestThread;
import org.ggp.base.util.gdl.grammar.GdlPool;
import org.ggp.base.util.match.Match;
import org.ggp.base.util.match.MatchPublisher;
import org.ggp.base.util.observer.Event;
Expand Down Expand Up @@ -67,6 +68,12 @@ public GameServer(Match match, List<String> hosts, List<Integer> ports) {

playerGetsUnlimitedTime = new boolean[hosts.size()];
playerPlaysRandomly = new boolean[hosts.size()];
List<Role> roles = Role.computeRoles(match.getGame().getRules());
for (int r = 0; r < roles.size(); r++) {
if (roles.get(r).getName() == GdlPool.RANDOM) {
playerPlaysRandomly[r] = true;
}
}

stateMachine = new ProverStateMachine();
stateMachine.initialize(match.getGame().getRules());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/ggp/base/util/gdl/grammar/GdlPool.java
Expand Up @@ -52,14 +52,15 @@ public final class GdlPool
// game-specific constants are case-sensitive or not. These special keywords are never
// sent over the network in PLAY requests and responses, so this should be safe.
public static final ImmutableSet<String> KEYWORDS = ImmutableSet.of(
"init","true","next","role","does","goal","legal","terminal","base","input","_");
"init","true","next","role","does","goal","legal","terminal","base","input","random","_");
public static final GdlConstant BASE = getConstant("base");
public static final GdlConstant DOES = getConstant("does");
public static final GdlConstant GOAL = getConstant("goal");
public static final GdlConstant INIT = getConstant("init");
public static final GdlConstant INPUT = getConstant("input");
public static final GdlConstant LEGAL = getConstant("legal");
public static final GdlConstant NEXT = getConstant("next");
public static final GdlConstant RANDOM = getConstant("random");
public static final GdlConstant ROLE = getConstant("role");
public static final GdlConstant TERMINAL = getConstant("terminal");
public static final GdlConstant TRUE = getConstant("true");
Expand Down

0 comments on commit e2cb168

Please sign in to comment.