Exemplo n.º 1
0
        public void ChasingEachOther()
        {
            initialConfig["grid"] =
            @"________________________
            ___W_____WWWWWWWW_______
            ________________________
            ________________________
            ________________________
            ________________________
            _WWWWWWWWW______________
            ________________________
            ________________________
            _________WWWWWWWW_______
            ________________________
            ___________WWWW_________
            ________________________
            ________________________
            ________________________
            ____X__________O________";

            initialConfig["orientation"] = "west";

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Move);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 2
0
        public static int Main(string[] args)
        {
            Directory.SetCurrentDirectory(IOUtil.GetProcessDirectory());

            JsonArgs commandLine = new JsonArgs(args);
            if (!commandLine.HasParam("?"))
            {
                string server = args[0];
                int port = int.Parse(args[1]);
                string gameId = args[2];
                string userId = args[3];

                while (true)
                {
                    try
                    {
                        Console.WriteLine("Starting game ...");
                        TankClient client = new HttpTankClient(server, port, gameId, userId);
                        using (Game game = new Game(client, true))
                        {
                            game.Run(new SignalWeights());
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("ERROR: " + ex);
                    }

                    ConsoleKey key = ConsoleKey.N;
                    while (key != ConsoleKey.Y)
                    {
                        Console.WriteLine("\n\nWould you like to play again (y, or n)?\n");
                        key = Console.ReadKey(true).Key;
                        if (key == ConsoleKey.N)
                        {
                            Console.WriteLine("Thanks for playing!");
                            return 0;
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine(Syntax);
            }

            return 0;
        }
Exemplo n.º 3
0
        public void Fire()
        {
            initialConfig["grid"] =
            @"________________________
            ___W_____WWWWWWWW_______
            ___W_W__________________
            ___W_W_______B____X_____
            ___W_W__________________
            ___W_W__________________
            _WWWWWWWWW________O_____
            _____W__________________
            _____W_WWWWW____________
            _________WWWWWWWW_______
            ________________________
            ___________WWWW_________
            ________________________
            ________________________
            ____WWW_________________
            ________________________";

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Fire);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 4
0
        public void DontNeedBattery()
        {
            initialConfig["grid"] =
            @"________________________
            ___W_____WWWWWWWW_______
            ___W_W_O________________
            ___W_W____________X_____
            ___W_W____________B_____
            ___W_W__________________
            _WWWWWWWWW______________
            _____W__________________
            _____W_WWWWW____________
            _________WWWWWWWW_______
            ________________________
            ___________WWWW_________
            ________________________
            ________________________
            ____WWW_________________
            ________________________";

            initialConfig["energy"] = 10;

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Move);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 5
0
        public void TurnRightToGetBattery()
        {
            initialConfig["grid"] =
            @"_____________________W__
            ___________WWWWWWWWWWW__
            _________B___W_B_____W__
            _____________________W__
            _____________________W__
            _WWWWWWWWWWW_________W__
            ________________________
            ________________________
            _______________W__W_____
            _______________W__W_____
            _____X____________W_____
            ___O_B____________W___L_
            __________________W_____
            __________________W_____
            ________________________
            ________________________";

            initialConfig["orientation"] = "east";

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Right);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 6
0
        public void ShotInTheBack()
        {
            initialConfig["grid"] =
            @"________________________
            ___W_____WWWWWWWW_______
            ___W_W_____________L____
            ___W_W__________________
            ___W_W_____________L____
            ___W_W__________________
            _WWWWWWWWW_________X____
            _____W__________________
            _____W_WWWWW____________
            _________WWWWWWWW_______
            ________________________
            ___________WWWW_________
            ___________________O____
            ________________________
            ____WWW_________________
            ________________________";

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Right | TankAction.Left);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 7
0
        public void OutOfEnergyGoGetBattery()
        {
            initialConfig["grid"] =
            @"________________________
            ________________W_______
            ________________W______W
            ____________W___W______W
            ________________W______W
            _______________________W
            ________________________
            ________________________
            ________WWWWWWWW________
            ________________B_______
            ________________________
            ___WWWWWWWWWWWWWW_______
            ______________________X_
            ______________________O_
            ________________________
            ________________________";

            initialConfig["energy"] = 0;

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Fire);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 8
0
        public void OpponentBetweenBatteryWithNoEnergy()
        {
            initialConfig["grid"] =
            @"________________________
            ___W_____WWWWWWWW_______
            ___W_W__________________
            ___W_W__________________
            ___W_W__________________
            ___W_W__________________
            _WWWWWWWWW_________X____
            _____W__________________
            _____W_WWWWW_______O____
            _________WWWWWWWW_______
            ________________________
            ___________WWWW____B____
            ________________________
            ________________________
            ____WWW_________________
            ________________________";

            initialConfig["energy"] = 0;

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Right | TankAction.Left);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 9
0
        public void OpponentBehindMe()
        {
            initialConfig["grid"] =
            @"________________________
            ___W_____WWWWWWWW_______
            ___W_W__________________
            ___W_W__________________
            ___W_W_____________O____
            ___W_W__________________
            _WWWWWWWWW_________X____
            _____W__________________
            _____W_WWWWW____________
            _________WWWWWWWW_______
            ________________________
            ___________WWWW_________
            ________________________
            ________________________
            ____WWW_________________
            ________________________";

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Left);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 10
0
        public void MultipleBatteriesWithOpponentNearOutOfEnergy()
        {
            initialConfig["grid"] =
            @"________________________
            ___W_____WWWWWWWW_______
            ___W_W_____B____________
            ___W_W____________X_____
            ___W_W____________B_____
            ___W_W__________________
            _WWWWWWWWW______________
            _____W______O___________
            _____W_WWWWW____________
            _________WWWWWWWW_______
            ________________________
            __________WWWW_________
            ________________________
            ________________________
            ____WWW_________________
            ________________________";

            initialConfig["energy"] = 0;
            initialConfig["health"] = 30;

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Move);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }
Exemplo n.º 11
0
        public void ForwardForBatteryFar()
        {
            initialConfig["grid"] =
            @"________________________
            ___W_____WWWWWWWW_______
            ___W_W__________________
            ___W_W____________X_____
            ___W_W__________________
            ___W_W__________________
            _WWWWWWWWW______________
            _____W__________________
            _____W_WWWWW____________
            _________WWWWWWWW_B_____
            ________________________
            ____O______WWWW_________
            ________________________
            ________________________
            ____WWW_________________
            ________________________";

            TestTankClient client = new TestTankClient(initialConfig, TankAction.Move);
            Game game = new Game(client);
            game.Run(new SignalWeights());
        }