Example #1
0
    public static void End(Gold[] gbs, Action[] path, byte[][] states, GscTile startTile)
    {
        Console.WriteLine("Searching for end path...");
        DFParameters <Gold, GscTile> parameters = new DFParameters <Gold, GscTile>()
        {
            NoEncounterSS = 60,
            MaxCost       = 0,
            EndTiles      = new GscTile[] { r30[17, 12] },
            FoundCallback = state => {
                Console.WriteLine("Found an end path!!");
                endWriter.WriteLine(ActionFunctions.ActionsToPath(path) + " " + state.Log);
                endWriter.Flush();
            }
        };

        DepthFirstSearch.StartSearch(gbs, parameters, startTile, 0, states);
    }
Example #2
0
    static void Cherrygrove(Gold[] gbs, Action[] path, byte[][] states, GscTile startTile)
    {
        long cherryPathsFound          = 0;
        long numSeenPaths              = 0;
        HashSet <(int, int, int)> rngs = new HashSet <(int, int, int)>();

        while (numSeenPaths < 30)
        {
            GC.Collect();
            Console.WriteLine("Searching for cherrygrove path (" + cherryPathsFound + ")...");
            var ret = RandomPathSearch.StartSearch(gbs,
                                                   new RandomSearchParameters <GscTile>()
            {
                StateList = new List <byte[][]>()
                {
                    states
                },
                ClusterSize       = 1,
                SS                = 60,
                NumPathsToFind    = 1,
                StartEdgeSet      = 0,
                StartTile         = startTile,
                EndTiles          = new GscTile[] { r30[12, 46], r30[13, 46] },
                ExecutionCallback = (gb, actions) => gb.Execute(actions) == gb.OverworldLoopAddress,
            }).First();

            cherryPathsFound++;
            Action[]   actions = ret.Actions;
            IGTResults results = ret.Results[0];
            (int, int, int)rng = (results.MostCommonHRA, results.MostCommonHRS, results.MostCommonDivider);
            Action[] concatPath = path.Concat(actions).ToArray();
            cherrygroveWriter.WriteLine(ActionFunctions.ActionsToPath(concatPath));
            cherrygroveWriter.Flush();
            if (!rngs.Add(rng))
            {
                numSeenPaths++;
                continue;
            }
            else
            {
                numSeenPaths = 0;
            }
            gbs[0].LoadState(results.FirstState);
            End(gbs, concatPath, results.States, gbs[0].Tile);
        }
    }
Example #3
0
    public List <GscTile> Sight(GscMap map)
    {
        Action         dir     = ActionFunctions.FromSpriteDirection(Direction);
        List <GscTile> sight   = new List <GscTile>();
        GscTile        current = map[StandingMapX - 4, StandingMapY - 4];

        for (int j = 0; j < Range; j++)
        {
            current = current.GetNeighbor(dir);
            if (current == null)
            {
                break;
            }
            sight.Add(current);
        }

        return(sight);
    }
Example #4
0
    public override int WalkTo(int targetX, int targetY)
    {
        GscMap  map      = Map;
        GscTile current  = Tile;
        GscTile target   = map[targetX, targetY];
        GscWarp warp     = map.Warps[current.X, current.Y];
        bool    original = false;

        if (warp != null)
        {
            original     = warp.Allowed;
            warp.Allowed = true;
        }
        List <Action> path = Pathfinding.FindPath(map, current, 17, map.Tileset.LandPermissions, target);

        if (warp != null)
        {
            warp.Allowed = original;
        }
        return(Execute(path.ToArray()));
    }
Example #5
0
    static void R29(Gold[] gbs, byte[][] states, GscTile startTile)
    {
        HashSet <(int, int, int)> rngs = new HashSet <(int, int, int)>();

        while (true)
        {
            Console.WriteLine("Searching for r29 path...");
            var ret = RandomPathSearch.StartSearch(gbs,
                                                   new RandomSearchParameters <GscTile>()
            {
                StateList = new List <byte[][]>()
                {
                    states
                },
                ClusterSize       = 1,
                SS                = 60,
                NumPathsToFind    = 1,
                StartEdgeSet      = 0,
                StartTile         = startTile,
                EndTiles          = new GscTile[] { cherrygrove[33, 7] },
                ExecutionCallback = (gb, action) => gb.Execute(action) == gb.OverworldLoopAddress,
            }).First();

            Action[]   actions = ret.Actions;
            IGTResults results = ret.Results[0];
            (int, int, int)rng = (results.MostCommonHRA, results.MostCommonHRS, results.MostCommonDivider);
            r29Writer.WriteLine(ActionFunctions.ActionsToPath(ret.Actions));
            r29Writer.Flush();
            if (!rngs.Add(rng))
            {
                continue;
            }
            gbs[0].LoadState(results.FirstState);
            Cherrygrove(gbs, ret.Actions, results.States, gbs[0].Tile);
        }
    }