@@ -6,7 +6,7 @@ The package has been written to be used in the master course of AI taught at the
## Install
You can download the source code from <https://gitlab.inf.unibz.it/tessaris/wumpus> and use `pip install .` or installing directly from the repository using
You can download the source code from <https://gitlab.inf.unibz.it/tessaris/wumpus> and use `pip install .`, or install directly from the repository using
To write your own player you should create a subclass of `Player` (defined in [gridworld.py](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/wumpus/gridworld.py)) and then use an instance as a parameter of the `run_episode` method of `GridWorld` class (defined in [gridworld.py](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/wumpus/gridworld.py)). Instances of the `Player` subclasses should be created using its `player` class method, where you can decide whether to give the player access to the underlying environment or to rely on the state information provided by the `play` method.
To write your own player you should create a subclass of `Player` (defined in [gridworld.py](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/wumpus/gridworld.py)) and then use an instance as a parameter of the `run_episode` method of `GridWorld` class (defined in [gridworld.py](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/wumpus/gridworld.py)).
Examples of the usage of the package can be found in the implementation of two players `RandomPlayer` and `UserPlayer` from [gridworld.py](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/wumpus/gridworld.py), and in the file [`wumpus-usage.py`](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/examples/wumpus-usage.py) in the `examples` directory of the repository.
\ No newline at end of file
Examples of the usage of the package can be found in the implementation of two players `RandomPlayer` and `UserPlayer` from [gridworld.py](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/wumpus/gridworld.py), and in the files [`wumpus-usage.py`](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/examples/wumpus-usage.py), [`eater-usage.py`](https://gitlab.inf.unibz.it/tessaris/wumpus/blob/master/examples/eater-usage.py) in the [`examples`](/wumpus-usage.py), [`eater-usage.py`]() directory of the repository.
Your player could be also run using the script `gridrunner` script (in the repository is the `runner.py` file) and it'll be available once the package is installed (in alternative could be executed using `python -m wumpus.runner`):
"""Checks that the argument is a valid object reference specification in the form 'importable.module:object.attr'. See <https://packaging.python.org/specifications/entry-points/#data-model> for details.
Args:
arg_value (str): object reference
pattern ([type], optional): regular expression defining the required reference. Defaults to '^[\w.-]+:[\w.-]+$'.
Raises:
argparse.ArgumentTypeError: if the argument doesn't comply with the pattern
Returns:
str: the given argument if it complies with the pattern
"""
ifnotpattern.match(arg_value):
raiseargparse.ArgumentTypeError("the argument doesn't comply with {}".format(pattern.pattern))
parser.add_argument('--name',type=str,default='wumpy',help='name of the player')
parser.add_argument('--path',type=str,default='.',help='path of the player library')
parser.add_argument('--module',type=str,required=True,help='name of the player class module')
parser.add_argument('--class',type=str,required=True,help='name of the player class')
parser.add_argument('--world',type=str,default='WumpusWorld',help='class name of the world')
parser.add_argument('--horizon',type=int,default=20,help='maximum number of steps')
parser.add_argument('infiles',type=argparse.FileType('r'),nargs='*',help='world description JSON files, they must be compatible with the world type (see --world option).')
parser.add_argument('--name','-n',type=str,help='name of the player, default to the name of the player class')
parser.add_argument('--path','-p',type=str,default='.',help="path of the player library, it's prepended to the sys.path variable")
parser.add_argument('--entry','-e',type=check_entrypoint,required=True,help="object reference for a Player subclass in the form 'importable.module:object.attr'. See <https://packaging.python.org/specifications/entry-points/#data-model> for details.")
parser.add_argument('--world','-w',type=str,default=world_classes[0].__name__,choices=[c.__name__forcinworld_classes],help='class name of the world')
parser.add_argument('--horizon','-z',type=int,default=20,help='maximum number of steps')
parser.add_argument('--noshow',action='store_false',help="prevent the printing the world at each step")
parser.add_argument('--out',type=argparse.FileType('w'),default=sys.stdout,help="write output to file")
parser.add_argument('--out','-o',type=argparse.FileType('w'),default=sys.stdout,help="write output to file")