This is a quick programming game exercise on Markov Decision Processes and Dynamic Programming.
dependencies:
- numpy (>=1.10.x)
- gym (>=0.8.0)
- pygame (>=1.9.3)
type in terminal
sudo pip install gym numpy pygame
To install to your system:
git clone https://github.com/kiddos/guidehim.git
cd guidehim
sudo python setup.py install
The goal is to guide Stone Lin moving towards the goal. If your command move Stone Lin out of the Screen, game is over and you will need to reset the environemnt to play.
You might see these objects on the map:
-
Empty: (grid value: 0)
-
Fire: If Stone Lin caught on fire, game over. (grid value: 2)
-
Pond: If Stone Lin fell into a pond, also game over. (grid value: 3)
Stone Lin does not always follow the command you gave him, since he is such a dick. He has a probablility of 87.87% to follow your command. For 12.13% chance, he will go the other way. This makes the game a little harder to play.
Your job is to gave Stone Lin action so that he can get to the goal.
import
from guidehim.guide_him import GuideHim
initialize environemnt:
env = GuideHim('map/simple.map')
reset the environemnt:
observation = env.reset()
give action:
observation, reward, done, _ = env.step(env.action_space.sample())
render:
env.render()
sample code:
from guidehim.guide_him import GuideHim
import numpy as np
def main():
env = GuideHim('map/simple.map')
observation = env.reset()
while True:
observation, reward, done, _ = env.step(env.action_space.sample())
env.render()
if __name__ == '__main__':
main()
I currently create 3 maps:
- empty.map
- simple.map
- easy.map
You can play around with these.
I implement 2 dynamic programming methods:
- value iteration
value_iteration.py
- policy iteration
policy_iteration.py
I suggest you implement your own first.