Beispiel #1
0
        private static double ScoreBundle(GameLayer layer, Bundle bundle)
        {
            double score     = 0;
            var    state     = layer.GetState();
            int    avSpace   = 0;
            int    turnsleft = state.MaxTurns - state.Turn;
            double income    = Helper.GetIncome(layer);

            if (income < 600 && state.Funds < 70000 && turnsleft > 100 && bundle.TotalIncome != 0)
            {
                score += Math.Min(1000 / (0.25 * (bundle.TotalIncome / turnsleft)), 1500);
            }
            foreach (var building in state.ResidenceBuildings)
            {
                avSpace += (layer.GetResidenceBlueprint(building.BuildingName).MaxPop - building.CurrentPop);
            }
            if (bundle.Residence != null)
            {
                score += Math.Min((state.HousingQueue - avSpace) * bundle.Residence.MaxPop * 4, 4000);
            }
            if ((state.Funds - bundle.UpfrontCost < 40000 || income < 400) && bundle.Upgrade != null)
            {
                return(-100);
            }
            score += bundle.PotentialScore;
            return(score);
        }
Beispiel #2
0
        private static void take_turn(string gameId)
        {
            // TODO Implement your artificial intelligence here.
            // TODO Taking one action per turn until the game ends.
            // TODO The following is a short example of how to use the StarterKit
            var x     = 0;
            var y     = 0;
            var state = GameLayer.GetState();

            if (state.ResidenceBuildings.Count < 1)
            {
                for (var i = 0; i < 10; i++)
                {
                    for (var j = 0; j < 10; j++)
                    {
                        if (state.Map[i][j] == 0)
                        {
                            x = i;
                            y = j;
                            break;
                        }
                    }
                }

                GameLayer.StartBuild(new Position(x, y), state.AvailableResidenceBuildings[0].BuildingName, gameId);
            }
            else
            {
                var building = state.ResidenceBuildings[0];
                if (building.BuildProgress < 100)
                {
                    GameLayer.Build(building.Position, gameId);
                }
                else if (!building.Effects.Contains(state.AvailableUpgrades[0].Name))
                {
                    GameLayer.BuyUpgrade(building.Position, state.AvailableUpgrades[0].Name, gameId);
                }
                else if (building.Health < 50)
                {
                    GameLayer.Maintenance(building.Position, gameId);
                }

                else if (building.Temperature < 18)
                {
                    var bluePrint = GameLayer.GetResidenceBlueprint(building.BuildingName);
                    var energy    = bluePrint.BaseEnergyNeed + (building.Temperature - state.CurrentTemp)
                                    * bluePrint.Emissivity / 1 + 0.5 - building.CurrentPop * 0.04;
                    GameLayer.AdjustEnergy(building.Position, energy, gameId);
                }
                else if (building.Temperature > 24)
                {
                    var bluePrint = GameLayer.GetResidenceBlueprint(building.BuildingName);
                    var energy    = bluePrint.BaseEnergyNeed + (building.Temperature - state.CurrentTemp)
                                    * bluePrint.Emissivity / 1 - 0.5 - building.CurrentPop * 0.04;
                    GameLayer.AdjustEnergy(building.Position, energy, gameId);
                }
                else
                {
                    GameLayer.Wait(gameId);
                }

                foreach (var message in GameLayer.GetState().Messages)
                {
                    Console.WriteLine(message);
                }

                foreach (var error in GameLayer.GetState().Errors)
                {
                    Console.WriteLine("Error: " + error);
                }
            }
        }