Giter Club home page Giter Club logo

f9lander's Introduction


###F9Lander

Simple 2d simulation of Falcon 9 rocket landing on an ocean platform.


###Requirements:

  1. python 2.7 https://www.python.org/downloads/

  2. pygame http://www.pygame.org/download.shtml

    installation of pygame with anaconda:

    http://stackoverflow.com/questions/19636480/installation-of-pygame-with-anaconda

    the easiest way to install using conda is:

    $ conda install -c https://conda.binstar.org/krisvanneste pygame
    
    or
    
    $ conda install -c https://conda.anaconda.org/kne pygame
  3. pybox2d https://github.com/pybox2d/pybox2d

    to install using conda:

    $ conda install -c https://conda.anaconda.org/kne pybox2d
  4. numpy http://www.scipy.org/scipylib/download.html

    to install using conda:

    $ conda install numpy

n. common sense

p.s. conda (not necessary | only if you choose conda way of packages installation)

http://conda.pydata.org/miniconda.html


###Demo:

https://youtu.be/wCqZF0uTbKY

Video is pretty old. Current version works much better (=


###Controls:

You can control rocket manually through keyboard or using external script through socket. To change type of control you should use key '-s' for "socket" mode. Default mode is "keyboard".

$ python F9LanderCORE.py -s

"keyboard"

w - main engine;

a - left engine;

d - right engine;

n, space - restart game (new rocket) | SPACE will work even in "socket" control mode;

You can find more information about controls in help.pdf

"socket"

The F9GameClient class is a simple wrapper that helps you to control rocket through the socket. See F9utils.py for more details.

Or if you want to use pure F9LanderPureSocketClient.py code:

To control rocket through socket you should send the string with list of four numbers [up, left, right, new] to the socket address. Each of the numbers can be 1 or 0, which means: 1 - activate, 0 - do nothing.

For example [1, 1, 1, 0] means that all engines are working. [0, 0, 0, 1] means that you want to get a new rocket and restart.

As an output you will receive a string with list of dictionaries [{}, {}, {}] with information about every object in simulation. You can see an example of such list in F9LanderClientCORE.py

Socket address ('127.0.0.1', 50007)

Keys map [up - main engine, left - left engine, right - right engine, new - new rocket]


###Command line options and how to run:

By default the game will run in "keyboard" mode.

$ python F9LanderCORE.py

To run it in the "socket" mode start the server script with the following options:

$ python F9LanderCORE.py -s

Then run in second console:

$ python F9LanderClientCORE.py

F9LanderClientCORE.py is a client which sends commands to the server, you can modify it if you are familiar with python, or write your own script in any programming language. F9LanderClientCORE represents Python API.

If you want to write your own API script:

First start the server F9LanderCORE.py and then you can send the string with list [up, left, right, new] to socket ('127.0.0.1', 50007). "up", "left", "right" and "new" can be 1 or 0.

You can modify the socket address and port by running the server with the following options:

$ python F9LanderCORE.py -i 127.0.0.1 -p 50007

As an output you will get a string with the list of dictionaries [{}, {}, {}] with information about every object in simulation.

You can run game without graphics with text output only (graphics is enabled by default):

$ python F9LanderCORE.py -d

Note that in this mode you can't control agent using keyboard.

In test mode you can launch the simulation for limited number of iterations. Log will be saved into ./log/log.txt file.

$ python F9LanderCORE.py -t 42000

###Information:

To show opened sockets in Ubuntu

$ netstat -ntlp | grep LISTEN

Experimental version with RESTful API

If you don't like TCP sockets as a default interface, there is an experimental version with RESTful API:

./experiments/RESTfulAPI


###Files:

F9LanderCORE.py - main class | server |

F9LanderClientCORE.py - external control script | client | Python API |

F9LanderPureSocketClient.py - external control script | client | pure socket API without wrapper |

./experiments - folder with experimental scripts

./experiments/RESTfulAPI - version with RESTful API

./res - folder with resources

./log - folder with output logs

^_^


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.