Esempio n. 1
0
        private void _maze_AgentStateChanged(object sender, QLearning.Core.AgentStateChangedEventArgs e)
        {
            int position = e.NewState % _agentPrimary.Environment.StatesPerPhase;
            var newSpace = _mazeSpace.GetSpaceByPosition(position);

            if (newSpace != null)
            {
                if (MazeSpace.ActiveSpacePrimary != null)
                {
                    MazeSpace.ActiveSpacePrimary.SetInactive();
                    MazeSpace.ActiveSpacePrimary.Invalidate();
                }

                MazeSpace.ActiveSpacePrimary = newSpace;

                var start = _mazeSpace.GetSpaceByPosition(_episodeStartSpace % _agentPrimary.Environment.StatesPerPhase);
                start.SetInactive();
                start.Invalidate();

                if (_agentPrimary.Environment.RewardsTable[e.NewState][_agentPrimary.Environment.GetRewardAction] > 0)
                {
                    newSpace.SetReward(false);
                }

                newSpace.SetActive();
                newSpace.Invalidate();
                _mazeSpace.Invalidate();
                newSpace.Refresh();
                _mazeSpace.Refresh();
                System.Threading.Thread.Sleep(_movementPause);
            }
        }
Esempio n. 2
0
        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);
        }