Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Syntax conflicts in search.py (tuples are used as functions!) #824

Closed
@goswami-rahul

Description

@goswami-rahul

In the function actions() inside search.py, the variable index_blank_square is a tuple of indices, but called as a function like index_blank_square(0) or index_blank_square(1).

def actions(self, state):
        """Return the actions that can be executed in the given state.
        The result would be a list, since there are only four possible actions
        in any given state of the environment."""
       
        possible_actions = list()
        index_blank_square = self.find_blank_square(state)

        if index_blank_square(0) == 0:
            possible_actions += ['DOWN']
        elif index_blank_square(0) == 1:
            possible_actions += ['UP', 'DOWN']
        elif index_blank_square(0) == 2:
            possible_actions += ['UP']
        
        if index_blank_square(1) == 0:
            possible_actions += ['RIGHT']
        elif index_blank_square(1) == 1:
            possible_actions += ['LEFT', 'RIGHT']
        elif index_blank_square(1) == 2:
            possible_actions += ['LEFT']

        return possible_actions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions