Beispiel #1
0
        // parse engine input and update the game state
        private void ParseUpdate(List <string> input)
        {
            // do some stuff first

            foreach (string line in input)
            {
                if (line.Length <= 0)
                {
                    continue;
                }

                string[] tokens = line.Split();

                if (tokens.Length >= 3)
                {
                    int row = int.Parse(tokens[1]);
                    int col = int.Parse(tokens[2]);

                    if (tokens[0].Equals("a"))
                    {
                        state.AddAnt(row, col, int.Parse(tokens[3]));
                    }
                    else if (tokens[0].Equals("f"))
                    {
                        state.AddFood(row, col);
                    }
                    else if (tokens[0].Equals("r"))
                    {
                        state.RemoveFood(row, col);
                    }
                    else if (tokens[0].Equals("w"))
                    {
                        state.AddWater(row, col);
                    }
                    else if (tokens[0].Equals("d"))
                    {
                        state.DeadAnt(row, col);
                    }
                    else if (tokens[0].Equals("h"))
                    {
                        state.AntHill(row, col, int.Parse(tokens[3]));
                    }
                }
            }
        }