Package ai.nettogrof.battlesnake.snakes
Class BasicSnake
- java.lang.Object
-
- ai.nettogrof.battlesnake.snakes.AbstractSnakeAI
-
- ai.nettogrof.battlesnake.snakes.AbstractSimpleSnakeAI
-
- ai.nettogrof.battlesnake.snakes.BasicSnake
-
public class BasicSnake extends AbstractSimpleSnakeAI
Basic snake. This class is the "Nessegrev" snake on Battlesnake. a basic snake that avoid wall, and other snakes' bodies. And try to go the the nearest food, by going directly to it, doesn't check if their a snake between him and the food. This snake should work only with API v1.- Version:
- Winter 2020
- Author:
- carl.lajeunesse
-
-
Field Summary
-
Fields inherited from class ai.nettogrof.battlesnake.snakes.AbstractSnakeAI
apiversion, BOARD, BODY, DOWN, fileConfig, FOUR_SNAKE, gameId, HEAD, HEALTH, height, HEIGHT_FIELD, LEFT, log, MOVESTR, NAME, RIGHT, rules, SHOUT, SINGLE_SNAKE, SNAKES, SQUAD, TURN, TWO_SNAKE, UPWARD, width, WIDTH_FIELD, YOU
-
-
Constructor Summary
Constructors Constructor Description BasicSnake()Basic / unused constructorBasicSnake(String gameId)Constructor with the gameid,
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private StringbestMove(int snakex, int snakey, Map<String,Integer> possiblemove, int[][] board)Choose the best moveprotected StringgetFileConfig()Gets the config file to set properties correctlyMap<String,String>move(com.fasterxml.jackson.databind.JsonNode moveRequest)This method will be call on each move request receive by BattleSnake-
Methods inherited from class ai.nettogrof.battlesnake.snakes.AbstractSimpleSnakeAI
getBestPossibleMove
-
Methods inherited from class ai.nettogrof.battlesnake.snakes.AbstractSnakeAI
end, getInfo, ping, setFileConfig, start
-
-
-
-
Constructor Detail
-
BasicSnake
public BasicSnake()
Basic / unused constructor
-
BasicSnake
public BasicSnake(String gameId)
Constructor with the gameid,- Parameters:
gameId- String of the gameid field receive in the start request.
-
-
Method Detail
-
move
public Map<String,String> move(com.fasterxml.jackson.databind.JsonNode moveRequest)
This method will be call on each move request receive by BattleSnake- Specified by:
movein classAbstractSnakeAI- Parameters:
moveRequest- Json call received- Returns:
- map of field to be return to battlesnake, example "move" , "up"
-
bestMove
private String bestMove(int snakex, int snakey, Map<String,Integer> possiblemove, int[][] board)
Choose the best move- Parameters:
snakex- snake head Xsnakey- snake head Ypossiblemove- map of possible moveboard- the board[][]- Returns:
- String of the best move (up , down , left or right)
-
getFileConfig
protected String getFileConfig()
Description copied from class:AbstractSnakeAIGets the config file to set properties correctly- Specified by:
getFileConfigin classAbstractSnakeAI- Returns:
- the config filename
-
-