Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add_fluents(self, turn):
- """ Called once per turn, this adds all 'fluents' for example,
- haveArrow[t+1] = haveArrow[t] OR shoot_act[t] """
- turn += 1
- breeze_perc.append(Bool("br_perc_%s" % (turn)))
- stench_perc.append(Bool("st_perc_%s" % (turn)))
- scream_perc.append(Bool("sc_perc_%s" % (turn)))
- glitter_perc.append(Bool("gl_perc_%s" % (turn)))
- bump_perc.append(Bool("bu_perc_%s" % (turn)))
- move_act.append(Bool("m_act_%s" % (turn)))
- right_act.append(Bool("r_act_%s" % (turn)))
- left_act.append(Bool("l_act_%s" % (turn)))
- shoot_act.append(Bool("s_act_%s" % (turn)))
- north.append(Bool("N_%s" % (turn)))
- east.append(Bool("E_%s" % (turn)))
- west.append(Bool("W_%s" % (turn)))
- south.append(Bool("S_%s" % (turn)))
- wumpus_alive.append(Bool("WumpusAlive_%s" % (turn)))
- have_arrow.append(Bool("HaveArrow_%s" % (turn)))
- tmp_loc = [[Bool("L_%s_%s_%s" % (turn, i + 1, j + 1)) for j in range(8)] for i in range(8)]
- tmp_ok = [[Bool("OK_%s_%s_%s" % (turn, i + 1, j + 1)) for j in range(8)] for i in range(8)]
- for thing in [tmp_loc, tmp_ok]:
- for row in thing:
- row.insert(0, row[1])
- row.append(row[-2])
- thing.insert(0, thing[1])
- thing.append(thing[-2])
- locations.append(tmp_loc)
- ok.append(tmp_ok)
- self.s.add(have_arrow[turn] == And(have_arrow[turn - 1], Not(shoot_act[turn - 1])))
- self.s.add(wumpus_alive[turn] == And(wumpus_alive[turn-1], Not(scream_perc[turn])))
- for x in range(1,9):
- for y in range(1,9):
- self.s.add(ok[turn][x][y] == And(Not(pits[x][y]), Not(And(wumpuses[x][y], wumpus_alive[turn]))))
- self.s.add(Implies(locations[turn][x][y], breeze_perc[turn] == breezes[x][y]))
- self.s.add(Implies(locations[turn][x][y], stench_perc[turn] == stenches[x][y]))
- # For current location:
- self.s.add(locations[turn][x][y] == Or(And(locations[turn-1][x][y], Or(Not(move_act[turn-1]),
- bump_perc[turn])),
- And(locations[turn-1][x-1][y], east[turn-1], move_act[turn-1],
- Not(bump_perc[turn])),
- And(locations[turn-1][x+1][y], west[turn-1], move_act[turn-1],
- Not(bump_perc[turn])),
- And(locations[turn-1][x][y-1], north[turn-1], move_act[turn-1],
- Not(bump_perc[turn])),
- And(locations[turn-1][x][y+1], south[turn-1], move_act[turn-1],
- Not(bump_perc[turn]))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement