From 5b27e9d273c43fd59905a7f126ddf8edfab7fae7 Mon Sep 17 00:00:00 2001 From: Neil Kollack Date: Sun, 7 Nov 2021 14:34:08 -0600 Subject: initial commit --- src/environment.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/environment.py (limited to 'src/environment.py') diff --git a/src/environment.py b/src/environment.py new file mode 100644 index 0000000..94f9cbf --- /dev/null +++ b/src/environment.py @@ -0,0 +1,56 @@ +# environment.py +# -------------- +# Licensing Information: You are free to use or extend these projects for +# educational purposes provided that (1) you do not distribute or publish +# solutions, (2) you retain this notice, and (3) you provide clear +# attribution to UC Berkeley, including a link to http://ai.berkeley.edu. +# +# Attribution Information: The Pacman AI projects were developed at UC Berkeley. +# The core projects and autograders were primarily created by John DeNero +# (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu). +# Student side autograding was added by Brad Miller, Nick Hay, and +# Pieter Abbeel (pabbeel@cs.berkeley.edu). + + +#!/usr/bin/python + +class Environment: + + def getCurrentState(self): + """ + Returns the current state of enviornment + """ + abstract + + def getPossibleActions(self, state): + """ + Returns possible actions the agent + can take in the given state. Can + return the empty list if we are in + a terminal state. + """ + abstract + + def doAction(self, action): + """ + Performs the given action in the current + environment state and updates the enviornment. + + Returns a (reward, nextState) pair + """ + abstract + + def reset(self): + """ + Resets the current state to the start state + """ + abstract + + def isTerminal(self): + """ + Has the enviornment entered a terminal + state? This means there are no successors + """ + state = self.getCurrentState() + actions = self.getPossibleActions(state) + return len(actions) == 0 -- cgit v1.2.3-70-g09d2