public AmbientBoard(int N, int M) { map = new AmbientCell[N, M]; this.Rows = N; this.Columns = M; this.Size = N * M; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { map[i, j] = new AmbientCell(); } } }
private void PrintMap() { string result = ""; for (int i = 0; i < ambient.AmbientBoard.Rows; i++) { result += PrintLine(); result += "|"; for (int j = 0; j < ambient.AmbientBoard.Columns; j++) { AmbientCell ac = ambient.AmbientBoard[i, j]; string[] temp = new string[5]; bool robot = (agent.Pos.x, agent.Pos.y) == (i, j); bool robotHasChild = robot && agent.Carrying; temp[0] = robot ? "@" : " "; temp[1] = " "; temp[2] = ac.IsObstacle ? "X" : " "; temp[3] = ac.IsPlaypen ? "#" : " "; temp[4] = ac.IsFilthy ? "*" : " "; if (ac.HasChild) { if (ac.IsPlaypen) { temp[1] = ((Playpen)ac.elementInside).child.ToString(); } else { temp[1] = ac.elementInside.ToString(); } } if (robotHasChild) { temp[1] = agent.Carried.ToString(); } result += string.Join("", temp) + "|"; } result += "\n"; } result += PrintLine(); Console.WriteLine(result); }