Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Constants.Init(Console.ReadLine());
            GameMechanicsHelper.Init();

            Game game = Game.CreateFromInput();

            Log.SetFileName($"bot-{game.MyPlayer.Id}.log");

            GameMapGeometry.InitDimensions(game.GameMap);

            MyBot bot = new MyBot(game);

            bot.Initialize();

            // The Halite game process is waiting for output from us
            // This indicates the end of the initilization stage and starts the game
            Console.WriteLine("HaliteGameBot");

            while (true)
            {
                game.ReadFrameUpdate();
                Log.Write("Ships: " + string.Join(", ", game.MyPlayer.Ships));
                var    commands   = bot.GenerateTurnCommands();
                string turnOutput = string.Join(" ", commands.Select(command => command.ToString()).ToArray());
                Console.WriteLine(turnOutput);
                Console.Out.Flush();
                bot.OnMoveCompleted();
            }
        }
Ejemplo n.º 2
0
        public double EvaluateStatic(GameState gameState)
        {
            GameAction gameAction = gameState.RecentGameAction;

            if (gameAction == null)
            {
                return(0.0);
            }

            int distanceToShipyard = GameMapGeometry.NaiveDistance(
                _myShipyard.Position,
                new Position(gameAction.Ship.X, gameAction.Ship.Y));

            double shipHaliteBonus = Math.Max(0, 20 - distanceToShipyard) / 20.0 * gameAction.Ship.Halite;

            double result = gameAction.Player.Halite - BasePlayerHalite + shipHaliteBonus;

            return(result);
        }