Package org.ggp.base.util.statemachine

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


    @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

    @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

      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

        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

  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

      {
        contents.add(p.getName());
      }

    }
    return new MachineState(contents);
  }
View Full Code Here

    Set<GdlSentence> trues = new HashSet<GdlSentence>();
    for (GdlSentence result : results)
    {
      trues.add(GdlPool.getRelation(TRUE, new GdlTerm[] { result.get(0) }));
    }
    return new MachineState(trues);
  }
View Full Code Here

TOP

Related Classes of org.ggp.base.util.statemachine.MachineState

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.