Class SquadNode
- java.lang.Object
-
- ai.nettogrof.battlesnake.treesearch.node.AbstractNode
-
- ai.nettogrof.battlesnake.treesearch.node.AbstractDecisionNode
-
- ai.nettogrof.battlesnake.treesearch.node.AbstractEvaluationNode
-
- ai.nettogrof.battlesnake.treesearch.search.squad.SquadNode
-
public class SquadNode extends AbstractEvaluationNode
This Squad node class must be in squad mode- Version:
- Summer 2021
- Author:
- carl.lajeunesse
-
-
Field Summary
Fields Modifier and Type Field Description protected static intMINIMUN_SNAKEMinimun number of snake for Squad Mode.-
Fields inherited from class ai.nettogrof.battlesnake.treesearch.node.AbstractNode
allChildsCount, boardInfo, child, exp, food, hazard, ONE, possibleMove, score, scoreRatio, snakes
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckBoardHash(int newPosX, int newPosY, int[][] board, int value)Check the board array if the hash value can expandAbstractNodecreateNode(List<SnakeInfo> snakes, AbstractNode currentNode)Create a node from the same typeprotected voidgenerateHash(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap old, it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap newHash, int[][] board)Generate new position to be added to hashprivate intgetPartnerIndex(SnakeInfo snake)Gets the index , for the teammatefloatgetScoreRatio()Gets the score ratio, the score ratio is compute has follow Our snake score / (all others snakes score added)protected int[][]initBoard()Initiate the board arrayprivate voidsetSquadScore()Sets the node scorevoidupdateScoreRatio()Update the score ratio-
Methods inherited from class ai.nettogrof.battlesnake.treesearch.node.AbstractEvaluationNode
addBasicLengthScore, addScoreDistance, addScoreDistanceAll, addSizeCompareScore, addToHash, adjustScodeBasedonBoardControl, applyNewHash, listAreaControl, setWinnerMaxScore
-
Methods inherited from class ai.nettogrof.battlesnake.treesearch.node.AbstractDecisionNode
countSnakeAlive, updateScore
-
Methods inherited from class ai.nettogrof.battlesnake.treesearch.node.AbstractNode
addChild, getBoardInfo, getChild, getChildCount, getFood, getHazard, getSnakes, isExp, isSingleSnake, setExp, setPossibleMove, updateChildCount
-
-
-
-
Field Detail
-
MINIMUN_SNAKE
protected static final int MINIMUN_SNAKE
Minimun number of snake for Squad Mode. If number of snake smaller than this value, the game end- See Also:
- Constant Field Values
-
-
Method Detail
-
setSquadScore
private void setSquadScore()
Sets the node score
-
createNode
public AbstractNode createNode(List<SnakeInfo> snakes, AbstractNode currentNode)
Description copied from class:AbstractNodeCreate a node from the same type- Specified by:
createNodein classAbstractNode- Parameters:
snakes- List of snake InfocurrentNode- Current node- Returns:
- new node from this type
-
getScoreRatio
public float getScoreRatio()
Description copied from class:AbstractNodeGets the score ratio, the score ratio is compute has follow Our snake score / (all others snakes score added)- Overrides:
getScoreRatioin classAbstractNode- Returns:
- float score ratio
-
initBoard
protected int[][] initBoard()
Initiate the board array- Overrides:
initBoardin classAbstractEvaluationNode- Returns:
- board array
-
getPartnerIndex
private int getPartnerIndex(SnakeInfo snake)
Gets the index , for the teammate- Parameters:
snake- Current snake- Returns:
- int for the index of the teammate
-
generateHash
protected void generateHash(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap old, it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap newHash, int[][] board)Generate new position to be added to hash- Overrides:
generateHashin classAbstractEvaluationNode- Parameters:
old- Previous hashnewHash- New hashboard- Board array
-
checkBoardHash
protected boolean checkBoardHash(int newPosX, int newPosY, int[][] board, int value)Check the board array if the hash value can expand- Parameters:
newPosX- Position XnewPosY- Position Yboard- Board arrayvalue- the hash value- Returns:
- if possible to expand
-
updateScoreRatio
public void updateScoreRatio()
Update the score ratio- Overrides:
updateScoreRatioin classAbstractNode
-
-