|
Britbot
|
Assigns targets to each group based on pure magic Also initiate local scoring.
Definition at line 273 of file Commander.cs. {
//force groups to calculate priorities
Commander.StartCalcPriorities(cancellationToken);
//read dimensions of iteration
int[] dimensions = Commander.GetTargetsDimensions();
//read all possible target-group assignment
Score[][] possibleAssignments = Commander.GetPossibleTargetMatrix();
//indexes of the best assignment yet
int[] maxAssignment = new int[dimensions.Length];
//maxScore setup
double maxScore = Int32.MinValue;
//create new iteration object
ExpIterator iterator = new ExpIterator(dimensions);
//Score array for calculations in each iteration
Score[] scoreArr;
//create new simulated game
SimulatedGame sg = new SimulatedGame();
//iterating over all possible target assignments
do
{
//Throwing an exception if cancellation was requested.
cancellationToken.ThrowIfCancellationRequested();
//set score array for current iteration
scoreArr = Commander.GetSpecificAssignmentScores(possibleAssignments, iterator.Values);
//calculate new score
double newScore = Commander.GlobalizeScore(sg, scoreArr, cancellationToken);
//check if the score is better
if (newScore > maxScore)
{
//replace best
maxScore = newScore;
//copy the array to the maxAssigment array
Array.Copy(iterator.Values, maxAssignment, iterator.Values.Length);
}
} while (iterator.NextIteration());
//read the "winning" assignment
scoreArr = Commander.GetSpecificAssignmentScores(possibleAssignments, maxAssignment);
//now we got the best assignment, so just set it up
for (int i = 0; i < dimensions.Length; i++)
Commander.Groups[i].SetTarget(scoreArr[i].Target);
}
|
1.7.6.1