|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--nl.bluering.ppracing.Player
This class implements both the data concerning each player, as well as functions for calculating the route for the computer players.
| Field Summary | |
static int |
COM
The type of the player: Computer, Human or Network-player |
static int |
DOWN
The directions to which a player can go |
static int |
HUM
The type of the player: Computer, Human or Network-player |
static int |
LEFT
The directions to which a player can go |
static int |
NET
The type of the player: Computer, Human or Network-player |
static int |
RIGHT
The directions to which a player can go |
static int |
SAME
The directions to which a player can go |
static int |
UP
The directions to which a player can go |
| Constructor Summary | |
Player(java.lang.String nm,
int t,
Ppracing p,
int startx,
int starty,
java.awt.Color col)
Constructs a new player |
|
| Method Summary | |
double |
ai(int x,
int y,
int vx,
int vy,
int l)
This method does a depth-first search for the longest arc-distance that can be made within the given number of moves (level). |
void |
ask()
Is used to make the computer do a move |
void |
checkterrain()
Checks if the car has hit the grass. |
void |
clicked(int x,
int y)
For user input from mouse |
Car |
getcar()
|
java.lang.String |
getname()
|
boolean |
isai()
|
boolean |
isnet()
|
static void |
main(java.lang.String[] ps)
Method for testing purposes.... |
void |
move(int m)
For actually moving the car |
void |
moveai()
This function is called by ask() to move the computer player |
void |
movecar(int x,
int y)
Internal function for moving the car to the new position. |
void |
settype(int i)
|
java.lang.String |
toString()
|
int |
type()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int LEFT
public static final int RIGHT
public static final int UP
public static final int DOWN
public static final int SAME
public static final int COM
public static final int HUM
public static final int NET
| Constructor Detail |
public Player(java.lang.String nm,
int t,
Ppracing p,
int startx,
int starty,
java.awt.Color col)
nm - The name of the playeraip - Is the player a computer player?p - Parental appletstartx - Horizontal start locationstarty - Vertical start locationcol - Color of the player| Method Detail |
public void ask()
public boolean isai()
public boolean isnet()
public int type()
public void settype(int i)
public void clicked(int x,
int y)
x - Horizontal (circuit) locationx - Vertical (circuit) locationpublic void move(int m)
m - One of: LEFT, RIGHT, UP, DOWN, SAME
public void movecar(int x,
int y)
public void checkterrain()
public java.lang.String getname()
public Car getcar()
public java.lang.String toString()
toString in class java.lang.Objectpublic void moveai()
public double ai(int x,
int y,
int vx,
int vy,
int l)
x - Horizontal start locationy - Vertical start locationvx - Current horizontal speedvy - Current vertical speedl - Level of search (or number of moves to maximize)public static void main(java.lang.String[] ps)
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||