Esempio n. 1
0
        public void SerializeWorld(List <Cell> world, long step)
        {
            if (!_workingFolderCreated)
            {
                Directory.CreateDirectory(_workingFolder);
                _workingFolderCreated = true;
            }

            DateTime now      = DateTime.Now;
            string   filename = $"{_workingFolder}\\{step:D8}-{now:yyyy-MM-dd-HH-mm-ss}-world.xml";

            CellUtils.SaveCells(filename, world);
        }
Esempio n. 2
0
        private void SerializeBest(Cell cell, long step)
        {
            if (!_workingFolderCreated)
            {
                Directory.CreateDirectory(_workingFolder);
                _workingFolderCreated = true;
            }

            DateTime now      = DateTime.Now;
            string   filename = $"{_workingFolder}\\{step:D8}-{now:yyyy-MM-dd-HH-mm-ss}-top.xml";

            CellUtils.SaveCell(filename, cell);
        }
Esempio n. 3
0
        public void InitializeFromTopFile(string filename)
        {
            Cell masterCell = CellUtils.ReadCell(filename);

            if (masterCell != null)
            {
                foreach (var cell in Cells)
                {
                    cell.CloneFrom(masterCell, _random, _maxX, _maxY, false, 0.0f);
                    cell.Random        = new Random(_random.Next());
                    cell.CurrentEnergy = AppProperties.InitialCellEnergy;
                    cell.LocationX     = _random.Next(_maxX);
                    cell.LocationY     = _random.Next(_maxY);
                }
            }
        }
Esempio n. 4
0
        public void InitializeFromWorldFile(string filename)
        {
            List <Cell> cells = CellUtils.ReadCells(filename);

            if (cells != null)
            {
                Cells = cells.ToArray();

                foreach (var cell in Cells)
                {
                    cell.Random        = new Random(_random.Next());
                    cell.CurrentEnergy = AppProperties.InitialCellEnergy;
                    cell.LocationX     = _random.Next(_maxX);
                    cell.LocationY     = _random.Next(_maxY);
                }
            }
        }