示例#1
0
        public bool DoNextIteration()
        {
            /*
             * //DEBUG
             * return (++_iteration == 1000);
             */


            _iteration++;


            for (int i = 0; i < bots.Length; i++)
            {
                EBot bot = bots[i];

                if (bot.alive)
                {
                    bot.DoRun(this);

                    if (!bot.alive)
                    {
                        cells[bot.point.x, bot.point.y].Clear();
                    }
                }

                if (isGenerationComplete())
                {
                    _history.Add(this);
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
        private void createBots()
        {
            for (int i = 0; i < bots.Length; i++)
            {
                ECell cell = selectEmptyCell();
                bots[i] = new EBot(cell);

                _generationIndex[i] = i;
            }

            RecalculationBotTraceIndex();

            return;
        }
示例#3
0
        public void RecalculationBotTraceIndex()
        {
            for (int i = 0; i < _traceIndex.Length; i++)
            {
                _traceIndex[i] = -1;
            }

            for (int i = 0; i < bots.Length; i++)
            {
                EBot bot = null;
                for (int j = 0; j < _generationIndex.Length; j++)
                {
                    if (_generationIndex[j] == i)
                    {
                        bot = bots[j];
                        break;
                    }
                }


                if (_traceIndex[i % 8] == -1 && (bot.alive || (i >= ESetting.BOT_COUNT_MAX - ESetting.BOT_COUNT_MIN)))
                {
                    bot.traceIndex     = i % 8;
                    _traceIndex[i % 8] = i % 8;
                }
                else
                {
                    bot.traceIndex = -1;
                }

                /*
                 * int genIndex = _generationIndex[i];
                 *
                 * if (_traceIndex[genIndex % 8] == -1 && (bots[genIndex].alive || (genIndex >= ESetting.BOT_COUNT_MAX - ESetting.BOT_COUNT_MIN)))
                 * {
                 *  bots[genIndex].traceIndex = genIndex % 8;
                 *  _traceIndex[genIndex % 8] = genIndex % 8;
                 * }
                 * else
                 * {
                 *  bots[genIndex].traceIndex = -1;
                 * }
                 */
            }

            return;
        }
示例#4
0
        public void DoRecovery(ECell cell, EBot sampleBot)
        {
            //_genom = "";
            _checkSum = String.Empty;
            _point    = cell.point;

            _course     = (MOrientation)MRandom.Next(Enum.GetValues(typeof(MOrientation)).Length);
            _generation = sampleBot.generation;
            _health     = ESetting.BOT_HEALTH_BIRTH;

            _dieByToxin = false;

            for (int i = 0; i < ESetting.BOT_PROGRAM_SIZE; i++)
            {
                program[i] = sampleBot.program[i];
            }
            for (int i = 0; i < ESetting.BOT_PROGRAM_SIZE; i++)
            {
                calls[i] = sampleBot.calls[i];
            }
            _address = 0;

            return;
        }
 public EResultGenerationBot(EBot bot)
 {
     generation = bot.generation;
     health     = bot.health;
     checkSum   = bot.checkSum.Substring(0, 4);
 }