Package org.ggp.base.util.statemachine

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


     * @param newStateMachine the new state machine
     */
    protected final void switchStateMachine(StateMachine newStateMachine) {
        try {
            MachineState newCurrentState = newStateMachine.getInitialState();
            Role newRole = newStateMachine.getRoleFromConstant(getRoleName());

            // Attempt to run through the game history in the new machine
            List<List<GdlTerm>> theMoveHistory = getMatch().getMoveHistory();
            for(List<GdlTerm> nextMove : theMoveHistory) {
                List<Move> theJointMove = new ArrayList<Move>();
View Full Code Here


        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));
        assertEquals(100, sm.getGoal(state, player));
    }
View Full Code Here

    // Should be called after each move, to collect all of the errors
    // caused by players and write them into the match description.
    private void appendErrorsToMatchDescription() {
        List<String> theErrors = new ArrayList<String>();
        for (int i = 0; i < stateMachine.getRoles().size(); i++) {
            Role r = stateMachine.getRoles().get(i);
            if (mostRecentErrors.containsKey(r)) {
                theErrors.add(mostRecentErrors.get(r));
            } else {
                theErrors.add("");
            }
View Full Code Here

        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);
        List<Role> roles = Arrays.asList(xRole, oRole);
        assertEquals(roles, sm.getRoles());

        assertEquals(9, sm.getLegalJointMoves(state).size());
        assertEquals(9, sm.getLegalMoves(state, xRole).size());
View Full Code Here

    @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")));
        assertTrue(sm.isTerminal(state));
View Full Code Here

    @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")));
        assertTrue(sm.isTerminal(state));
View Full Code Here

    @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")));
        assertTrue(sm.isTerminal(state));
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")));
        assertTrue(sm.isTerminal(state));
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")));
        assertTrue(sm.isTerminal(state));
View Full Code Here

      GdlRelation relation = (GdlRelation) proposition.getName();
      if (!relation.getName().getValue().equals("goal"))
          continue;

      Role theRole = new Role((GdlConstant) relation.get(0));
      if (!goalPropositions.containsKey(theRole)) {
        goalPropositions.put(theRole, new HashSet<Proposition>());
      }
      goalPropositions.get(theRole).add(proposition);
    }
View Full Code Here

TOP

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

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.