Package org.ggp.base.util.game

Examples of org.ggp.base.util.game.Game


  // a randomly-played match, to demonstrate that visualization works.
  public static void main(String args[]) {
        JFrame frame = new JFrame("Visualization Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Game theGame = GameRepository.getDefaultRepository().getGame("nineBoardTicTacToe");
        VisualizationPanel theVisual = new VisualizationPanel(theGame);
        frame.setPreferredSize(new Dimension(1200, 900));
        frame.getContentPane().add(theVisual);
        frame.pack();
        frame.setVisible(true);

        StateMachine theMachine = new CachedStateMachine(new ProverStateMachine());
        theMachine.initialize(theGame.getRules());
        try {
            MachineState theCurrentState = theMachine.getInitialState();
            do {
                theVisual.observe(new ServerNewGameStateEvent(theCurrentState));
                theCurrentState = theMachine.getRandomNextState(theCurrentState);
View Full Code Here


    int playClock = Integer.valueOf(arg5.getValue());

    // For now, there are only five standard arguments. If there are any
    // new standard arguments added to START, they should be added here.

    Game theReceivedGame = Game.createEphemeralGame(theRulesheet);
    return new StartRequest(gamer, matchId, roleName, theReceivedGame, startClock, playClock);
  }
View Full Code Here

    SymbolAtom arg2 = (SymbolAtom) list.get(2);

    String theRulesheet = arg1.toString();
    int previewClock = Integer.valueOf(arg2.getValue());

    Game theReceivedGame = Game.createEphemeralGame(theRulesheet);
    return new PreviewRequest(gamer, theReceivedGame, previewClock);
    }
View Full Code Here

    public static final boolean hideStepCounter = true;
    public static final boolean hideControlProposition = true;
    public static final boolean showCurrentState = false;

    public static void main(String[] args) throws InterruptedException {
        final Game theGame = GameRepository.getDefaultRepository().getGame("nineBoardTicTacToe");
        final Match theMatch = new Match("simpleGameSim." + Match.getRandomString(5), -1, 0, 0, theGame);
        try {
            // Load a sample set of cryptographic keys. These sample keys are not secure,
            // since they're checked into the public GGP Base SVN repository. They are provided
            // merely to illustrate how the crypto key API in Match works. If you want to prove
            // that you ran a match, you need to generate your own pair of cryptographic keys,
            // keep them secure and hidden, and pass them to "setCryptographicKeys" in Match.
            // The match will then be signed using those keys. Do not use the sample keys if you
            // want to actually prove anything.
            theMatch.setCryptographicKeys(new EncodedKeyPair(FileUtils.readFileAsString(new File("src/org/ggp/base/apps/utilities/SampleKeys.json"))));
        } catch (JSONException e) {
            System.err.println("Could not load sample cryptograhic keys: " + e);
        }

        // Set up fake players to pretend to play the game
        List<String> fakeHosts = new ArrayList<String>();
        List<Integer> fakePorts = new ArrayList<Integer>();
        for (int i = 0; i < Role.computeRoles(theGame.getRules()).size(); i++) {
          fakeHosts.add("SamplePlayer" + i);
          fakePorts.add(9147+i);
        }

        // Set up a game server to play through the game, with all players playing randomly.
View Full Code Here

  private AbstractAction testPlayerButtonMethod() {
    return new AbstractAction("Test") {
      @Override
      public void actionPerformed(ActionEvent evt) {
        if (playerSelectorList.getSelectedValue() != null) {
          Game testGame = GameRepository.getDefaultRepository().getGame("maze");
          String playerName = playerSelectorList.getSelectedValue().toString();
          List<PlayerPresence> thePlayers = Arrays.asList(new PlayerPresence[]{playerSelector.getPlayerPresence(playerName)});
          scheduler.addPendingMatch(new PendingMatch("Test", testGame, thePlayers, -1, 10, 5, false, false, true, false, false));
        }
      }
View Full Code Here

  public static void main(String[] args) throws IOException, SymbolFormatException, GdlFormatException, InterruptedException, GoalDefinitionException
  {
    // Extract the desired configuration from the command line.
    String tourneyName = args[0];
    String gameKey = args[1];
    Game game = GameRepository.getDefaultRepository().getGame(gameKey);
    int startClock = Integer.valueOf(args[2]);
    int playClock = Integer.valueOf(args[3]);
    if ((args.length - 4) % 3 != 0) {
      throw new RuntimeException("Invalid number of player arguments of the form host/port/name.");
    }
    List<String> hostNames = new ArrayList<String>();
    List<String> playerNames = new ArrayList<String>();
    List<Integer> portNumbers = new ArrayList<Integer>();
    String matchName = tourneyName + "." + gameKey + "." + System.currentTimeMillis();
    for (int i = 4; i < args.length; i += 3) {
      String hostname = args[i];
      Integer port = Integer.valueOf(args[i + 1]);
      String name = args[i + 2];
      hostNames.add(hostname);
      portNumbers.add(port);
      playerNames.add(name);
    }
    int expectedRoles = Role.computeRoles(game.getRules()).size();
    if (hostNames.size() != expectedRoles) {
      throw new RuntimeException("Invalid number of players for game " + gameKey + ": " + hostNames.size() + " vs " + expectedRoles);
    }
    Match match = new Match(matchName, -1, startClock, playClock, game);
    match.setPlayerNamesFromHost(playerNames);
View Full Code Here

        GameRepository theRepository = getSelectedGameRepository();
        List<String> theKeyList = new ArrayList<String>(theRepository.getGameKeys());
        Collections.sort(theKeyList);
        theGameList.removeAllItems();
        for (String theKey : theKeyList) {
            Game theGame = theRepository.getGame(theKey);
            if (theGame == null) {
                continue;
            }
            String theName = theGame.getName();
            if (theName == null) {
                theName = theKey;
            }
            if (theName.length() > 24)
                theName = theName.substring(0, 24) + "...";
View Full Code Here

      System.out.println("Please enter the path of a .kif file as an argument.");
      return;
    }

    String filename = args[0];
    Game theGame = Game.createEphemeralGame(Game.preprocessRulesheet(FileUtils.readFileAsString(new File(filename))));
    if (theGame.getRules() == null || theGame.getRules().size() == 0) {
      System.err.println("Problem reading the file " + filename + " or parsing the GDL.");
      return;
    }

    try {
      new StaticValidator().checkValidity(theGame);
    } catch (ValidatorException e) {
      System.err.println("GDL validation error: " + e.toString());
      return;
    }

    List<Gdl> transformedDescription = DeORer.run(theGame.getRules());

    String newFilename = filename.substring(0, filename.lastIndexOf(".kif")) + "_DEORED.kif";

    try {
      BufferedWriter out = new BufferedWriter(new FileWriter(new File(newFilename)));
View Full Code Here

      System.out.println("Please enter the path of a .kif file as an argument.");
      return;
    }

    String filename = args[0];
    Game theGame = Game.createEphemeralGame(Game.preprocessRulesheet(FileUtils.readFileAsString(new File(filename))));
    if (theGame.getRules() == null || theGame.getRules().size() == 0) {
      System.err.println("Problem reading the file " + filename + " or parsing the GDL.");
      return;
    }

    try {
      new StaticValidator().checkValidity(theGame);
    } catch (ValidatorException e) {
      System.err.println("GDL validation error: " + e.toString());
      return;
    }

    List<Gdl> transformedDescription = VariableConstrainer.replaceFunctionValuedVariables(theGame.getRules());

    String newFilename = filename.substring(0, filename.lastIndexOf(".kif")) + "_VARCONST.kif";

    try {
      BufferedWriter out = new BufferedWriter(new FileWriter(new File(newFilename)));
View Full Code Here

  {
    GameRepository repo = new CloudGameRepository("games.ggp.org/base");
    for (String gameKey : repo.getGameKeys()) {
      if (gameKey.contains("amazons") || gameKey.contains("knightazons") || gameKey.contains("factoringImpossibleTurtleBrain") || gameKey.contains("quad") || gameKey.contains("blokbox") || gameKey.contains("othello"))
        continue;
      Game game = repo.getGame(gameKey);
      GameValidator[] theValidators = new GameValidator[] {
          new StaticValidator(),
          new BasesInputsValidator(3000),
          new SimulationValidator(300, 10),
          new OPNFValidator(),
View Full Code Here

TOP

Related Classes of org.ggp.base.util.game.Game

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.