コード例 #1
0
            public void PickObservation(out int index, out int pattern)
            {
                var topology = propagator.Topology;
                var t        = edgedPathView.PathSelectedTracker;
                // Find cells that could potentially be paths, and are next to
                // already selected path. In tileSpace
                var tilePriority = Enumerable.Range(0, topology.IndexCount).Select(i =>
                {
                    if (!topology.ContainsIndex(i))
                    {
                        return(-1);
                    }
                    var qs = t.GetQuadstate(i);
                    if (qs.IsYes())
                    {
                        return(2);
                    }
                    if (qs.IsNo())
                    {
                        return(0);
                    }
                    // Determine if any neighbours exit onto this tile
                    for (var d = 0; d < topology.DirectionsCount; d++)
                    {
                        if (topology.TryMove(i, (Direction)d, out var i2, out var inverseDirection, out var _))
                        {
                            if (edgedPathView.TrackerByExit.TryGetValue(inverseDirection, out var tracker))
                            {
                                var s2 = tracker.GetQuadstate(i2);
                                if (s2.IsYes())
                                {
                                    return(1);
                                }
                            }
                        }
                    }
                    return(0);
                }).ToArray();

                var patternPriority = tileModelMapping.PatternCoordToTileCoordIndexAndOffset == null ? tilePriority : throw new NotImplementedException();

                index = randomPicker.GetRandomIndex(randomDouble, patternPriority);

                if (index == -1)
                {
                    fallbackHeuristic.PickObservation(out index, out pattern);
                    propagator.Topology.GetCoord(index, out var x, out var y, out var z);
                }
                else
                {
                    propagator.Topology.GetCoord(index, out var x, out var y, out var z);
                    pattern = randomPicker.GetRandomPossiblePatternAt(index, randomDouble);
                }
            }
コード例 #2
0
 public void PickObservation(out int index, out int pattern)
 {
     // Choose a random cell
     index = randomPicker.GetRandomIndex(randomDouble);
     if (index == -1)
     {
         pattern = -1;
         return;
     }
     // Choose a random pattern
     pattern = randomPicker.GetRandomPossiblePatternAt(index, randomDouble);
 }