internal void CreateTurns(int maxTurns) { // Pre create all the turns for the board, // At the beginning of each turn we need to update these states. // Updating these states is actually prediction the future with the known facts. // Based on these facts we can start looking for good moves. // That way we know the objects will all be there which make the rest of the code simpler. // it also reduces the number of memory allocations, which should help speed. TurnPrediction = new PlanetTurnPredictions(maxTurns); TurnPrediction.Capacity = TurnPrediction.Count; }
internal PlanetTurn FindCheapestTakeOverPoint(int shipsCanNotArriveBeforeThisTurn, PlanetTurnPredictions prediction) { return(this[shipsCanNotArriveBeforeThisTurn].Clone()); }
internal PlanetTurn CalcMaxGainUsingThisManyShips(PlanetTurn lowBoundFleetArrival, int attackShipCount, PlanetTurnPredictions prediction) { int targetTurn = lowBoundFleetArrival.TurnsFromNow; PlanetTurn current = FirstTurn; PlanetTurn copyTo = prediction.FirstTurn; while (targetTurn-- > 0) { copyTo.SetValues(current.Owner, current.NumShips); current = current.Next; copyTo = copyTo.Next; } current = copyTo; copyTo.Prior.SetValues(1, attackShipCount - current.NumShips); PlanetTurn prior = current; while (current != null) { prior = current; current = GrowTurn(GrowthRate, current); } return(prior); }