first commit

This commit is contained in:
Jose Caban
2025-06-07 01:59:34 -04:00
commit 388ac241f0
3558 changed files with 9116289 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
/**
* <PRE>
* CGhostAI.java
*
* Revisions: 1.0 Nov. 23, 2002
* Created the CGhostAI class
*
* </PRE>
*
* @author <A HREF="mailto:gtg184g@mail.gatech.edu">Jose Manuel Caban</A>
* @version Version 1.0, Nov. 23, 2002
*/
import java.util.*;
public class CGhostAI extends CIntelligence implements Constants{
/**
*This GhostAI uses a more classicPacman-like AI system
*Considering the fact that pacman isn't Half-Life, we don't need
*to do any searches to find Pacman, Pacman will eventually run into
*the ghosts.
*
*Basically, if the Ghost "sees" Pacman, that is, Pacman is within the
*Ghost's Line of Sight, the ghost will increase his speed to equal Pacman's
*(in this case I'm setting the speeds to be 3,2,1: 3 = Pacman speed,
*2 = Ghost regular speed, 1 = Ghost zombied speed)
*and the Ghost will head in Pacman's direction at full speed until pacman
*hits a new node (a Pacman hit Node event occurs) where the new direction
*Pacman chooses will be sent back to the Ghost and the Ghost will return to
*moving at normal speed (which is slightly slower than pacman but much faster
*than the speed at which they move when zombied out.
*
*@param CNode, the Ghost's current node
*@param CGhost, the Ghost to be analyzed
*@param CCoord, pacmans coordinate
*/
public int doMove(CNode cLastNode, CGhost cGhost, CCoord cPacPos){
int wayToGo;
if(cGhost.getX() == cPacPos.getX()){
if(cGhost.getY() < cPacPos.getY()){
wayToGo = cLastNode.canMV_DN()?MV_DN:MV_SAMEDIR;
}
else{
wayToGo = cLastNode.canMV_UP()?MV_UP:MV_SAMEDIR;
}
}
else if(cGhost.getY() == cPacPos.getY()){
if(cGhost.getX() < cPacPos.getX()){
wayToGo = cLastNode.canMV_RIGHT()?MV_RIGHT:MV_SAMEDIR;
}
else{
wayToGo = cLastNode.canMV_LEFT()?MV_LEFT:MV_SAMEDIR;
}
}
else {
//if the ghost can't see pacman then
Random rando = new Random();
wayToGo = rando.nextInt(MV_SAMEDIR);
}
return wayToGo;
}//end doMove()
}// end of class CGhostAI