Package net.sf.colossus.ai.helper
Class OnTheFlyLegionMove
java.lang.Object
net.sf.colossus.ai.helper.OnTheFlyLegionMove
- All Implemented Interfaces:
Iterable<LegionMove>
,Collection<LegionMove>
On-the-fly generation of the Collection of all possible LegionMove.
This doesn't fully respect the Collection interface:
The random generation may fail before all elements have been returned,
so to iterators may return different subsets of the entire collection.
Also, this may cause size() to return a value higher than what is really
accessible.
- Author:
- Romain Dolbeau
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List
<List<CritterMove>> private static final int
Percentage from the top (of the already avaluated space) to pick a 'good' parent.private static final Logger
private static final long
Amount of memory needed before a refill.private static final int
Minimum number of possible 'good' parents.private final int
private static final int
Percentage that a gene will be random instead of inherited.private static final int
Maximum number of try before giving up generating a new element.private static final int
Percentage of a randomly chosen parent.private static final int
number of elements to put in each new batch of element.private static final int
Percentage of fully random new elements This helps diversifying the gene pool. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(LegionMove o) boolean
addAll
(Collection<? extends LegionMove> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
(package private) int
getDim()
int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
RANDOM_MAX_TRY
private static final int RANDOM_MAX_TRYMaximum number of try before giving up generating a new element. Ideally this is only a safety belt.- See Also:
-
REFILL_SIZE
private static final int REFILL_SIZEnumber of elements to put in each new batch of element. From my experiments, should be about 1-3 second worth of evaluation.- See Also:
-
RANDOM_GENE_PERCENT
private static final int RANDOM_GENE_PERCENTPercentage that a gene will be random instead of inherited. Low will densify exploration around the current maximums. High will widen the explorated space around the current maximums.- See Also:
-
RANDOM_PARENT_PERCENT
private static final int RANDOM_PARENT_PERCENTPercentage of a randomly chosen parent. Another parameter to avoid inbreeding and missing not-yet-detected local maximums.- See Also:
-
GOOD_PARENT_TOP_PERCENT
private static final int GOOD_PARENT_TOP_PERCENTPercentage from the top (of the already avaluated space) to pick a 'good' parent. Low will pick parent only from very near the local maximums. High will give not-so-good parents a chance.to breed.- See Also:
-
MIN_PARENT_CHOICE
private static final int MIN_PARENT_CHOICEMinimum number of possible 'good' parents. For small exploration space, this avoid excessive inbreeding.- See Also:
-
SPONTANEOUS_GENERATION_PERCENT
private static final int SPONTANEOUS_GENERATION_PERCENTPercentage of fully random new elements This helps diversifying the gene pool.- See Also:
-
MIN_MEMORY_REFILL
private static final long MIN_MEMORY_REFILLAmount of memory needed before a refill. This avoid crashing low-mem JVM. The constant part is of the pulled-out-of-a-hat variety.- See Also:
-
LOGGER
-
allCritterMoves
-
mysize
private final int mysize
-
-
Constructor Details
-
OnTheFlyLegionMove
-
-
Method Details
-
getDim
int getDim() -
add
- Specified by:
add
in interfaceCollection<LegionMove>
-
addAll
- Specified by:
addAll
in interfaceCollection<LegionMove>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<LegionMove>
-
contains
- Specified by:
contains
in interfaceCollection<LegionMove>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<LegionMove>
-
equals
- Specified by:
equals
in interfaceCollection<LegionMove>
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<LegionMove>
- Overrides:
hashCode
in classObject
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<LegionMove>
-
iterator
- Specified by:
iterator
in interfaceCollection<LegionMove>
- Specified by:
iterator
in interfaceIterable<LegionMove>
-
remove
- Specified by:
remove
in interfaceCollection<LegionMove>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<LegionMove>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<LegionMove>
-
size
public int size()- Specified by:
size
in interfaceCollection<LegionMove>
-
toArray
- Specified by:
toArray
in interfaceCollection<LegionMove>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<LegionMove>
-