Skip to content
Snippets Groups Projects
Commit c94749b2 authored by Tessaris Sergio's avatar Tessaris Sergio
Browse files

added blind player to examples

parent 01b75411
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
import json
import random
import sys
import wumpus as wws
......@@ -86,16 +87,40 @@ def play_fixed(world_json: str = WUMPUS_WORLD):
world.run_episode(hunter, MyPlayer.player(world=world, agent=hunter))
EXAMPLES = (play_classic, play_classic_informed, play_fixed)
def real_deal(size: int = 0):
"""Play the classic version of the wumpus without being able to see the actual layout, that is as the actual software agent will do."""
# create the world
world = wws.WumpusWorld.classic(size=size if size > 3 else random.randint(4, 8))
# get the hunter agent
hunter = next(iter(o for o in world.objects if isinstance(o, wws.Hunter)), None)
# Run a player without any knowledge about the world
world.run_episode(hunter, wws.UserPlayer.player(), show=False)
EXAMPLES = (play_classic, play_classic_informed, play_fixed, real_deal)
def main(*args):
# Randomly play one of the examples
ex = random.choice(EXAMPLES)
ex_names = {ex.__name__.lower(): ex for ex in EXAMPLES}
ex = None
if len(args) > 0:
ex_name = args[0]
if ex_name.lower() in ex_names:
ex = ex_names[ex_name.lower()]
else:
print('Example {} not among the available {}'.format(ex_name, list(ex_names.keys())))
return -1
else:
# Randomly play one of the examples
ex = random.choice(EXAMPLES)
print('Example {}:'.format(ex.__name__))
print(' ' + ex.__doc__)
ex()
return 0
if __name__ == "__main__":
main()
sys.exit(main(*sys.argv[1:]))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment