Examples of MachineState


Examples of org.ggp.base.util.statemachine.MachineState

        StaticValidator.validateDescription(description);

        StateMachine sm = new ProverStateMachine();
        sm.initialize(description);
        MachineState state = sm.getInitialState();
        assertEquals(1, sm.getRoles().size());
        Role player = sm.getRoles().get(0);
        assertEquals(1, sm.getLegalMoves(state, player).size());
        state = sm.getNextStates(state).get(0);
        assertTrue(sm.isTerminal(state));
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

    @Test
    public void testProverOnTicTacToe() throws Exception {
        List<Gdl> ticTacToeDesc = new TestGameRepository().getGame("ticTacToe").getRules();
        sm.initialize(ticTacToeDesc);
        MachineState state = sm.getInitialState();
        assertFalse(sm.isTerminal(state));
        GdlConstant X_PLAYER = GdlPool.getConstant("xplayer");
        GdlConstant O_PLAYER = GdlPool.getConstant("oplayer");
        Role xRole = new Role(X_PLAYER);
        Role oRole = new Role(O_PLAYER);
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

    @Test
    public void testCase1A() throws Exception {
        List<Gdl> desc = new TestGameRepository().getGame("test_case_1a").getRules();
        sm.initialize(desc);
        MachineState state = sm.getInitialState();
        Role you = new Role(GdlPool.getConstant("you"));
        assertFalse(sm.isTerminal(state));
        assertEquals(100, sm.getGoal(state, you));
        assertEquals(Collections.singletonList(100), sm.getGoals(state));
        state = sm.getNextState(state, Collections.singletonList(move("proceed")));
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

    @Test
    public void testCase3C() throws Exception {
        List<Gdl> desc = new TestGameRepository().getGame("test_case_3c").getRules();
        sm.initialize(desc);
        MachineState state = sm.getInitialState();
        Role xplayer = new Role(GdlPool.getConstant("xplayer"));
        assertFalse(sm.isTerminal(state));
        assertEquals(1, sm.getLegalMoves(state, xplayer).size());
        assertEquals(move("win"), sm.getLegalMoves(state, xplayer).get(0));
        state = sm.getNextState(state, Collections.singletonList(move("win")));
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

    @Test
    public void testCase5A() throws Exception {
        List<Gdl> desc = new TestGameRepository().getGame("test_case_5a").getRules();
        sm.initialize(desc);
        MachineState state = sm.getInitialState();
        Role you = new Role(GdlPool.getConstant("you"));
        assertFalse(sm.isTerminal(state));
        assertEquals(1, sm.getLegalMoves(state, you).size());
        assertEquals(move("proceed"), sm.getLegalMoves(state, you).get(0));
        state = sm.getNextState(state, Collections.singletonList(move("proceed")));
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

    @Test
    public void testCase5B() throws Exception {
        List<Gdl> desc = new TestGameRepository().getGame("test_case_5b").getRules();
        sm.initialize(desc);
        MachineState state = sm.getInitialState();
        Role you = new Role(GdlPool.getConstant("you"));
        assertFalse(sm.isTerminal(state));
        assertEquals(1, sm.getLegalMoves(state, you).size());
        assertEquals(move("draw 1 1 1 2"), sm.getLegalMoves(state, you).get(0));
        state = sm.getNextState(state, Collections.singletonList(move("draw 1 1 1 2")));
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

    @Test
    public void testCase5C() throws Exception {
        List<Gdl> desc = new TestGameRepository().getGame("test_case_5c").getRules();
        sm.initialize(desc);
        MachineState state = sm.getInitialState();
        Role you = new Role(GdlPool.getConstant("you"));
        assertFalse(sm.isTerminal(state));
        assertEquals(1, sm.getLegalMoves(state, you).size());
        assertEquals(move("proceed"), sm.getLegalMoves(state, you).get(0));
        state = sm.getNextState(state, Collections.singletonList(move("proceed")));
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

      if (truesFromBases.isEmpty() && legalsFromInputs.isEmpty()) {
        return ImmutableList.of();
      }

      MachineState initialState = sm.getInitialState();
      MachineState state = initialState;
      long startTime = System.currentTimeMillis();
      while (System.currentTimeMillis() < startTime + millisecondsToTest) {
        //Check state against bases, inputs
        if (!truesFromBases.isEmpty()) {
          if (!truesFromBases.containsAll(state.getContents())) {
            Set<GdlSentence> missingBases = new HashSet<GdlSentence>();
            missingBases.addAll(state.getContents());
            missingBases.removeAll(truesFromBases);
            throw new ValidatorException("Found missing bases: " + missingBases);
          }
        }
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

        final int[] nState = new int[1];
        theServer.addObserver(new Observer() {
      @Override
      public void observe(Event event) {
        if (event instanceof ServerNewGameStateEvent) {
          MachineState theCurrentState = ((ServerNewGameStateEvent)event).getState();
                  if(nState[0] > 0) System.out.print("State[" + nState[0] + "]: ");
                  Set<GdlSentence> newContents = theCurrentState.getContents();
                  for(GdlSentence newSentence : newContents) {
                      if(hideStepCounter && newSentence.toString().contains("step")) continue;
                      if(hideControlProposition && newSentence.toString().contains("control")) continue;
                      if(!oldContents.contains(newSentence)) {
                          System.out.print("+" + newSentence + ", ");
View Full Code Here

Examples of org.ggp.base.util.statemachine.MachineState

  public List<ValidatorWarning> checkValidity(Game theGame) throws ValidatorException {
    for (int i = 0; i < numSimulations; i++) {
      StateMachine stateMachine = new ProverStateMachine();
      stateMachine.initialize(theGame.getRules());

      MachineState state = stateMachine.getInitialState();
      for (int depth = 0; !stateMachine.isTerminal(state); depth++) {
        if (depth == maxDepth) {
          throw new ValidatorException("Hit max depth while simulating: " + maxDepth);
        }
        try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.