-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 85b10eb
Showing
12 changed files
with
225 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_STORE |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from gym.envs.registration import register | ||
|
||
register( | ||
id='risk-v0', | ||
entry_point='gym_risk.envs:RiskEnv', | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from gym_risk.envs.risk_env import RiskEnv |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import gym | ||
|
||
class RiskEnv(gym.Env): | ||
metadata = {'render.modes': ['human']} | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def _step(self, action): | ||
""" | ||
Parameters | ||
---------- | ||
action : | ||
Returns | ||
------- | ||
ob, reward, episode_over, info : tuple | ||
ob (object) : | ||
an environment-specific object representing your observation of | ||
the environment. | ||
reward (float) : | ||
amount of reward achieved by the previous action. The scale | ||
varies between environments, but the goal is always to increase | ||
your total reward. | ||
episode_over (bool) : | ||
whether it's time to reset the environment again. Most (but not | ||
all) tasks are divided up into well-defined episodes, and done | ||
being True indicates the episode has terminated. (For example, | ||
perhaps the pole tipped too far, or you lost your last life.) | ||
info (dict) : | ||
diagnostic information useful for debugging. It can sometimes | ||
be useful for learning (for example, it might contain the raw | ||
probabilities behind the environment's last state change). | ||
However, official evaluations of your agent are not allowed to | ||
use this for learning. | ||
""" | ||
self._take_action(action) | ||
self.status = self.env.step() | ||
reward = self._get_reward() | ||
ob = self.env.getState() | ||
episode_over = self.status != hfo_py.IN_GAME | ||
return ob, reward, episode_over, {} | ||
|
||
def _reset(self): | ||
pass | ||
|
||
def _render(self, mode='human', close=False): | ||
pass | ||
|
||
def _take_action(self, action): | ||
pass | ||
|
||
def _get_reward(self): | ||
""" Reward is given for XY. """ | ||
if self.status == FOOBAR: | ||
return 1 | ||
elif self.status == ABC: | ||
return self.somestate ** 2 | ||
else: | ||
return 0 |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import random | ||
import networkx as nx | ||
|
||
from maps.debug import debug | ||
|
||
class Map(): | ||
metadata = {} | ||
|
||
def __init__(self): | ||
self.graph = None | ||
pass | ||
|
||
def initialize_player_assignment(self): | ||
"""Randomly assigns each player a country until there are none left""" | ||
|
||
|
||
pass | ||
|
||
def change_ownership(self, payload): | ||
"""Change ownership of a country | ||
Params: payload (dict) {node:player} | ||
""" | ||
nx.set_node_attributes(self.graph, payload, "owner") | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import networkx as nx | ||
|
||
debug = nx.Graph() | ||
|
||
debug.add_node("Thousand Oaks", continent="California", color="red") | ||
debug.add_node("San Francisco", continent="California", color="red") | ||
debug.add_node("Sacramento", continent="California", color="red") | ||
debug.add_node("Provo", continent="Utah", color="blue") | ||
debug.add_node("South Jordan", continent="Utah", color="blue") | ||
|
||
debug.add_edge("South Jordan", "Provo") | ||
debug.add_edge("South Jordan", "San Francisco") | ||
debug.add_edge("Thousand Oaks", "San Francisco") | ||
debug.add_edge("Provo", "San Francisco") | ||
debug.add_edge("San Francisco", "Sacramento") | ||
debug.add_edge("Sacramento", "Thousand Oaks") | ||
debug.add_edge("Sacramento", "Provo") |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### File for visualizing the map | ||
from matplotlib import pyplot as plt | ||
import networkx as nx | ||
|
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from setuptools import setup | ||
|
||
setup(name='gym_risk', | ||
version='0.0.1', | ||
install_requires=['gym', | ||
'networkx', | ||
'geopandas', | ||
'descartes', | ||
] # And any other dependencies risk needs | ||
) |