コード例 #1
0
ファイル: WorldMap.cs プロジェクト: florinleon/ActressMas
        public string CreateName(InsectAgent a)
        {
            if (a.GetType().Name == "AntAgent")
            {
                return($"a{_currentId++}");
            }
            else if (a.GetType().Name == "DoodlebugAgent")
            {
                return($"d{_currentId++}");
            }

            throw new Exception($"Unknown agent type: {a.GetType().Name}");
        }
コード例 #2
0
ファイル: WorldMap.cs プロジェクト: jferdelyi/ActressMas
        public string CreateName(InsectAgent a)
        {
            if (a.GetType().Name == "AntAgent")
            {
                return(string.Format("a{0}", _currentId++));
            }
            else if (a.GetType().Name == "DoodlebugAgent")
            {
                return(string.Format("d{0}", _currentId++));
            }

            throw new Exception("Unknown agent type: " + a.GetType().ToString());
        }
コード例 #3
0
ファイル: WorldMap.cs プロジェクト: florinleon/ActressMas
        public void AddAgentToMap(InsectAgent a, int line, int column)
        {
            if (a.GetType().Name == "AntAgent")
            {
                _map[line, column].State = CellState.Ant;
            }
            else if (a.GetType().Name == "DoodlebugAgent")
            {
                _map[line, column].State = CellState.Doodlebug;
            }

            a.Line = line; a.Column = column;
            _map[line, column].AgentInCell = a;
        }
コード例 #4
0
ファイル: WorldMap.cs プロジェクト: florinleon/ActressMas
        public void Breed(InsectAgent a, int newLine, int newColumn)
        {
            InsectAgent offspring = null;

            if (a.GetType().Name == "AntAgent")
            {
                offspring = new AntAgent();
            }
            else if (a.GetType().Name == "DoodlebugAgent")
            {
                offspring = new DoodlebugAgent();
            }

            Add(offspring, CreateName(offspring)); // Add is from ActressMas.Environment
            AddAgentToMap(offspring, newLine, newColumn);

            if (Settings.Verbose)
            {
                Console.WriteLine($"Breeding {offspring.Name}");
            }
        }