Class AbstractEvaluationNode
- java.lang.Object
-
- ai.nettogrof.battlesnake.treesearch.node.AbstractNode
-
- ai.nettogrof.battlesnake.treesearch.node.AbstractDecisionNode
-
- ai.nettogrof.battlesnake.treesearch.node.AbstractEvaluationNode
-
- Direct Known Subclasses:
AbstractRoyaleNode,ConstrictorNode,DuelNode,FourNode,ManyNode,SquadNode
public abstract class AbstractEvaluationNode extends AbstractDecisionNode
This abstract evaluation node class is the based of all node class methods evaluation, provide evaluation method use in any node.- Version:
- Summer 2021
- Author:
- carl.lajeunesse
-
-
Field Summary
Fields Modifier and Type Field Description private static intDEFAULTRVdefault openhashmap value-
Fields inherited from class ai.nettogrof.battlesnake.treesearch.node.AbstractNode
allChildsCount, boardInfo, child, exp, food, hazard, ONE, possibleMove, score, scoreRatio, snakes
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEvaluationNode(List<SnakeInfo> snakes, FoodInfo food, BoardInfo boardInfo)Constructor with snakes and food information
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddBasicLengthScore()Adding basic length to score and health score = length + health /50protected voidaddScoreDistance(int head)Adjust our snake score for the distance between head and the nearest foodprotected voidaddScoreDistanceAll()Adjust our snake score for the distance between head and the nearest foodprotected voidaddSizeCompareScore()Add or remove score to our snake if it longer or shorter than the other snakesprotected voidaddToHash(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap newHash, int position, int value)Add the position and value to the hash mapprotected voidadjustScodeBasedonBoardControl(int[][] board)Adjust the score based on number of square controls by snakes The board array contain the snake number from 1 to X snakesprotected voidapplyNewHash(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap newHash, int[][] board)Apply the new Hash map value to the board.protected voidgenerateHash(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap old, it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap newHash, int[][] board)Generate new position to be added to hashprotected int[][]initBoard()Initiate the board arrayprotected voidlistAreaControl()Generate score based on the area control by the snake.protected voidsetWinnerMaxScore()Set Max score to winner snakes.-
Methods inherited from class ai.nettogrof.battlesnake.treesearch.node.AbstractDecisionNode
countSnakeAlive, updateScore
-
Methods inherited from class ai.nettogrof.battlesnake.treesearch.node.AbstractNode
addChild, createNode, getBoardInfo, getChild, getChildCount, getFood, getHazard, getScoreRatio, getSnakes, isExp, isSingleSnake, setExp, setPossibleMove, updateChildCount, updateScoreRatio
-
-
-
-
Method Detail
-
addScoreDistance
protected void addScoreDistance(int head)
Adjust our snake score for the distance between head and the nearest food- Parameters:
head- Square of the snake head
-
addScoreDistanceAll
protected void addScoreDistanceAll()
Adjust our snake score for the distance between head and the nearest food
-
applyNewHash
protected void applyNewHash(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap newHash, int[][] board)Apply the new Hash map value to the board.- Parameters:
newHash- The new hash map of position/valueboard- Board array
-
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- Parameters:
old- Previous hashnewHash- New hashboard- Board array
-
addToHash
protected void addToHash(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap newHash, int position, int value)Add the position and value to the hash map- Parameters:
newHash- hash map of position / valueposition- the current positionvalue- the value
-
addBasicLengthScore
protected void addBasicLengthScore()
Adding basic length to score and health score = length + health /50
-
addSizeCompareScore
protected void addSizeCompareScore()
Add or remove score to our snake if it longer or shorter than the other snakes
-
adjustScodeBasedonBoardControl
protected void adjustScodeBasedonBoardControl(int[][] board)
Adjust the score based on number of square controls by snakes The board array contain the snake number from 1 to X snakes- Parameters:
board- Board array
-
initBoard
protected int[][] initBoard()
Initiate the board array- Returns:
- board array
-
listAreaControl
protected void listAreaControl()
Generate score based on the area control by the snake. Using a kind of voronoi algo.
-
setWinnerMaxScore
protected void setWinnerMaxScore()
Set Max score to winner snakes.
-
-