|
Britbot
|
A c'tor, this should allocate memory This should be called ONCE PER TURN. Definition at line 76 of file SimulatedGame.cs. {
//initialize stuff
this.CommingEvents = new HeapPriorityQueue<SimulatedEvent>((int) (2 * Magic.MaxCalculableDistance));
this.ConstantEvents = new List<SimulatedEvent>();
this.Islands = new Dictionary<int,SimulatedIsland>();
this.MyGroups = new Dictionary<int, SimulatedGroup>();
this.EnemyGroups = new Dictionary<int, SimulatedGroup>();
//add the ending Event
this.ConstantEvents.Add(new SimulationEndEvent(Magic.SimulationLength));
this.OriginalEnemyDeadPirates = 0;
this.OriginalMyDeadPirates = 0;
this.OriginalMyIslandCount = 0;
this.OriginalEnemyIslandCount = 0;
//set my groups
foreach (Group group in Commander.Groups)
{
//check if capturing
bool isCapturing = false;
foreach(SmartIsland sIsland in SmartIsland.IslandList)
{
if(group.MinimalETATo(sIsland.Loc) == 0)
{
isCapturing = true;
break;
}
}
this.MyGroups.Add(group.Id, new SimulatedGroup(group.Id, Consts.ME, group.LiveCount(), isCapturing));
}
//set enemy group
foreach (EnemyGroup eGroup in Enemy.Groups)
{
//check if capturing
bool isCapturing = false;
foreach (SmartIsland sIsland in SmartIsland.IslandList)
{
if (eGroup.MinimalETATo(sIsland.Loc) == 0)
{
isCapturing = true;
break;
}
}
this.EnemyGroups.Add(eGroup.Id, new SimulatedGroup(eGroup.Id, Consts.ENEMY, eGroup.GetMaxFightPower(), isCapturing));
}
//set up islands
foreach (SmartIsland sIsland in SmartIsland.IslandList)
{
SimulatedIsland newIsland = new SimulatedIsland(id: sIsland.Id,
owner: sIsland.Owner,
turnsBeingCaptured: sIsland.TurnsBeingCaptured,
value: sIsland.Value);
//we set capturing teams through events
this.Islands.Add(newIsland.Id, newIsland);
if (sIsland.Owner == Consts.ME)
OriginalMyIslandCount+= sIsland.Value;
if (sIsland.Owner == Consts.ENEMY)
OriginalEnemyIslandCount += sIsland.Value;
}
//set constant events
foreach (SmartIsland sIsland in SmartIsland.IslandList)
{
//go over the enemy list of each island
foreach (KeyValuePair<EnemyGroup, bool> enemy in sIsland.approachingEnemies)
{
SimulatedEvent newEvent;
//if it is likely that he will come to the island
if (enemy.Value)
{
newEvent = new GroupArrivalEvent((int)enemy.Key.MinimalETATo(sIsland.Loc),
this.Islands[sIsland.Id],
this.EnemyGroups[enemy.Key.Id]);
this.ConstantEvents.Add(newEvent);
}
else if ((int)enemy.Key.MinimalETATo(sIsland.Loc) < 0 || Commander.IsDefensive() )
{
newEvent = new PossibleArrivalEvent((int)enemy.Key.MinimalETATo(sIsland.Loc),
this.Islands[sIsland.Id],
this.EnemyGroups[enemy.Key.Id]);
this.ConstantEvents.Add(newEvent);
}
}
//add the event
//check if there are ships on the islands
foreach(Group g in Commander.Groups)
{
if(g.MinimalETATo(sIsland.Loc) <= 1)
{
this.Islands[sIsland.Id].CapturingGroup = this.MyGroups[g.Id];
break;
}
}
}
}
|
1.7.6.1