Class ConstrictorSearch
- java.lang.Object
-
- ai.nettogrof.battlesnake.treesearch.AbstractSearch
-
- ai.nettogrof.battlesnake.treesearch.AbstractBestFirstSearch
-
- ai.nettogrof.battlesnake.treesearch.AbstractMCTS
-
- ai.nettogrof.battlesnake.treesearch.search.constrictor.ConstrictorSearch
-
- All Implemented Interfaces:
Runnable
public class ConstrictorSearch extends AbstractMCTS
This Constrictor search add the possibility to play Constrictor mode It start by search the smallest branch and expand it (256 times) then : 1. find the best branch from the previous best branch that the score doesn't change (root the first time) 2. expand the MCTS leaf node (ratio between best / less explored ) 3. update score of the branch keep branch info if score doesn't changed Repeat those 2 steps until no time left or the root is not more expandable.- Version:
- Summer 2021
- Author:
- carl.lajeunesse
-
-
Constructor Summary
Constructors Constructor Description ConstrictorSearch()Basic constructorConstrictorSearch(AbstractNode root, int width, int height)Constructor used to expand the tree once.ConstrictorSearch(AbstractNode root, int width, int height, long starttime, int timeout, GameRuleset rules)Constructor used to expand to do the tree search.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SnakeInfocreateSnakeInfo(SnakeInfo snake, int newHead, AbstractNode node)Create new SnakeInfo based on the current node and the new head squareprotected booleanfreeSpace(int square, List<SnakeInfo> snakes, SnakeInfo yourSnake)Check if the snake can move on the squareprotected voidkill(SnakeInfo death, List<SnakeInfo> all)This abstract method will be use to "kill" a snakevoidrun()-
Methods inherited from class ai.nettogrof.battlesnake.treesearch.AbstractMCTS
executeMCTS, getMCTSBestPath
-
Methods inherited from class ai.nettogrof.battlesnake.treesearch.AbstractBestFirstSearch
getBestChild, getbestChildValue, getBestPath, mergeList, updateFullListNode, updateListNode
-
Methods inherited from class ai.nettogrof.battlesnake.treesearch.AbstractSearch
addMove, checkHeadToHead, generateChild, generateChild, generateSnakeInfoDestination, getSmallestChild, merge, moveSnake, stopSearching
-
-
-
-
Constructor Detail
-
ConstrictorSearch
public ConstrictorSearch()
Basic constructor
-
ConstrictorSearch
public ConstrictorSearch(AbstractNode root, int width, int height)
Constructor used to expand the tree once.- Parameters:
root- Root nodewidth- Board widthheight- Board height
-
ConstrictorSearch
public ConstrictorSearch(AbstractNode root, int width, int height, long starttime, int timeout, GameRuleset rules)
Constructor used to expand to do the tree search.- Parameters:
root- Root nodewidth- Board widthheight- Board heightstarttime- starting time for the search in millisecondtimeout- the time limit to run the searchrules- Game ruleset
-
-
Method Detail
-
run
public void run()
-
kill
protected void kill(SnakeInfo death, List<SnakeInfo> all)
Description copied from class:AbstractSearchThis abstract method will be use to "kill" a snake- Specified by:
killin classAbstractSearch- Parameters:
death- SnakeInfo of the snake to killall- List of all snakeinfo
-
createSnakeInfo
protected SnakeInfo createSnakeInfo(SnakeInfo snake, int newHead, AbstractNode node)
Description copied from class:AbstractSearchCreate new SnakeInfo based on the current node and the new head square- Specified by:
createSnakeInfoin classAbstractSearch- Parameters:
snake- previous snakeInfonewHead- New head squarenode- Previous node- Returns:
- new SnakeInfo
-
freeSpace
protected boolean freeSpace(int square, List<SnakeInfo> snakes, SnakeInfo yourSnake)Description copied from class:AbstractSearchCheck if the snake can move on the square- Specified by:
freeSpacein classAbstractSearch- Parameters:
square- the int sqauresnakes- List of all snakesyourSnake- current Snake- Returns:
- boolean free to move on that square
-
-