最多一个wumpus:wumpus AI项目

2024-09-24 22:31:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法将带'&;的联接与列表操作数一起使用。任何帮助都将不胜感激!你知道吗

def axiom_generator_at_most_one_wumpus(xmin, xmax, ymin, ymax):
    """
    Assert that there is at at most one Wumpus.

    xmin, xmax, ymin, ymax := the bounds of the environment.
    """

    axiom_str = ''
    options = []
    for x in range(xmin, xmax+1):
        for y in range(ymin, ymax+1):
            option = wumpus_str(x,y) + " >> ("
            notWumps = []
            for xtemp in range(xmin, xmax+1):
                for ytemp in range(ymin, ymax+1):
                    if xtemp != x and ytemp != y:
                        notWumps.append('~' + wumpus_str(xtemp,ytemp))
            option += ' & '.join(notWumps)
            option += ')'
            options.append(option)
    axiom_str += ' & '.join(options)
    return axiom_str

Tags: inforrangeatoptionsoptionxminymax