Class AbstractNode
- java.lang.Object
-
- ai.nettogrof.battlesnake.treesearch.node.AbstractNode
-
- Direct Known Subclasses:
AbstractDecisionNode
public abstract class AbstractNode extends Object
This abstract node class is the based of all node class, provide basic method use in any node.- Version:
- Spring 2021
- Author:
- carl.lajeunesse
-
-
Field Summary
Fields Modifier and Type Field Description protected intallChildsCountCounts of all node of that branchprotected BoardInfoboardInfoBoard width useful for some evaluation methodprotected List<AbstractNode>childList of child nodeprotected booleanexpDoes that node can be exploreprotected FoodInfofoodFood informationprotected AbstractHazardhazardHazard informationprotected static intONESingle posssible moveprotected intpossibleMoveNumber of possible move of our snakefloat[]scoreArray of score of each snakeprotected floatscoreRatioCurrent scoreRatioprotected List<SnakeInfo>snakesList of snakes
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractNode()Basic constructorprotectedAbstractNode(List<SnakeInfo> snakes, FoodInfo food, BoardInfo boardInfo)Constructor with the minimal info needed
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChild(AbstractNode newChild)Add a child to this nodeabstract AbstractNodecreateNode(List<SnakeInfo> snakes, AbstractNode currentNode)Create a node from the same typeBoardInfogetBoardInfo()List<AbstractNode>getChild()Gets list of child from this nodeintgetChildCount()Return counts of all node of that branchFoodInfogetFood()Gets food information,AbstractHazardgetHazard()Return the hazard objectfloatgetScoreRatio()Gets the score ratio, the score ratio is compute has follow Our snake score / (all others snakes score added)List<SnakeInfo>getSnakes()Gets list of snakes from this nodebooleanisExp()Does the node is ExpendablebooleanisSingleSnake()Return true if there's just one snakevoidsetExp(boolean exp)voidsetPossibleMove(int possibleMove)Set possible moveprotected voidupdateChildCount()Update the child countabstract voidupdateScore()Update this node scorevoidupdateScoreRatio()Update the score ratio
-
-
-
Field Detail
-
boardInfo
protected BoardInfo boardInfo
Board width useful for some evaluation method
-
ONE
protected static final int ONE
Single posssible move- See Also:
- Constant Field Values
-
child
protected List<AbstractNode> child
List of child node
-
food
protected FoodInfo food
Food information
-
hazard
protected AbstractHazard hazard
Hazard information
-
scoreRatio
protected float scoreRatio
Current scoreRatio
-
score
public float[] score
Array of score of each snake
-
possibleMove
protected int possibleMove
Number of possible move of our snake
-
allChildsCount
protected int allChildsCount
Counts of all node of that branch
-
exp
protected boolean exp
Does that node can be explore
-
-
Method Detail
-
getFood
public FoodInfo getFood()
Gets food information,- Returns:
- return the food information
-
getSnakes
public List<SnakeInfo> getSnakes()
Gets list of snakes from this node- Returns:
- Lost of snakeInfo
-
getChildCount
public int getChildCount()
Return counts of all node of that branch- Returns:
- All Childs count
-
getScoreRatio
public float getScoreRatio()
Gets the score ratio, the score ratio is compute has follow Our snake score / (all others snakes score added)- Returns:
- float score ratio
-
addChild
public void addChild(AbstractNode newChild)
Add a child to this node- Parameters:
newChild- Node to be added
-
updateScore
public abstract void updateScore()
Update this node score
-
updateScoreRatio
public void updateScoreRatio()
Update the score ratio
-
updateChildCount
protected void updateChildCount()
Update the child count
-
getChild
public List<AbstractNode> getChild()
Gets list of child from this node- Returns:
- list of child
-
createNode
public abstract AbstractNode createNode(List<SnakeInfo> snakes, AbstractNode currentNode)
Create a node from the same type- Parameters:
snakes- List of snake InfocurrentNode- Current node- Returns:
- new node from this type
-
isSingleSnake
public boolean isSingleSnake()
Return true if there's just one snake- Returns:
- if there's just one snake
-
getHazard
public AbstractHazard getHazard()
Return the hazard object- Returns:
- the hazard
-
setPossibleMove
public void setPossibleMove(int possibleMove)
Set possible move- Parameters:
possibleMove- int of number of possible move
-
isExp
public boolean isExp()
Does the node is Expendable- Returns:
- the exp
-
setExp
public void setExp(boolean exp)
- Parameters:
exp- the exp to set
-
getBoardInfo
public BoardInfo getBoardInfo()
- Returns:
- the boardInfo
-
-