public void FromMapData(MapData mapData) { Turn = mapData.Turn; Walls = mapData.Walls.Select(item => new Position(item[0], item[1])).ToList(); Blocks = mapData.Blocks.Select(item => new Position(item[0], item[1])).ToList(); Players = mapData.Players; Me = mapData.Players.Find(p => p.Name == Consts.MyName); Bombs = mapData.Bombs; Items = mapData.Items; Fires = mapData.Fires.Select(item => new Position(item[0], item[1])).ToList(); MinX = Walls.Select(item => item.x).Min(); int MaxX = Walls.Select(item => item.x).Max(); SizeX = MaxX - MinX + 1; MinY = Walls.Select(item => item.y).Min(); int MaxY = Walls.Select(item => item.y).Max(); SizeY = MaxY - MinY + 1; logger.Debug($"MinX: {MinX}, SizeX: {SizeX}, MinY {MinY}, SizeY {SizeY}"); var ary2 = Enumerable.Range(MinY, SizeY).Select(y => { return(Enumerable.Range(MinX, SizeX).Select(x => { var cell = new Cell() { X = x, Y = y, Wall = Walls.Any(w => w.x == x && w.y == y), Block = Blocks.Any(b => b.x == x && b.y == y), AnyPlayer = Players.Any(p => p.pos.x == x && p.pos.y == y && p.Name != Consts.MyName), MyPosition = Players.Any(p => p.pos.x == x && p.pos.y == y && p.Name == Consts.MyName), Bomb = Bombs.Find(b => b.pos.x == x && b.pos.y == y), Item = Items.Any(i => i.pos.x == x && i.pos.y == y), Fire = Fires.Any(f => f.x == x && f.y == y) }; var pos = new Position(x, y); return new KeyValuePair <Position, Cell>(pos, cell); })); }).SelectMany(e => e); CellDict = new CellDict(ary2, MinX, SizeX, MinY, SizeY); SetAboutToFire(); SetFallingWall(); CellDict.SetDistance(Me.pos); CellDict.Log(); }