Package net.sf.colossus.ai.helper
Class OnTheFlyLegionMove.OnTheFlyLegionMoveIterator
- java.lang.Object
-
- net.sf.colossus.ai.helper.OnTheFlyLegionMove.OnTheFlyLegionMoveIterator
-
- All Implemented Interfaces:
java.util.Iterator<LegionMove>
- Enclosing class:
- OnTheFlyLegionMove
class OnTheFlyLegionMove.OnTheFlyLegionMoveIterator extends java.lang.Object implements java.util.Iterator<LegionMove>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
OnTheFlyLegionMove.OnTheFlyLegionMoveIterator.myIntArrayComparator
(package private) class
OnTheFlyLegionMove.OnTheFlyLegionMoveIterator.myIntArrayLegionValueComparator
-
Field Summary
Fields Modifier and Type Field Description private boolean
abort
private java.util.SortedMap<int[],LegionMove>
alreadydone
map from indexes to LegionMove, what we have already sent to the AIprivate java.util.SortedMap<int[],LegionMove>
beingdone
map from indexes to LegionMove, the next batch to send to the AIprivate java.util.List<int[]>
byValues
already done & evaluated, sorted by legion valueprivate OnTheFlyLegionMove.OnTheFlyLegionMoveIterator.myIntArrayLegionValueComparator
byValuesComparator
private OnTheFlyLegionMove
daddy
private int
dim
private boolean
failoverOnly
private java.util.Set<java.lang.Integer>[][][]
incomps
The 'incompatibility map'.private int[]
lastDense
deterministically make up a on-used combinationprivate int[]
lastone
the previously returned objectprivate java.util.Random
rand
-
Constructor Summary
Constructors Constructor Description OnTheFlyLegionMoveIterator(OnTheFlyLegionMove d)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int[]
breed(int[] mom, int[] dad, int percentRandom)
breed a combination from parentsprivate void
buildIncompMap()
private int[]
failoverGeneration()
protected void
finalize()
private int
firstfill()
fill beingdone with the first, supposedly most interesting combinatione.private int[]
geneticGeneration()
create a genetic combinationprivate int[]
getParent(int percentRandom, int percentTop)
pick a parentboolean
hasNext()
private int
higherRankIncomp(int[] indexes)
(package private) java.lang.String
intArrayToString(int[] t)
private boolean
isBad(int[] indexes)
LegionMove
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[]
spontaneousGeneration()
create a fully random combination
-
-
-
Field Detail
-
alreadydone
private final java.util.SortedMap<int[],LegionMove> alreadydone
map from indexes to LegionMove, what we have already sent to the AI
-
byValues
private final java.util.List<int[]> byValues
already done & evaluated, sorted by legion value
-
byValuesComparator
private final OnTheFlyLegionMove.OnTheFlyLegionMoveIterator.myIntArrayLegionValueComparator byValuesComparator
-
lastone
private int[] lastone
the previously returned object
-
beingdone
private final java.util.SortedMap<int[],LegionMove> beingdone
map from indexes to LegionMove, the next batch to send to the AI
-
daddy
private final OnTheFlyLegionMove daddy
-
rand
private final java.util.Random rand
-
dim
private final int dim
-
abort
private boolean abort
-
failoverOnly
private boolean failoverOnly
-
incomps
private final java.util.Set<java.lang.Integer>[][][] 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[] lastDense
deterministically make up a on-used combination
-
-
Constructor Detail
-
OnTheFlyLegionMoveIterator
OnTheFlyLegionMoveIterator(OnTheFlyLegionMove d)
-
-
Method Detail
-
intArrayToString
java.lang.String intArrayToString(int[] t)
-
buildIncompMap
private void buildIncompMap()
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<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
public LegionMove next()
- Specified by:
next
in interfacejava.util.Iterator<LegionMove>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<LegionMove>
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-