add Node from Queue into list but its makes infinite loop

29 views Asked by At

I have the maze:

enter image description here

I want to add Node (state, action) from Queue into states = [] without popup all Node in Queue

count = 0
max_element = queue.count()
        for node in queue.queue_to_add_again():
            if count < max_element:
                states.append((node.state, node.action))
                queue.add(node)
                count += 1
            else:
                break

I have problem with infinite loop and cannot solve this maze. Someone can help me?

queue.count():

def count(self):
    return len(self.queue)

queue.queue_to_add_again():

def queue_to_add_again(self):
    return self.queue
0

There are 0 answers