private Task RunAgent(MazeAgent agent) { try { agent.Run(agent.StartPosition); } catch (Exception ex) { string agentVal = agent == PrimaryAgent ? "Primary" : "Secondary"; MessageBox.Show($"Error with {agentVal} Agent: {ex.Message}"); } return(Task.CompletedTask); }
private Task RunAgentAsync(MazeAgent agent) { try { agent.Run(agent.StartPosition); } catch (Exception ex) { string prefix; if (agent == _agentPrimary) { prefix = "Primary"; } else { prefix = "Secondary"; } MessageBox.Show($"{prefix} Agent Error: {ex.Message}"); } return(Task.CompletedTask); }
private void RenderTraining() { _mazeSpace = new MazeSpace(); _mazeSpace.CreateMazeControls(_agentPrimary.Environment); _mazeSpace.GetSpaceByPosition(_agentPrimary.StartPosition).SetStart(false); _mazeSpace.GetSpaceByPosition(_episodeStartSpace % _agentPrimary.Environment.StatesPerPhase).SetStart(true); Form frm = new Form(); frm.Size = _mazeSpace.Size = new Size(_mazeSpace.Width + 10, _mazeSpace.Height + 10); frm.Controls.Add(_mazeSpace); _mazeSpace.Dock = DockStyle.Fill; frm.Controls.Add(_mazeSpace); frm.Show(); frm.WindowState = FormWindowState.Maximized; frm.FormBorderStyle = FormBorderStyle.None; try { _agentPrimary.AgentStateChanged += _maze_AgentStateChanged; _agentPrimary.Run(_episodeStartSpace); } catch { //MessageBox.Show(ex.ToString()); } finally { _mazeSpace.Dispose(); _mazeSpace = null; frm.Dispose(); frm = null; _agentPrimary.AgentStateChanged -= _maze_AgentStateChanged; } }