Package net.sf.colossus.ai.helper
Class OnTheFlyLegionMove.OnTheFlyLegionMoveIterator
java.lang.Object
net.sf.colossus.ai.helper.OnTheFlyLegionMove.OnTheFlyLegionMoveIterator
- All Implemented Interfaces:
Iterator<LegionMove>
- Enclosing class:
- OnTheFlyLegionMove
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final SortedMap<int[],
LegionMove> map from indexes to LegionMove, what we have already sent to the AIprivate final SortedMap<int[],
LegionMove> map from indexes to LegionMove, the next batch to send to the AIprivate final List<int[]>
already done & evaluated, sorted by legion valueprivate final OnTheFlyLegionMove
private final int
private boolean
The 'incompatibility map'.private int[]
deterministically make up a on-used combinationprivate int[]
the previously returned objectprivate final Random
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int[]
breed
(int[] mom, int[] dad, int percentRandom) breed a combination from parentsprivate void
private int[]
protected void
finalize()
private int
fill beingdone with the first, supposedly most interesting combinatione.private int[]
create a genetic combinationprivate int[]
getParent
(int percentRandom, int percentTop) pick a parentboolean
hasNext()
private int
higherRankIncomp
(int[] indexes) (package private) String
intArrayToString
(int[] t) private boolean
isBad
(int[] indexes) next()
private int
recurseGenerate
(int index, int[] counts, int[] actual) full recursive generationprivate int
refill
(int n) fill beingdone with up to n genetically generated, not-yet-done combinations.void
remove()
private int[]
create a fully random combinationMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
alreadydone
map from indexes to LegionMove, what we have already sent to the AI -
byValues
already done & evaluated, sorted by legion value -
byValuesComparator
private final OnTheFlyLegionMove.OnTheFlyLegionMoveIterator.myIntArrayLegionValueComparator byValuesComparator -
lastone
private int[] lastonethe previously returned object -
beingdone
map from indexes to LegionMove, the next batch to send to the AI -
daddy
-
rand
-
dim
private final int dim -
abort
private boolean abort -
failoverOnly
private boolean failoverOnly -
incomps
The 'incompatibility map'. first index is which position in the source int[] is checked. second index is which position in the destination source int[] is checked. third index is value in the source int[]. The Set is all the incompatible values in the dest int[]. -
lastDense
private int[] lastDensedeterministically make up a on-used combination
-
-
Constructor Details
-
OnTheFlyLegionMoveIterator
OnTheFlyLegionMoveIterator(OnTheFlyLegionMove d)
-
-
Method Details
-
intArrayToString
-
buildIncompMap
private void buildIncompMap() -
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceIterator<LegionMove>
-
higherRankIncomp
private int higherRankIncomp(int[] indexes) -
isBad
private boolean isBad(int[] indexes) -
recurseGenerate
private int recurseGenerate(int index, int[] counts, int[] actual) full recursive generation -
firstfill
private int firstfill()fill beingdone with the first, supposedly most interesting combinatione.- Returns:
- The number of combinations generated.
-
failoverGeneration
private int[] failoverGeneration() -
spontaneousGeneration
private int[] spontaneousGeneration()create a fully random combination -
geneticGeneration
private int[] geneticGeneration()create a genetic combination -
getParent
private int[] getParent(int percentRandom, int percentTop) pick a parent -
breed
private int[] breed(int[] mom, int[] dad, int percentRandom) breed a combination from parents -
refill
private int refill(int n) fill beingdone with up to n genetically generated, not-yet-done combinations.- Parameters:
n
- The number of requeste combinations.- Returns:
- The number of combinations generated.
-
next
- Specified by:
next
in interfaceIterator<LegionMove>
-
remove
public void remove()- Specified by:
remove
in interfaceIterator<LegionMove>
-
finalize
-