-1

I have a python script and I am receiving the following error:

File "C:\AIND\AIND-isolation\AIND-Isolation\game_agent.py", line 229, in minimax
  my_minimax(current_location, current_depth, max_depth)
  NameError: name 'my_minimax' is not defined

Here is the code that causes the problem:

class MinimaxPlayer(IsolationPlayer):

    def my_minimax(self, current_location, current_depth, max_depth):
        print("my_minimax")

    def minimax(self, game, depth):

        if self.time_left() < self.TIMER_THRESHOLD:
            raise SearchTimeout()

        # TODO: finish this function!
        legal_moves = game.get_legal_moves()

        if not legal_moves:
            return (-1, -1)

        _, move = max([(self.score(game.forecast_move(node), self), node)
                        for node in legal_moves])

        current_depth = 0
        max_depth = depth
        current_location = game.get_player_location(self)

        my_minimax(current_location, current_depth, max_depth)

        return move

I defined the function before I use it. Why can't the function be found?

KDB
  • 173
  • 1
  • 4
  • 12

1 Answers1

4

my_minimax is a method of MinimaxPlayer.

Call self.my_minimax(...)

Szabolcs Dombi
  • 5,493
  • 3
  • 39
  • 71