private void ChangeGoalPosition(int newGoal) { var space = MazeVm.GetSpaceByPosition(MazeVm.Maze.GoalPosition); if (space != null) { space.IsGoal = false; } space = MazeVm.GetSpaceByPosition(newGoal); space.IsGoal = true; MazeVm.Maze.GoalPosition = newGoal; if (PrimaryAgent.Environment == null) { PrimaryAgent.Environment = new MazeBase(MazeVm.Columns, MazeVm.Rows, PrimaryAgent.StartPosition, newGoal, 200); PrimaryAgent.Environment.Initialize(); SecondaryAgent.Environment = MazeUtilities.CopyEnvironment(PrimaryAgent.Environment); } else { PrimaryAgent.Environment.GoalPosition = newGoal; SecondaryAgent.Environment.GoalPosition = newGoal; } }
private void EditObjectives() { var vm = new CustomObjectivesViewModel(PrimaryAgent.Environment); vm.InitializeObjectives(); Views.CustomObjectivesView dialog = new Views.CustomObjectivesView(); dialog.DataContext = vm; var result = dialog.ShowDialog(); if (result.HasValue && result.Value) { if (PrimaryAgent.Environment != MazeVm.Maze) { PrimaryAgent.Environment = (MazeBase)MazeVm.Maze; } PrimaryAgent.Environment.AdditionalRewards.Clear(); foreach (var objective in vm.Objectives) { PrimaryAgent.Environment.AddReward(objective); } if (SecondaryAgent != null) { SecondaryAgent.Environment = MazeUtilities.CopyEnvironment(PrimaryAgent.Environment); } MazeVm.InitializeMaze(); } }
private void ChangeStartPosition(MazeAgent agent, int newStart) { var space = MazeVm.GetSpaceByPosition(agent.StartPosition); space.IsStart = false; agent.StartPosition = newStart; space = MazeVm.GetSpaceByPosition(agent.StartPosition); space.IsStart = true; MazeVm.SetActiveState(newStart, agent == PrimaryAgent); }
private void AgentStateChanged(object sender, QLearning.Core.AgentStateChangedEventArgs e) { bool isPrimary = sender == _primaryAgent; MazeVm.SetActiveState(e.NewState, isPrimary); if (isPrimary) { PrimaryAgentResultsVisibility = Visibility.Visible; PrimaryAgentResultsMoves = e.MovesMade; PrimaryAgentResultsScore = e.RewardsEarned; } else { SecondaryAgentResultsVisibility = Visibility.Visible; SecondaryAgentResultsMoves = e.MovesMade; SecondaryAgentResultsScore = e.RewardsEarned; } System.Threading.Thread.Sleep(200); }