def greedy(self, wrld, exit, meX, meY):
        # Complete the greedy algorithm
        # Get the [x,y] coords of the next cell to go to
        goTo = greedyBFS.getNextStep([meX, meY], exit, wrld)

        #move in direction to get to x,y found in prev step
        self.move(-meX + goTo[0], -meY + goTo[1])
    def greedy(self, wrld, exit, meX, meY):
        # Returns true if the character can be moved, false if not

        # Complete the greedy algorithm
        # Get the [x,y] coords of the next cell to go to
        goTo = greedyBFS.getNextStep([meX, meY], exit, wrld)

        #move in direction to get to x,y found in prev step
        self.move(-meX + goTo[0], -meY + goTo[1])

        if not greedy:
            # TODO: Improve bomb placement and pathfinding combinations
            goTo = greedyBFS.getNextStep([meX, meY], exit, wrld, 0)
            if wrld.wall_at(goTo[0], goTo[1]):
                NotSetThisTime = False
                self.place_bomb()
            else:
                self.move(-meX + goTo[0], -meY + goTo[1])
Esempio n. 3
0
    def do(self, wrld):
        # Your code here
        exit = [0, 0]
        #get current position
        meX = wrld.me(self).x
        meY = wrld.me(self).y

        #check every gridcell for the exit. Uses the last exit found as the "goal"
        for i in range(wrld.width()):

            for j in range(wrld.height()):

                if wrld.exit_at(i, j):
                    exit = [i, j]

        #get the [x,y] coords of the next cell to go to
        goTo = greedyBFS.getNextStep([meX, meY], exit, wrld)

        #move in direction to get to x,y found in prev step
        self.move(-meX + goTo[0], -meY + goTo[1])
Esempio n. 4
0
    def greedy(self, wrld, exit, meX, meY):
        # Returns true if the character can be moved, false if not

        # Complete the greedy algorithm
        # Get the [x,y] coords of the next cell to go to
        goTo = greedyBFS.getNextStep([meX, meY], exit, wrld)

        if goTo[0] == exit[0] and goTo[1] == exit[1]:
            print("Threw that")
            raise ValueError

        if goTo is None:
            # TODO: Improve bomb placement and pathfinding combinations
            goTo = conn4.getNextStep([meX, meY], exit, wrld)
            if wrld.wall_at(goTo[0],goTo[1]):
                self.place_bomb()
            else:
                self.move(-meX + goTo[0], -meY + goTo[1])
        else:
            #move in direction to get to x,y found in prev step
            self.move(-meX + goTo[0], -meY + goTo[1])