Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello there! question regarding project 0 (degree.py) #1

Open
blinkomaniak opened this issue Aug 24, 2023 · 1 comment
Open

Hello there! question regarding project 0 (degree.py) #1

blinkomaniak opened this issue Aug 24, 2023 · 1 comment

Comments

@blinkomaniak
Copy link

Hello fellow
Thanks for posting your solutions

I took a look on the degree.py solution. In the shortest_path function, the code segment:

        if node.state == target:
            rt = []

            while node.parent is not None:
                rt.append((node.action, node.state))
                node = node.parent

            rt.reverse()
            return rt

is it necessary? I run with that segment commented and I think it is working pretty well without it taking in consideration that the same validation is done inside the for loop. I am just asking to learn. Thanks in advance.

@Mojtaba-Heravi
Copy link

Hello fellow Thanks for posting your solutions

I took a look on the degree.py solution. In the shortest_path function, the code segment:

        if node.state == target:
            rt = []

            while node.parent is not None:
                rt.append((node.action, node.state))
                node = node.parent

            rt.reverse()
            return rt

is it necessary? I run with that segment commented and I think it is working pretty well without it taking in consideration that the same validation is done inside the for loop. I am just asking to learn. Thanks in advance.

Hello blinkomaniak,
You say true. If you see this part of code that you mentioned, at the beginning of the while loop had to use it and check this condition for terminate, but in this part (# add neighbours to frontier) you don't need it repeat again. so, you can remove from code for have a clean code.
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants