public Game[] Build(string inputFilename) { var games = new List<Game>(); var input = new InputReader().Read(inputFilename); var board = Board.CreateEmpty(input.height, input.width); foreach (var busyCell in input.filled) { board.Fill(busyCell.ToPoint()); } var units = input.units.Select(x => x.ToUnit()).ToArray(); foreach (var seed in input.sourceSeeds) { var generator = new RandomGenerator(seed); var unitSequence = generator.Generate().Select(x => units[x % units.Length]).Take(input.sourceLength).ToArray(); var game = new Game(board, null, unitSequence, 0, 0, 0, input.id, seed, string.Empty, 0); game = game.TrySpawnNew(); games.Add(game); } return games.ToArray(); }
public void TestGetNext() { var generator = new RandomGenerator(17); var actuals = generator.Generate().Take(10).ToArray(); CollectionAssert.AreEqual(new[] { 0, 24107, 16552, 12125, 9427, 13152, 21440, 3383, 6873, 16117 }, actuals); }