Skip to content

Commit

Permalink
cleaned up behavior for defender 0
Browse files Browse the repository at this point in the history
  • Loading branch information
blake6534 committed Nov 24, 2017
1 parent b1fc773 commit 1899a3f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 49 deletions.
31 changes: 20 additions & 11 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 19 additions & 38 deletions src/ufl/cs1/controllers/StudentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public int[] update(Game game,long timeDue) {

for (int i = 0; i < actions.length; i++) {

actions[i] = ghostMotion(game, ghostMode(game, i), i);
actions[i] = distanceOptimizer(game, i, ghostMode(game, i));

/* structure for how to assign unique behaviors to defenders
if(i ==0){
Expand All @@ -56,15 +56,6 @@ else if(i ==3){
}


//modularize and determine ghost motion
public static int ghostMotion(Game gameStatus, int ghostStrategy, int ghostNumber){
int defenderDirection;

defenderDirection = modeBasedDirection(gameStatus, ghostNumber, ghostStrategy);

return defenderDirection;
}

//assign the ghost to be either attacking or fleeing
public static int ghostMode(Game gameState, int ghostNumber){
//for mode
Expand Down Expand Up @@ -100,39 +91,20 @@ public static boolean getVulnerability(Game gameState, int ghostNumber){
return vulnerable;
}

//find direction pacMan last took
public static int getPlayerDirection(Game gameState){
int playerDirection;

playerDirection = gameState.getAttacker().getDirection();

return playerDirection;
}

//find the direction that will put optimize the ghosts distance to the player
public static int modeBasedDirection(Game gameState, int ghostNumber, int mode){
double upDistance;
double temporaryUp;

double downDistance;
double temporaryDown;

double leftDistance;
double temporaryLeft;

double rightDistance;
double temporaryRight;
public static int distanceOptimizer(Game gameState, int ghostNumber, int mode){
double upDistance, temporaryUp;
double downDistance, temporaryDown;
double leftDistance, temporaryLeft;
double rightDistance, temporaryRight;

int chosenDirection;

int ghostXValue;
int ghostYValue;

int playerXValue;
int playerYValue;
int ghostXValue, ghostYValue;
int playerXValue, playerYValue;

int convertedYplayer;
int convertedYGhost;
int convertedYplayer, convertedYGhost;

//for defender (x,y)
ghostXValue = gameState.getDefender(ghostNumber).getLocation().getX();
Expand Down Expand Up @@ -251,6 +223,15 @@ else if((right == Math.max(right, up)) && (right == Math.max(right, left)) && (r
return finalAction;
}

//find direction pacMan last took
public static int getPlayerDirection(Game gameState){
int playerDirection;

playerDirection = gameState.getAttacker().getDirection();

return playerDirection;
}




Expand Down Expand Up @@ -313,7 +294,7 @@ public static boolean powerPillProximity(Game gameState, int ghostNumber, Maze m
the ghost exhibit a more cautious approach or start escaping. If the player is farther have the ghost attack more aggresively.
*/

/*defender method 2 idea: tMotion(game, i): instead of the tradtional distance formula, utilize only horizontal or vertical distances
/*defender method 3 idea: tMotion(game, i): instead of the tradtional distance formula, utilize only horizontal or vertical distances
from the player to the ghost. This would mean to first determine whether the ghost is vulnerable. If the ghost is vulnerable determine
which direction (vertical or horizontal) would maximize the ghosts distance from the player, have the ghost then adopt this motion. If
the ghost is not vulnerable, determine which direction (vertical or horizontal) would minmize the ghosts distance to the player. Have
Expand Down

0 comments on commit 1899a3f

Please sign in to comment.