-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting of sticky action probability, setting fixed random seed…
…, and toggling difficulty ramp via environment initializer
- Loading branch information
Showing
7 changed files
with
35 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# Tian Tian ([email protected]) # | ||
################################################################################################################ | ||
from importlib import import_module | ||
import numpy as np | ||
|
||
|
||
##################################################################################################################### | ||
|
@@ -14,14 +15,19 @@ | |
# | ||
##################################################################################################################### | ||
class Environment: | ||
def __init__(self, env_name): | ||
def __init__(self, env_name, sticky_action_prob = 0.1, difficulty_ramping = True, random_seed = None): | ||
env_module = import_module('minatar.environments.'+env_name) | ||
self.env_name = env_name | ||
self.env = env_module.Env() | ||
self.env = env_module.Env(ramping = difficulty_ramping, seed = random_seed) | ||
self.n_channels = self.env.state_shape()[2] | ||
self.sticky_action_prob = sticky_action_prob | ||
self.last_action = 0 | ||
|
||
# Wrapper for env.act | ||
def act(self, a): | ||
if(np.random.rand()<self.sticky_action_prob): | ||
a = self.last_action | ||
self.last_action = a | ||
return self.env.act(a) | ||
|
||
# Wrapper for env.state | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters