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 intPercentage from the top (of the already avaluated space) to pick a 'good' parent.private static final Loggerprivate static final longAmount of memory needed before a refill.private static final intMinimum number of possible 'good' parents.private final intprivate static final intPercentage that a gene will be random instead of inherited.private static final intMaximum number of try before giving up generating a new element.private static final intPercentage of a randomly chosen parent.private static final intnumber of elements to put in each new batch of element.private static final intPercentage of fully random new elements This helps diversifying the gene pool. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(LegionMove o) booleanaddAll(Collection<? extends LegionMove> c) voidclear()booleanbooleancontainsAll(Collection<?> c) boolean(package private) intgetDim()inthashCode()booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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:
addin interfaceCollection<LegionMove>
-
addAll
- Specified by:
addAllin interfaceCollection<LegionMove>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<LegionMove>
-
contains
- Specified by:
containsin interfaceCollection<LegionMove>
-
containsAll
- Specified by:
containsAllin interfaceCollection<LegionMove>
-
equals
- Specified by:
equalsin interfaceCollection<LegionMove>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<LegionMove>- Overrides:
hashCodein classObject
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<LegionMove>
-
iterator
- Specified by:
iteratorin interfaceCollection<LegionMove>- Specified by:
iteratorin interfaceIterable<LegionMove>
-
remove
- Specified by:
removein interfaceCollection<LegionMove>
-
removeAll
- Specified by:
removeAllin interfaceCollection<LegionMove>
-
retainAll
- Specified by:
retainAllin interfaceCollection<LegionMove>
-
size
public int size()- Specified by:
sizein interfaceCollection<LegionMove>
-
toArray
- Specified by:
toArrayin interfaceCollection<LegionMove>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<LegionMove>
-