Skip to content

Commit

Permalink
added agents
Browse files Browse the repository at this point in the history
  • Loading branch information
felimomo committed Feb 25, 2024
1 parent bc1357c commit 9937bc3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Empty file.
11 changes: 11 additions & 0 deletions src/rl4greencrab/agents/const_action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class constAction:
def __init__(self, mortality=0, env = None, **kwargs):
self.mortality = mortality
self.action = 2 * self.mortality - 1
self.env = env

def predict(self, observation):
return self.action



23 changes: 23 additions & 0 deletions src/rl4greencrab/agents/const_escapement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class constEsc:
def __init__(self, escapement, env = None):
self.escapement = escapement
self.env = env
self.bound = 1
if self.env is not None:
self.bound = self.env.bound

def predict(self, observation):
obs_nat_units = self.bound * self.to_01(observation)
if obs_nat_units <= self.escapement or obs_nat_units =< 0:
return -1
mortality = (obs_nat_units - self.escapement) / self.escapement
return self.to_pm1(mortality)

def to_01(self, val):
return (val + 1 ) / 2

def to_pm1(self, val):
return 2 * val - 1



0 comments on commit 9937bc3

Please sign in to comment.