“””Wumpus World.
COMP3620/6320 Artificial Intelligence
The Australian National University
Authors: COMP-3620 team
Date: 2022
Student Details
—————
Student Name:
Student Number:
import argparse
import sys
def process_command_line_arguments() -> argparse.Namespace:
“””Parse the command line arguments and return an object with attributes
containing the parsed arguments or their default values.
import json
parser = argparse.ArgumentParser()
parser.add_argument(“-i”, “–input”, dest=”input”, metavar=”INPUT”,
type=str, help=”Input file with the Wumpus World parameters and observations (MANDATORY)”)
parser.add_argument(“-a”, “–action”, dest=”action”, metavar=”ACTION”,
type=str, choices=[“north”, “south”, “east”, “west”],
help=”Action to be tested for safety (MANDATORY)”)
parser.add_argument(“-o”, “–output”, dest=”output”, metavar=”OUTPUT”, default=’wumpus_outputs’,
help=”Output folder (default: %(default)s)”)
args = parser.parse_args()
if args.action is None:
raise SystemExit(“Error: No action was specified.”)
if args.input is None:
raise SystemExit(“Error: No input file was specified.”)
if not os.path.exists(args.input):
raise SystemExit(
“Error: Input file ‘{}’ does not exist”.format(args.input))
with open(args.input) as instream:
args.domain_and_observations = json.load(instream)
except IOError:
raise SystemExit(“Error: could not open file {}”.format(args.input))
return args
def main():
# Processes the arguments passed through the command line
args = process_command_line_arguments()
# The name of the action to test
action = args.action
# The path of the directory that will contain the generated CSP files
output_path = args.output
# The description of the Wumpus World features and sequence of observations
# resulting from the agent actions.
dao = args.domain_and_observations
n_rows = dao[“rows”]
n_columns = dao[“columns”]
n_wumpuses = dao[“wumpuses”]
n_pits = dao[“pits”]
observations = dao[“observations”]
# YOUR CODE HERE
if __name__ == ‘__main__’: