public Simulator(SimulationParameters parameters, ILevelGenerator levelGenerator, IAiFactory aiFactory, Int32 initialLevelSeed) { Parameters = parameters ?? throw new ArgumentNullException(nameof(parameters)); LevelGenerator = levelGenerator ?? throw new ArgumentNullException(nameof(levelGenerator)); AiFactory = aiFactory ?? throw new ArgumentNullException(nameof(aiFactory)); _lastLevelSeed = initialLevelSeed - 1; }
private async void SimulateButton_Click(object sender, EventArgs e) { if (!running) { running = true; } else { return; } if (!Int32.TryParse(RunCount.Text, out Int32 runCount)) { return; } if (_workManager == null) { _workManager = new WorkManager(SimulationParameters.Default); } List <IAiFactory> selectedAis = _aiFactories.Where(t => AiList.SelectedItems.ContainsKey(t.Name)).ToList(); ILevelGenerator selectedLevelGenerator = _levelGenerators[LevelGeneratorName.Text]; var progress = new Progress <Int32>(UpdateProgress); _completedCount = 0; _stopwatch.Reset(); UpdateStatus(); Timer.Start(); _stopwatch.Start(); (var results, var worstSim, var worstAi) = await _workManager.Simulate(selectedAis, selectedLevelGenerator, runCount, progress); _stopwatch.Stop(); Timer.Stop(); UpdateStatus(); _renderSim = worstSim; _renderAiFactory = worstAi; if (_renderSim != null && _renderSim.HasError) { MessageBox.Show("ERROR"); } foreach (var aiFactory in results.Keys) { var stat = results[aiFactory]; if (Results.Rows.Count == 0) { DataGridViewRow row = new DataGridViewRow(); Results.Rows.Add(row); } (var meanMoves, var meanPower, var meanSamples, var sampleStdDev) = stat; Results.Rows[0].SetValues(aiFactory.Name, meanMoves.ToString("F2"), meanPower.ToString("F2"), meanSamples.ToString("F2"), sampleStdDev.ToString("F2")); } running = false; }
// Start is called before the first frame update void Start() { playerObject = Instantiate(playerPrefab); enemyObject = Instantiate(enemyPrefab); _inputHandler = new InputHandler(); _inputHandler.InputInit(); _player = new Player(playerObject); _powerUpPool = new ObjectPool <PowerUp>(); _levelGeneration = new LevelGeneration(_player, _powerUpPool) as ILevelGenerator; _score = new PointCounter(); powerUpManager = new PowerUpManager(); //powerUpManager.createRandomPowerUp(Instantiate(PowerUpPrefab).transform); _enemyStateMachine = new EnemyFSM(); _enemyStateMachine.AddState(EnemyStateType.Idle, new IdleState()); _enemyStateMachine.AddState(EnemyStateType.Attack, new AttackState()); _levelGeneration = new LevelGeneration() as ILevelGenerator; _randomCoordinate = new RandomCoordinate(_levelGeneration); _pathfinder = new Pathfinder2(_levelGeneration); }
internal IObservable <Unit> Simulate(IReadOnlyList <IAiFactory> aiFactories, ILevelGenerator levelGenerator, Int32 runCount) { return(Observable.StartAsync(() => { return SimulateAsync(aiFactories, levelGenerator, runCount); })); }
public void GenerateLevel() { // levelGenerator = new SimpleGenerator(10, enemyPool, enemySpawnPoint); _levelGenerator = new SimpleGenerator(); _levelSettings = _levelGenerator.Generate(); // spawn Ball SpawnBall(); }
void Awake() { RocketLauncher = new RocketLaunchSystem(this); RocketTypes = GetComponent <RocketTypeManager>(); levelGenerator = GetComponent <LevelGenerator>(); PlanetMaterials = GetComponent <MaterialsStore>(); UI_Controller = GetComponent <UIController>(); PrepareGameProcess(); }
public void Generate(ILevelGenerator levelGenerator, ICrystalGenerator crystalGenerator) { this.levelGenerator = levelGenerator; this.crystalGenerator = crystalGenerator; Clear(); levelGenerator.Clear(); GenerateNext(); }
private void Awake() { algorithm = new LevelGeneratorAlgorithm(); rotators = new List <ArrowHintRotator>(); items = new List <ItemAnimator>(); colors = new List <Color> { Color.red, Color.green, Color.blue, Color.yellow, Color.white, Color.magenta }; sphereRadius = spherePrefab.GetComponent <SphereCollider>().radius; }
public void Generate(ILevelGenerator levelGenerator, ICrystalGenerator crystalGenerator) { this.levelGenerator = levelGenerator; this.crystalGenerator = crystalGenerator; //Чистим предыдущий уровень Clear(); levelGenerator.Clear(); GenerateNext(); }
/// <summary> /// setup brick by lase level settings /// </summary> public void RestartLastLevel() { // levelGenerator = new SimpleGenerator(10, enemyPool, enemySpawnPoint); if (_levelGenerator == null) { _levelGenerator = new SimpleGenerator(); } _levelGenerator.ResetLevel(_levelSettings); // reset settings in Ball or spawn a new one SpawnBall(); }
public BeginGameState(IRoot root, ILevelGenerator levelGenerator, ITurnSystem turnSystem, IMatchSystem matchSystem, IGameplayController gameplayController, IScoreSystem scoreSystem) { this.root = root; this.levelGenerator = levelGenerator; this.turnSystem = turnSystem; this.matchSystem = matchSystem; this.gameplayController = gameplayController; this.scoreSystem = scoreSystem; }
public GameMaker(int rowCount, int rowWidth, int groundFrom, int groundTo, GameObject player, ILevelGenerator levelGenerator, IGameRules gameRules, IWorldCreator worldCreator) { _rowCount = rowCount; _rowWidth = rowWidth; _groundFrom = groundFrom; _groundTo = groundTo; _worldCreator = worldCreator; _player = player; _levelGenerator = levelGenerator; _gameRules = gameRules; Debug.Log("New game, GameMaker constructor."); }
public bool TryGenerateNextLevel() { if (_levelGenerators.Count <= 0) { return(false); } _currentLevel = _levelGenerators.Dequeue(); _bricksOnLevel = _currentLevel.GenerateLevel(); foreach (var brick in _bricksOnLevel) { brick.BrickDestroyed += OnBrickDestroy; } return(true); }
// Start is called before the first frame update void Start() { _winScreen.gameObject.SetActive(false); _playerObject = Instantiate(_playerPrefab); _inputHandler = new InputHandler(); _inputHandler.InputInit(); _player = new Player(_playerObject); _powerUpPool = new ObjectPool <PowerUp>(); _levelGeneration = new LevelGeneration(_player, _powerUpPool) as ILevelGenerator; _score = new PointCounter(); _powerUpManager = new PowerUpManager(); _enemyStateMachine = new EnemyFSM(); _enemyStateMachine.AddState(EnemyStateType.Idle, new IdleState()); _enemyStateMachine.AddState(EnemyStateType.Attack, new AttackState()); _randomCoordinate = new RandomCoordinate(_levelGeneration); _pathfinder = new Pathfinder2(_levelGeneration); }
internal async Task SimulateAsync(IReadOnlyList <IAiFactory> aiFactories, ILevelGenerator levelGenerator, Int32 runCount) { SimulationParameters parameters = SimulationParameters.Default; Int32 initialLevelSeed = LevelSeed; var tasks = new List <Task>(aiFactories.Count); var results = new Dictionary <IAiFactory, List <CompletedSimulation> >(aiFactories.Count); foreach (var aiFactory in aiFactories) { var simulator = new Simulator(parameters, levelGenerator, aiFactory, initialLevelSeed); results[aiFactory] = new List <CompletedSimulation>(runCount); tasks.Add(simulator.SimulateAsync(runCount, sim => results[aiFactory].Add(sim))); } await Task.WhenAll(tasks); foreach (var ai in aiFactories) { Simulations.AddRange(results[ai].Select(sim => new SimulationRowViewModel(ai, sim))); } LevelSeed += runCount; }
public ProtoLevel(SimulationParameters parameters, ILevelGenerator levelGenerator, Int32 seed) { Parameters = parameters ?? throw new ArgumentNullException(nameof(parameters)); LevelGenerator = levelGenerator ?? throw new ArgumentNullException(nameof(levelGenerator)); Seed = seed; }
public Pathfinder2(ILevelGenerator para) { _iLevelGenerator = para; //_pathNode.coordinateNode = pathCoordinate; }
public OpenCheckingGenerator(ILevelGenerator wrappedGenerator, Int32 minimumContiguousTiles) { _wrappedGenerator = wrappedGenerator ?? throw new ArgumentNullException(nameof(wrappedGenerator)); MinimumContiguousTiles = minimumContiguousTiles >= 0 ? minimumContiguousTiles : throw new ArgumentOutOfRangeException(nameof(minimumContiguousTiles)); }
internal async Task <(Dictionary <IAiFactory, (Double meanMoves, Double meanPower, Double meanSamples, Double sampleStdDev)> aggregates, CompletedSimulation worstSim, IAiFactory worstAi)> Simulate(IList <IAiFactory> aiFactories, ILevelGenerator levelGenerator, Int32 runCount, IProgress <Int32> progress) { var aggregates = new Dictionary <IAiFactory, (Double meanMoves, Double meanPower, Double meanSamples, Double sampleStdDev)>(); Int32 initialLevelSeed = NextLevelSeed; CompletedSimulation worstSim = null; IAiFactory worstAi = null; foreach (var aiFactory in aiFactories) { var simulator = new Simulator(Parameters, levelGenerator, aiFactory, initialLevelSeed); using Completer completer = Completer.Create(Path.Combine(OutputDirectory, $"RoverSim-{aiFactory.Name}.csv"), progress); await simulator.SimulateAsync(runCount, completer.Consume); NextLevelSeed = simulator.NextLevelSeed; aggregates[aiFactory] = completer.GetAggregates(); worstSim = Completer.ChooseWorst(worstSim, completer.WorstSim); if (worstSim == completer.WorstSim) { worstAi = aiFactory; } } return(aggregates, worstSim, worstAi); }
/// <summary> /// Applies a ILevelGenerators's generate function to a NodeGrid /// </summary> /// <param name="generator">A instantiated level generator (ILevelGenerator) object</param> public void ApplyGenerator(ILevelGenerator generator) { generator.Generate(this); }
public RandomCoordinate(ILevelGenerator para) { _ILevelGenerator = para; }