-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery Starbot ⭐ refactored RusherRG/OpenAI-Gyms #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,9 +57,7 @@ def parser(self): | |
| help='Play using pre-trained models' | ||
| ) | ||
| argcomplete.autocomplete(argparser) | ||
| args = argparser.parse_args() | ||
|
|
||
| return args | ||
| return argparser.parse_args() | ||
|
|
||
| def initialize_env(self, args): | ||
| self.env_name = args.env | ||
|
|
@@ -139,8 +137,7 @@ def save_model(self, model): | |
| return | ||
|
|
||
| def load_model(self): | ||
| model = None | ||
| return model | ||
| return None | ||
|
Comment on lines
-142
to
+140
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def play(self): | ||
| model = self.load_model() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,9 +139,7 @@ def parser(self): | |
| help='Number of episodes to run' | ||
| ) | ||
| argcomplete.autocomplete(argparser) | ||
| args = argparser.parse_args() | ||
|
|
||
| return args | ||
| return argparser.parse_args() | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def initialize_env(self, args): | ||
| self.env_name = args.env | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ def init_population(initial_games,name): | |
| #init_population() | ||
|
|
||
| def neural_network_model(): | ||
| model = tf.keras.Sequential([ | ||
| return tf.keras.Sequential([ | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| tf.keras.layers.Dense(128, activation='relu', input_shape=(4,)), | ||
| tf.keras.layers.Dropout(drop), | ||
| tf.keras.layers.Dense(256, activation='relu'), | ||
|
|
@@ -74,7 +74,6 @@ def neural_network_model(): | |
| tf.keras.layers.Dropout(drop), | ||
| tf.keras.layers.Dense(2, activation='softmax') | ||
| ]) | ||
| return model | ||
|
|
||
| def play(model): | ||
| number_games = 10 | ||
|
|
@@ -132,8 +131,7 @@ def train_model(x_train, y_train, x_test, y_test): | |
| return model | ||
|
|
||
| def loadmodel(name): | ||
| model = tf.keras.models.load_model(name) | ||
| return model | ||
| return tf.keras.models.load_model(name) | ||
|
Comment on lines
-135
to
+134
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def lets_play(): | ||
| #generate_data_sets() | ||
|
|
@@ -151,7 +149,7 @@ def lets_play(): | |
|
|
||
|
|
||
| def some_random_games_first(): | ||
| for episode in range(5): | ||
| for _ in range(5): | ||
|
Comment on lines
-154
to
+152
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| env.reset() | ||
| for t in range(goal_steps): | ||
| env.render() | ||
|
|
@@ -163,7 +161,7 @@ def some_random_games_first(): | |
| env.close() | ||
|
|
||
| def env_test(): | ||
| for i_episode in range(20): | ||
| for _ in range(20): | ||
|
Comment on lines
-166
to
+164
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| observation = env.reset() | ||
| for t in range(100): | ||
| env.render() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,9 +51,7 @@ def parser(self): | |
| help='Size of state space' | ||
| ) | ||
| argcomplete.autocomplete(argparser) | ||
| args = argparser.parse_args() | ||
|
|
||
| return args | ||
| return argparser.parse_args() | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def initialize_env(self, args): | ||
| self.env = args.env | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
Agent.parserrefactored with the following changes:inline-immediately-returned-variable)