Пример #1
0
 public void OnMoveTo(int newPosY, int newPosX)
 {
     AxonWayPoints[0] = new NeuronAxonWaypoint(1, this, new Point(newPosX, newPosY));
     if (Type == NeuronType.Output)
     {
         AxonTerminal = AxonWayPoints[0].Waypoint;
     }
 }
Пример #2
0
        private bool ProcessGuideAxon()
        {
            NeuronAxonWaypoint lastAxonWaypoint = AxonWayPoints.Last();
            Point lastMaxLocation = lastAxonWaypoint.Waypoint;

            Point  maxLocation;
            double maxScore;
            var    guidanceForceScores =
                AxonGuidanceForces.Select
                    (axonGuidanceForce => new GuidanceForceScoreEventArgs(axonGuidanceForce,
                                                                          lastMaxLocation.Y, lastMaxLocation.X, this,
                                                                          axonGuidanceForce.GetScore(lastMaxLocation.Y, lastMaxLocation.X, this))).ToArray();

            var guidanceForceScoresSum = guidanceForceScores.Select(guidanceForceScore => guidanceForceScore.Score).Sum();

            IEnumerable <Point> maxLocations;

            guidanceForceScoresSum.GetMaxAndLocation(out maxLocations, out maxScore);

            bool result = false;

            if (maxScore > 0)
            {
                maxLocation = maxLocations.ElementAt(_random.Next(maxLocations.Count()));

                maxLocation = new Point
                                  (Math.Min(Math.Max(maxLocation.X - Network.AxonGuidanceForceSearchPlainRange + lastMaxLocation.X, 0), Network.Width - 1),
                                  Math.Min(Math.Max(maxLocation.Y - Network.AxonGuidanceForceSearchPlainRange + lastMaxLocation.Y, 0), Network.Height - 1));

                double lastMaxLocationScore = AxonGuidanceForces.Select(axonGuidanceForce => axonGuidanceForce.ComputeScoreAtLocation(lastMaxLocation.X, lastMaxLocation.Y, this)).Sum();

                if (maxScore > lastMaxLocationScore ||
                    AxonWayPoints.Count == 1)
                {
                    var newAxonWaypoint = new NeuronAxonWaypoint(lastAxonWaypoint.Id + 1, this, maxLocation);
                    AxonWayPoints.Add(newAxonWaypoint);
                    Network.NeuronAxonWayPoints[maxLocation.Y, maxLocation.X] = newAxonWaypoint;
                    result = true;
                }

                InvokeAxonGuidanceForcesScoreEvent(guidanceForceScores);
                InvokeAxonGuidanceForcesSumEvent(guidanceForceScoresSum);
            }

            return(result);
        }
Пример #3
0
        private bool ProcessGuideAxon()
        {
            NeuronAxonWaypoint lastAxonWaypoint = AxonWayPoints.Last();
            Point lastMaxLocation = lastAxonWaypoint.Waypoint;

            Point maxLocation;
            double maxScore;
            var guidanceForceScores =
                AxonGuidanceForces.Select
                (axonGuidanceForce => new GuidanceForceScoreEventArgs(axonGuidanceForce,
                    lastMaxLocation.Y, lastMaxLocation.X, this,
                    axonGuidanceForce.GetScore(lastMaxLocation.Y, lastMaxLocation.X, this))).ToArray();

            var guidanceForceScoresSum = guidanceForceScores.Select(guidanceForceScore => guidanceForceScore.Score).Sum();

            IEnumerable<Point> maxLocations;
            guidanceForceScoresSum.GetMaxAndLocation(out maxLocations, out maxScore);

            bool result = false;
            if (maxScore > 0)
            {
                maxLocation = maxLocations.ElementAt(_random.Next(maxLocations.Count()));

                maxLocation = new Point
                    (Math.Min(Math.Max(maxLocation.X - Network.AxonGuidanceForceSearchPlainRange + lastMaxLocation.X, 0), Network.Width - 1),
                    Math.Min(Math.Max(maxLocation.Y - Network.AxonGuidanceForceSearchPlainRange + lastMaxLocation.Y, 0), Network.Height - 1));

                double lastMaxLocationScore = AxonGuidanceForces.Select(axonGuidanceForce => axonGuidanceForce.ComputeScoreAtLocation(lastMaxLocation.X, lastMaxLocation.Y, this)).Sum();

                if (maxScore > lastMaxLocationScore
                    || AxonWayPoints.Count == 1)
                {
                    var newAxonWaypoint = new NeuronAxonWaypoint(lastAxonWaypoint.Id + 1, this, maxLocation);
                    AxonWayPoints.Add(newAxonWaypoint);
                    Network.NeuronAxonWayPoints[maxLocation.Y, maxLocation.X] = newAxonWaypoint;
                    result = true;
                }

                InvokeAxonGuidanceForcesScoreEvent(guidanceForceScores);
                InvokeAxonGuidanceForcesSumEvent(guidanceForceScoresSum);
            }

            return result;
        }
Пример #4
0
 public void OnMoveTo(int newPosY, int newPosX)
 {
     AxonWayPoints[0] = new NeuronAxonWaypoint(1, this, new Point(newPosX, newPosY));
     if (Type == NeuronType.Output)
     {
         AxonTerminal = AxonWayPoints[0].Waypoint;
     }
 }