コード例 #1
0
        protected virtual bool HandleAttackTransferMoves(IGameplayEngine firstPlayer, IGameplayEngine secondPlayer)
        {
            var moves = firstPlayer.GetAttackTransferMoves(_timeout); ;
            ProcessPlayerMoves(firstPlayer, secondPlayer, moves.Cast<Move>().ToList());
            if (DetectGameEnd())
            {
                return true;
            }

            moves = secondPlayer.GetAttackTransferMoves(_timeout);
            ProcessPlayerMoves(secondPlayer, firstPlayer, moves.Cast<Move>().ToList());
            if (DetectGameEnd())
            {
                return true;
            }

            firstPlayer.State.UpdateMap(GetMapUpdate(firstPlayer.Name));
            secondPlayer.State.UpdateMap(GetMapUpdate(secondPlayer.Name));

            return false;
        }
コード例 #2
0
        /// <summary>
        /// Called when the bot needs to make a place_armies or attack/transfer move.
        /// </summary>
        /// <param name="bot"></param>
        /// <param name="parts"></param>
        /// <returns></returns>
        private static string Go(IGameplayEngine bot, string[] parts)
        {
            IEnumerable<Move> moves = null;
            int timeout = int.Parse(parts[2]);

            if (parts[1].Equals("place_armies"))
            {
                moves = bot.GetPlaceArmiesMoves(timeout).Cast<Move>();
            }
            else if (parts[1].Equals("attack/transfer"))
            {
                moves = bot.GetAttackTransferMoves(timeout).Cast<Move>();
            }
            else
            {
                throw new Exception(string.Format("Unkown go command '{0}'.", parts[1]));
            }

            if (moves == null || !moves.Any())
            {
                return "No moves";
            }
            else
            {
                string output = string.Join(",", moves.Select(m => m.GetCommandString()).ToArray());
                return output;
            }
        }