Class PredictSplitNode
java.lang.Object
net.sf.colossus.client.PredictSplitNode
- All Implemented Interfaces:
Comparable<PredictSplitNode>
Predicts splits for one enemy player, and adjusts predictions as
creatures are revealed.
- Author:
- David Ripton, Kim Milvang-Jensen See docs/SplitPrediction.txt
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CreatureTypeprivate PredictSplitNodeprivate PredictSplitNodeprivate intprivate static CreatureInfoComparatorprivate CreatureInfoListprivate final Stringprivate final PredictSplitNodeprivate final CreatureInfoListprivate final CreatureTypeprivate final intprivate final Variant -
Constructor Summary
ConstructorsConstructorDescriptionPredictSplitNode(String markerId, int turnCreated, CreatureInfoList cil, PredictSplitNode parent, Variant variant) -
Method Summary
Modifier and TypeMethodDescription(package private) voidaddCreature(CreatureType type) (package private) boolean(package private) booleanReturn true if all of this node's children, grandchildren, etc.(package private) List<CreatureType> chooseCreaturesToSplitOut(List<List<CreatureType>> possibleSplits) Decide how to split this legion, and return a list of creatures names to remove.private voidintcompareTo(PredictSplitNode other) (package private) voidcomputeSplit(int childSize, List<CreatureType> knownKeep, List<CreatureType> knownSplit, CreatureInfoList keepList, CreatureInfoList splitList) Computes the predicted split of childsize, given that we may already know some pieces that are keept or spilt.(package private) intReturn the number of times ob is found in li(package private) static intReturn the number of times name occurs in li(package private) List<List<CreatureType>> findAllPossibleSplits(int childSize, List<CreatureType> knownKeep, List<CreatureType> knownSplit) Return a list of all legal combinations of splitoffs.(package private) CreatureInfoListReturn list of CreatureInfo where atSplit == false.(package private) CreatureInfoListReturn list of CreatureInfo where atSplit == true, plus removed creatures.(package private) CreatureInfoListReturn list of CreatureInfo where both certain and atSplit are true, plus removed creatures.(package private) CreatureInfoListReturn list of CreatureInfo where certain == true.(package private) List<PredictSplitNode> (package private) CreatureInfoListReturn list of CreatureInfo(package private) int(package private) String(package private) CreatureInfoListReturn list of CreatureInfoint(package private) booleanhasSplit()booleanisLegalInitialSplitoff(List<CreatureType> types) (package private) voidmerge(PredictSplitNode other) Recombine this legion and other, because it was not possible to move.(package private) static intlili is a list of lists.(package private) int(package private) int(package private) voidremoveCreature(CreatureType type) (package private) voidremoveCreatures(List<CreatureType> creatureTypes) (package private) voidreSplit()Recompute the split of a stack, taking advantage of any information potentially gained from the children(package private) voidrevealCreatures(List<CreatureType> cnl) private static <T> booleansafeEquals(T obj1, T obj2) (package private) voidsetCreatures(CreatureInfoList creatures) (package private) voidPerform the initial split of a stack, and create the children(package private) static <T> List<T> subtractLists(List<T> big, List<T> little) (package private) static <T> booleanReturn true if big is a superset of little.toString()(package private) voidupdateInitialSplitInfo(CreatureInfoList newList) This takes potentially new information about the legion's composition at split and applies the later changes to the legion to get a new predicton of contents.
-
Field Details
-
markerId
-
turnCreated
private final int turnCreated -
creatures
-
removed
-
parent
-
childSize2
private int childSize2 -
child1
-
child2
-
variant
-
titan
-
angel
-
cic
-
-
Constructor Details
-
PredictSplitNode
PredictSplitNode(String markerId, int turnCreated, CreatureInfoList cil, PredictSplitNode parent, Variant variant)
-
-
Method Details
-
clearChildren
private void clearChildren() -
getMarkerId
-
getFullName
-
getChild1
-
getChild2
-
getParent
-
getTurnCreated
public int getTurnCreated() -
toString
-
getCreatures
CreatureInfoList getCreatures()Return list of CreatureInfo -
setCreatures
-
getRemovedCreatures
CreatureInfoList getRemovedCreatures()Return list of CreatureInfo -
getCertainCreatures
CreatureInfoList getCertainCreatures()Return list of CreatureInfo where certain == true. -
numCertainCreatures
int numCertainCreatures() -
numUncertainCreatures
int numUncertainCreatures() -
allCertain
boolean allCertain() -
hasSplit
boolean hasSplit() -
getChildren
List<PredictSplitNode> getChildren() -
allDescendentsCertain
boolean allDescendentsCertain()Return true if all of this node's children, grandchildren, etc. have no uncertain creatures -
getAtSplitOrRemovedCreatures
CreatureInfoList getAtSplitOrRemovedCreatures()Return list of CreatureInfo where atSplit == true, plus removed creatures. -
getAfterSplitCreatures
CreatureInfoList getAfterSplitCreatures()Return list of CreatureInfo where atSplit == false. -
getCertainAtSplitOrRemovedCreatures
CreatureInfoList getCertainAtSplitOrRemovedCreatures()Return list of CreatureInfo where both certain and atSplit are true, plus removed creatures. -
getOtherChildMarkerId
String getOtherChildMarkerId() -
getHeight
int getHeight() -
superset
Return true if big is a superset of little. Note that this treats repeated elements as distinct, i.e. if the little list contains two copies of something, then the big list has to contain two copies, too. It differs in that regard from Collection.containsAll(Collection) which is implemented in a fashion where this is not necessary (the specification as of JDK 1.5 is actually blurry on the matter). -
revealCreatures
-
isLegalInitialSplitoff
-
findAllPossibleSplits
List<List<CreatureType>> findAllPossibleSplits(int childSize, List<CreatureType> knownKeep, List<CreatureType> knownSplit) Return a list of all legal combinations of splitoffs. Also update knownKeep and knownSplit if we conclude that more creatures are certain.- Parameters:
childSize-knownKeep-knownSplit-- Returns:
-
safeEquals
private static <T> boolean safeEquals(T obj1, T obj2) -
chooseCreaturesToSplitOut
Decide how to split this legion, and return a list of creatures names to remove. Return empty list on error. -
count
-
computeSplit
void computeSplit(int childSize, List<CreatureType> knownKeep, List<CreatureType> knownSplit, CreatureInfoList keepList, CreatureInfoList splitList) Computes the predicted split of childsize, given that we may already know some pieces that are keept or spilt. Also makes the new CreatureInfoLists. Note that knownKeep and knownSplit will be altered, and be empty after call- Parameters:
childSize-knownKeep- certain creatures to keepknownSplit- certain creatures to splitkeepList- return argumentsplitList- return argument
-
split
Perform the initial split of a stack, and create the children- Parameters:
childSize-turn-otherMarkerId-
-
reSplit
void reSplit()Recompute the split of a stack, taking advantage of any information potentially gained from the children -
updateInitialSplitInfo
This takes potentially new information about the legion's composition at split and applies the later changes to the legion to get a new predicton of contents. It then recursively resplits.- Parameters:
newList-
-
merge
Recombine this legion and other, because it was not possible to move. They must share a parent. If either legion has the parent's markerId, then that legion will remain. Otherwise this legion will remain. Also used to undo splits. -
addCreature
-
removeCreature
-
removeCreatures
-
compareTo
- Specified by:
compareToin interfaceComparable<PredictSplitNode>
-
subtractLists
-
count
-
minCount
-