Ejemplo n.º 1
0
        private void Socket_OnMessage(object sender, MessageEventArgs e)
        {
            if (!_shouldExit)
            {
                var response = e.Data;
                _retriesCount = 0;

                if (!response.StartsWith(_responsePrefix))
                {
                    Console.WriteLine("Something strange is happening on the server... Response:\n{0}", response);
                    InitiateExit();
                }
                else
                {
                    var boardString = response.Substring(_responsePrefix.Length);
                    var parser      = new MapParser(GameLib.Codes);
                    var dimension   = (int)Math.Sqrt(boardString.Length);
                    var map         = parser.ParseMapFromString(boardString, new VectorInt2(dimension, dimension));            //

                    var action = Get(map);

                    //Console.WriteLine("Answer: " + action);
                    //Console.SetCursorPosition(0, 0);

                    ((WebSocket)sender).Send(action);
                }
            }
        }
Ejemplo n.º 2
0
        public void Arrange(string board, GameInfo info)
        {
            var str = string.Join("", board.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));

            map        = mapParser.ParseMapFromString(str, new VectorInt2(7, 6));
            graph      = map.ToFullGraph();
            playerTile = map.PlayerTile;
            hunter     = new Hunter(map, info);
        }
Ejemplo n.º 3
0
        public void RightTilesInBlastZones()
        {
            var field = string.Join("", GameField2.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));

            map        = mapParser.ParseMapFromString(field, new VectorInt2(8, 7));
            playerTile = map.Values.First(x => x.IsPlayer);
            Assert.AreEqual(1, map.AllBombs.Count);
            Assert.AreEqual(10, map.GetBombBlastZone(new Tile(new VectorInt2(3, 4), TileTypes.Bomb1)).Count);
            Assert.AreEqual(10, map.GetChainBombBlastZone(new Tile(new VectorInt2(3, 4), TileTypes.Bomb1)).Count);
            Assert.AreEqual(10, map.GetAllBlastZones().Count);
        }
Ejemplo n.º 4
0
 public void Setup()
 {
     GameField1 = string.Join("", GameField1.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));
     mapParser  = new MapParser(codes);
     map        = mapParser.ParseMapFromString(GameField1, new VectorInt2(8, 7));
     graph      = map.ToFullGraph();
     mind       = new Mastermind("");
     pathfinder = new DijkstraPathfinder();
     playerTile = map.Values.First(x => x.IsPlayer);
     pathfinder.FindAllPaths(graph, playerTile);
 }