<jupyter_start><jupyter_text>Pruebas<jupyter_code>import heapq
import math
import sys
from collections import defaultdict, deque, Counter
from itertools import combinations
FIFOQueue = deque

LIFOQueue = list

class PriorityQueue:
    """A queue in which the item with minimum f(item) is always popped first."""

    def __init__(self, items=(), key=lambda x: x): 
        self.key = key
        self.items = [] # a heap of (score, item) pairs
        for item in items:
            self.add(item)
         
    def add(self, item):
        """Add item to the queuez."""
        pair = (self.key(item), item)
        heapq.heappush(self.items, pair)

    def pop(self):
        """Pop and return the item with min f(item) value."""
        return heapq.heappop(self.items)[1]
    
    def top(self): return self.items[0][1]

    def __len__(self): return len(self.items)
def best_first_search(problem, f):
    "Search nodes with minimum f(node) value first."
    node = Node(problem.initial)
    frontier = PriorityQueue([node], key=f)
    reached = {problem.initial: node}
    while frontier:
        node = frontier.pop()
        if problem.goal_test(node.state):
            return node
        for child in node.expand(problem):
            s = child.state
            if s not in reached or child.path_cost < reached[s].path_cost:
                reached[s] = child
                frontier.add(child)
    return failure

def g(n): return n.path_cost

def uniform_cost_search(problem):
    "Search nodes with minimum path cost first."
    return best_first_search(problem, f=g)

laberinto=toymaze()
goal=State(5,0,'O')
#coordenadas son(x=filas,y=columnas)
state0=State(5,5,'N')
statef=goal
problema=Laberinto(state0,statef,laberinto)
ucs=uniform_cost_search(problema)
print(ucs.solution())<jupyter_output>['girard', 'avanzar', 'avanzar', 'girard', 'avanzar', 'avanzar', 'girari', 'avanzar', 'avanzar', 'girari', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'girari', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'girari', 'avanzar', 'avanzar', 'avanzar', 'avanzar', 'girard', 'avanzar']
{'fraction_non_alphanumeric': 0.14013921113689096, 'fraction_numerical': 0.004176334106728539, 'mean_word_length': 3.501043841336117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '534490', 'license': 'MIT', 'n_tokens_mistral': 761, 'n_tokens_neox': 741, 'n_words': 190, 'path': 'frand(1).ipynb', 'repo_name': 'FranciscoAquinoFlores/Clase_IA_aima-python', 'size': '2155'}