Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence CSSE 413 students, here is the API for the game. Please keep in mind that this is subject to slight change. Classes contained in this API: Player (you extend this class) Bot Move Point Constants 2 7 9 11 13 Please post any questions on the forum or e-mail us. 10/23/2006 2:21:00 PM Page 1 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence Overview Package Class Tree Deprecated Index Help PREV CLASS NEXT CLASS SUMMARY: NESTED | FIELD | CONSTR | METHOD FRAMES NO FRAMES All Classes DETAIL: FIELD | CONSTR | METHOD Class Player public abstract class Player extends java.lang.Object Field Summary ArrayList<Bot> bots The bots a player has available. ArrayList<Bot> enemyBots The opposing bots a player can see. Point enemyFlag A mapping of the bots contained in array list bots and which bots they can see out of enemyBots. int hasTheirFlag The bot in the arraylist bots that has your opponent’s flag. int hasYourFlag The bot in the array list enemyBots that has your flag. int[][] Map Terrain, represented as a set of constants. Note that this goes by [Height][Width]. int playerNum A number indicating which player you are, corresponding to constants in Constants. int turnsLeft The total number of turns (yours and theirs combined) until the game ends. ArrayList<Point> visibility A mapping of the bots contained in array list bots and which bots they can see out of enemyBots, represented as a Point with x corresponding to your bot. Point yourFlag The location of your flag. 10/23/2006 2:21:00 PM Page 2 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence Constructor Summary Player() Method Summary void endGame() Finishes the game. abstract getMove() Move This will be called by the game to obtain the player’s move. Point[] getTurn0() This allows an AI player to select 5 points to set-up their side; the first point is the flag and the four remaining points are the bots. Placing bots in the babysitting zone will cause them to automatically be moved out of the zone. void startGame(java.lang.Integer player, java.util.ArrayList<Bot> bots, int[][] Map) Initializes the above constants and begins the game. void update(java.util.ArrayList<Bot> bots, java.util.ArrayList<Bot> enemyBots, java.util.ArrayList<Point> vis, Point yourFlag, Point enemyFlag, int hasTheirFlag, int hasYourFlag, int turnsLeft) Updates the above list of constants based on what has happened in the game since the last turn. Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Field Detail bots A set of the bots a player currently has. protected java.util.ArrayList<Bot> bots 10/23/2006 2:21:00 PM Page 3 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence enemyBots A listing of bots a player can currently see. protected java.util.ArrayList<Bot> enemyBots visibility An arraylist indicating which of a players’ bots can see which corresponding enemy bots. protected java.util.ArrayList<Point> visibility playerNum An integer representing which side the player is on. protected int playerNum yourFlag A point indicating where your flag is. protected Point yourFlag enemyFlag A point indicating where the enemy flag is. protected Point enemyFlag hasTheirFlag A point indicating which of a player’s bots (if any) currently has the enemy flag. protected int hasTheirFlag hasYourFlag A point indicating which of the enemy’s bots which a player can see has the player’s flag. protected int hasYourFlag turnsLeft 10/23/2006 2:21:00 PM Page 4 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence An integer indicating how many turns (both a player’s and their enemy’s) are left until the game ends. protected int turnsLeft Map A two-dimentional integer map of the terrain. Plains: 0 Forest: 1 Mountain: 2 Water (impassable): 3 protected int[][] Map Values are: Constructor Detail N/A Method Detail getMove This method returns a Move object containing two points, where the first point contains one of your bots and the second point contains either the bot’s destination, its aiming target, or its killing target. public abstract Move getMove() startGame Initializes several fields. public void startGame(java.lang.Integer player, java.util.ArrayList<Bot> bots, int[][] Map) endGame Ends the game. public void endGame() getTurn0 Returns a set of points indicating starting locations of a player’s flag and bots. The first entry of the array must be the flag, and the second through fifth are the bots. The flag must be Constants.CAMPING away from the North and South ends of the map. Otherwise, these points must be inside the 10/23/2006 2:21:00 PM Page 5 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence three columns on the player’s side of the map and the bots must not be within the babysitting radius of the flag. public Point[] getTurn0() update Updates the fields listed below. This is called before getMove() is called. public void update(java.util.ArrayList<Bot> bots, java.util.ArrayList<Bot> enemyBots, java.util.ArrayList<Point> vis, Point yourFlag, Point enemyFlag, int hasTheirFlag, int hasYourFlag, int turnsLeft) Overview Package Class Tree Deprecated Index Help PREV CLASS NEXT CLASS SUMMARY: NESTED | FIELD | CONSTR | METHOD 10/23/2006 2:21:00 PM FRAMES NO FRAMES All Classes DETAIL: FIELD | CONSTR | METHOD Page 6 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence Class Bot Public class Bot extends a hidden class The Bot class contains information pertinent to an individual bot. Field Summary Bot target The Bot currently being targeted. boolean dead Indicates whether the Bot is active int respawnTime The number of your turns until the Bot respawns. It will respawn at the first available space at the top of the column your flag is in. int reloadTime The number of your turns until the Bot can fire again. static MOVEMENT int The number of squares, unadjusted, that this Bot can move this turn. static VISION int The distance this Bot can see. Constructor Summary Bot(stuff) Constructs a new Bot object. Method Summary boolean hasTarget() Returns whether the Bot has a target. boolean hasFlag() Returns whether the Bot is carrying a flag. Methods inherited from class java.lang.Object clone, finalize, getClass, notify, notifyAll, wait, wait, wait Field Detail target 10/23/2006 2:21:00 PM Page 7 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 public Bot target Contains the Bot Artificial Intelligence that is being targeted by this Bot. dead public boolean dead Whether the Bot is active or not (if it is true, the bot is inactive). respawnTime public int respawnTime The number of turns until the can Bot respawns. It will respawn at the first available space at the top of the column your flag is in. reloadTime public int reloadTime The number of turns until the Bot can fire again. MOVEMENT public static int MOVEMENT The number of squares the Bot can move each turn. VISION public static int VISION The number of squares the Bot can see. Constructor Detail Bot public Bot(stuff) Constructs a new Bot object. Method Detail hasTarget() public boolean hasTarget() If the Bot has a target, this returns true. Integer.toString(n, 16).toUpperCase() hasFlag() public boolean hasFlag() If the Bot is carrying a flag, 10/23/2006 2:21:00 PM this returns true. Page 8 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence Class Move Public class Move Implements Cloneable The Move class returns two points, the original position of one of your bots and either the destination of that bot or the location of a bot that is being aimed at or killed. Field Summary Point from The Bot currently being moved. Point to The Point the Bot is moving to, targeting, or shooting at. Constructor Summary Move(Point from, Point to) Constructs a new Move object. Move(int from_x, int from_y, int to_x, int to_y) Constructs a new Move object. Method Summary Object clone() Returns a clone of the move. boolean equals() Returns whether the two moves are equal. String toString() Returns a String in the form of (point from) “->” (point to) Methods inherited from class java.lang.Object clone, finalize, getClass, notify, notifyAll, wait, wait, wait Field Detail from public Point from Contains Point the Bot is moving from. to public Point to 10/23/2006 2:21:00 PM Page 9 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence Contains Point the Bot is moving from. Constructor Detail Point public Point(Point from, Point to) Constructs a new Move object. Point public Point(int from_x, int from_y, int to_x, int to_y) Constructs a new Move object. Method Detail clone() public Object clone() Returns a clone of the current Point. equals() public boolean equals() If the two Points are equal, this returns true. toString() public String toString() Returns a String indicating the from and to points. 10/23/2006 2:21:00 PM Page 10 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence Class Point Public class Point Implements Cloneable The Move class returns two points, the original position of one of your bots and either the destination of that bot or the location of a bot that is being aimed at or killed. For this project, x is the column, which begins counting at 0; likewise, y is the respective row, which also begins counting at 0. Field Summary int x The x value of the point int y The y value of the point Constructor Summary Move(int x, int y) Constructs a new Point object. Method Summary Object clone() Returns a clone of the Point. Boolean equals(Point p) Returns whether the two moves are equal. String toString() Returns a String in the form of x, y int absDistance(Point p) Returns the total distance in squares from this Point to Point p. Methods inherited from class java.lang.Object clone, finalize, getClass, notify, notifyAll, wait, wait, wait Field Detail x public int x Contains the value of x. 10/23/2006 2:21:00 PM Page 11 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence y public int y Contains the value of y. Constructor Detail Point public Point(int x, int y) Constructs a new Point object. Method Detail clone() public Object clone() Returns a clone of the current Point. equals() public boolean equals(Point p) If the two Points are equal, this returns true. toString() public String toString() Returns a String indicating the from and to points. absDistance() public int absDistance(Point p) Returns the distance, in squares, between this Point and the other Point. 10/23/2006 2:21:00 PM Page 12 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence Class Constants Public class Constants Implements Cloneable The Move class returns two points, the original position of one of your bots and either the destination of that bot or the location of a bot that is being aimed at or killed. For this project, x is the column, which begins counting at 0; likewise, y is the respective row, which also begins counting at 0. Field Summary static NUM_BOTS int The number of bots each player gets static PLAYER1 int The value used to indicate Red player, 0. static PLAYER2 int The value used to indicate Blue player, 1. static EMPTY_PLAYER int The value used to indicate not Red or Blue player, 2. static HEIGHT int The number of squares tall the board is, 16. static WIDTH int The number of squares wide the board is, 24. static RELOAD int The number of that player’s turns that must elapse until the Bot is able to fire again. static RESPAWN int The number of that player’s turns that must elapse until the Bot respawns in the topmost available space. static CAMPING int The minimum number of squares away from your flag that your bots must stay while the flag is not in the possession of your opponent. static turnLimit int The number of total turns (both players, combined) static Plains int The integer representing a ‘Plains’ square on the terrain map, 0. static Forest int The integer representing a ‘Forest’ square on the terrain map, 1. static Mountain 10/23/2006 2:21:00 PM Page 13 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence The integer representing a ‘Mountain’ square on the terrain map, 2. int static Lake int The integer representing a ‘Lake’ square on the terrain map, 3. static COSTS int[] How much it costs to move across a square of a given terrain (Lakes are impassable, so it is of length 3). static VIS_COST int[] How much it costs to see across a square of a given terrain (length is 4). static VIS_MOD int[] How much being in a certain terrain modifies a bot’s visibility (Lakes are impassable, so effectively length 3). static TIME_LIMIT int How much time players have to take their turn. Constructor Summary N/A Method Summary N/A Methods inherited from class java.lang.Object clone, finalize, getClass, notify, notifyAll, wait, wait, wait Field Detail NUM_BOTS public static final int NUM_BOTS The total number of Bots each player has. PLAYER1 public static final int PLAYER1 The value used to indicate Red player, 0. PLAYER2 public static final int PLAYER2 The value used to indicate Blue player, 1. EMPTY_PLAYER public static final int EMPTY_PLAYER 10/23/2006 2:21:00 PM Page 14 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence The value used to indicate neither Red nor Blue, 2. HEIGHT public static final int HEIGHT Contains the value of how tall the playing field is, 16. WIDTH public static final int y Contains the value of how wide the playing field is, 24. RELOAD public static final int y How many of your turns after firing before that bot is able to fire again. RESPAWN public static final int public int y The number of your turns that it takes to respawn a bot. CAMPING public static final int CAMPING The minimum distance, in squares, that each of your bots must stay away from your flag while it is not being carried by an opponent’s bot. turnLimit public static final int turnLimit The total number of turns, for both players combined, that the game runs before ending. Plains public static final int Plains The integer value that denotes a Plains in the terrain map, 0. Forest public static final int Forest The integer value that denotes a Forest in the terrain map, 1. Mountain public static final int Mountain The integer value that denotes a Mountain in the terrain map, 2. Lake public static final int Lake The integer value that denotes a Lake in the terrain map, 3. COSTS public static final int[] COSTS 10/23/2006 2:21:00 PM Page 15 of 16 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Computer Science and Software Engineering CSSE 413 Artificial Intelligence Contains the cost associated with moving through a square based on the terrain it contains, (1,2,2,impassible – represented as Integer.MAX_VALUE). VIS_COST public static final int[] VIS_COST Contains the cost associated with seeing the contents of a square based on the terrain it contains, (1,2,2,1) VIS_MOD public static final int[] VIS_MOD Contains the modifier for how far away a Bot may be seen, (0,0,3,Integer.MIN_VALUE). Constructor Detail N/A Method Detail N/A 10/23/2006 2:21:00 PM Page 16 of 16