Skip to content

Commit

Permalink
reset Exec.java to initial state
Browse files Browse the repository at this point in the history
Changed StateMachine to allow null actions
  • Loading branch information
tylorr committed Jan 30, 2012
1 parent 9939532 commit c653dff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
22 changes: 18 additions & 4 deletions ai/fsm/StateMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class StateMachine {

public StateMachineState currentState;

@SuppressWarnings("unused")
public Action update() {
Action actions = null;

Expand Down Expand Up @@ -54,14 +55,27 @@ public Action update() {

// Add each element to the list in turn
actions = currentState.getExitActions();
last = actions.getLast();
if (actions != null) {
last = actions.getLast();
}

tempList = transition.getActions();
last.next = tempList;
last = tempList.getLast();

if (actions == null) {
actions = tempList;
last = actions.getLast();
} else if (tempList != null) {
last.next = tempList;
last = tempList.getLast();
}

tempList = nextState.getEntryActions();
last.next = tempList;
if (actions == null) {
actions = tempList;
last = actions.getLast();
} else if (tempList != null) {
last.next = tempList;
}

// Update the change of state
currentState = nextState;
Expand Down
8 changes: 3 additions & 5 deletions game/Exec.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ public static void main(String[] args)
//this can be used for numerical testing (non-visual, no delays)
// exec.runExperiment(new RandomPacMan(),new AttractRepelGhosts(true),100);

//run game without time limits (un-comment if required) Ms PacMan has a seizure, and the ghosts are less scattered
//run game without time limits (un-comment if required)
// exec.runGame(new RandomPacMan(),new RandomGhosts(),true,G.DELAY);

//run game with time limits (un-comment if required) ghosts chase you in this one
//run game with time limits (un-comment if required)
// exec.runGameTimed(new Human(),new AttractRepelGhosts(true),true);
//run game with time limits. Here NearestPillPacManVS is chosen to illustrate how to use graphics for debugging/information purposes
//Pac-man goes on her own with blue path illuminated and paths to ghosts are shown
// exec.runGameTimed(new NearestPillPacManVS(),new AttractRepelGhosts(false),true);
exec.runGameTimed(new NearestPillPacManVS(),new AttractRepelGhosts(false),true);

//this allows you to record a game and replay it later. This could be very useful when
//running many games in non-visual mode - one can then pick out those that appear irregular
//and replay them in visual mode to see what is happening.
//you can play as pacman in this version but ghosts scatter at this point
// exec.runGameTimedAndRecorded(new Human(),new AttractRepelGhosts(false),true,"human-v-Legacy2.txt");
// exec.replayGame("human-v-Legacy2.txt");
}
Expand Down

0 comments on commit c653dff

Please sign in to comment.