private void initialized(object sender, EventArgs a) { EvaluationNNParameter parameter = new EvaluationNNParameter( new float[] { 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f }, new float[] { 0.25f, 0.25f, 0.25f, 0.25f, 0.25f }); if (Setting is SinglePlaySetting) { SinglePlaySetting setting = Setting as SinglePlaySetting; Game = new TetrisGame(App.GetLogger()); Game.SetRenderer(DXPanel); Game.SetController(DXPanel.Controller); Game.TimerSpan = setting.FallInterval.Value; Game.RecordPlayDataEnabled = setting.RecordPlayDataEnabled.Value; Game.Start(); } else if (Setting is AIPlaySetting) { AIPlaySetting setting = Setting as AIPlaySetting; var p = EvaluationNNParameter.Load(typeof(EvaluationNNParameter), setting.AiTrainingFile.Value.DirectoryName, setting.AiTrainingFile.Value.Name) as EvaluationNNParameter; if (p != null) { parameter = p; } Evaluator evaluator = new Evaluator(parameter); Game = new TetrisGame(App.GetLogger()); Game.SetRenderer(DXPanel); Game.SetController(new AITetrisController(evaluator, setting.AiControllInterval.Value)); Game.TimerSpan = setting.FallInterval.Value; Game.RecordPlayDataEnabled = setting.RecordPlayDataEnabled.Value; Game.Start(); } else if (Setting is RePlaySetting) { RePlaySetting setting = Setting as RePlaySetting; GamePlayData playdata = (GamePlayData)GamePlayData.Load(typeof(GamePlayData), setting.PlayDataFile.Value.DirectoryName, setting.PlayDataFile.Value.Name); Game = new TetrisGame(App.GetLogger(), 10, 20, playdata.ObjectPool, playdata.ObjectQueue); Game.SetRenderer(DXPanel); Game.SetController(new ReplayController(playdata.Events)); Game.Start(); } //Game = new TetrisGame(TetrisPlayer.GetLogger(),10,20,playdata.ObjectPool,playdata.ObjectQueue); }
private void initialized(object sender, EventArgs a) { EvaluationNNParameter parameter = new EvaluationNNParameter( new float[] { 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f }, new float[] { 0.25f, 0.25f, 0.25f, 0.25f, 0.25f }); string path = "parameters"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var p = EvaluationNNParameter.Load(typeof(EvaluationNNParameter), path, "params.xml") as EvaluationNNParameter; if (p != null) { parameter = p; } Evaluator evaluator = new Evaluator(parameter); GamePlayData playdata = (GamePlayData)GamePlayData.Load(typeof(GamePlayData), "playdata", "data.xml"); //Game = new TetrisGame(TetrisPlayer.GetLogger(),10,20,playdata.ObjectPool,playdata.ObjectQueue); Game = new TetrisGame(TetrisPlayer.GetLogger()); foreach (Control c in this.Controls) { if (c is IRenderer) { TetrisPlayer.GetLogger().Info("Find a Renderer:" + c.GetType().Name); Game.SetRenderer((IRenderer)c); Game.SetController((IController) new AITetrisController(evaluator, 100)); //Game.SetController((IController)new ReplayController(playdata.Events)); } } Game.RecordPlayDataEnabled = false; Game.Start(); }