Skip to content

keeyon2/GravitationalVoronoi

Repository files navigation

Gravitational Voronoi

Installation and requirements

Ubuntu/Mac

  • You should have python-2.6 or 2.7, numpy, pyqt4 and twisted on your machine. Use your favorite package manager (apt-get, brew)
  • Install qtreactor (Execute this from this repo's main directory):

cd qtreactor
python setup.py install

  • Install cython and q via pip

sudo pip install cython
sudo pip install q

  • Install our custom cython extension (Execute this from this repo's main directory)

./shared.sh

Windows

  • Install Anaconda. If you don't want to install anaconda, install cython, python-2.7, numpy and pyqt4 manually.
  • Install VC++ Compiler for Python-2.7
  • Use the Anaconda prompt for the following instructions
  • Install q

pip install q

  • Install twisted

pip install twisted

  • Install qtreactor

cd qtreactor
python setup.py install

  • Install our custom cython extension (Execute this from this repo's main directory)

shared.bat

Server instructions

  • Run the server with following command:

python gravoronoi_reactor.py

  • Use -h to know all the options
  • Connect your client to the server via TCP to port 1337 (configurable)
  • Make sure your client responds to the following protocol.
  • See client example in client.py, run with:

python client.py <player_name>

Game protocol sequence (bold = data received from server)

  • Connect to the server at port 1337 (configurable)
  • Receive TEAM from the server
  • Send to server your team name (no spaces)
  • Receive something like the following from server:
<Player 1 Name> x1 y1\n  
<Player 2 Name> x2 y2\n  
...  
MOVE
  • Each line before the ending line MOVE represents a move made by the previous players in order (num_players-1). During the first round of moves, if you are the first player you will not see any previous moves, therefore, only MOVE will be sent. If you are the second player, you will see 1 previous move, and so on.
  • Send your move in format “x y”. Wait for your turn then repeat the last step until game ends.
  • After num_moves has passed, game ends. You’ll receive END.
  • If you try to send move to server again after game has ended it will respond with GAME ENDED.

Manual game

  • You can also play the game with a mouse.
  • Try this:

python gravoronoi.py

  • Use the -h option to see further options

Checking the board values

  • Re-run shared.sh or shared.bat to make this work. (Only need to run the first time)
  • You can check the board values generated by our code for any number of moves using check_board.py.
  • Just pipe your input file in the following format:
<num_players> <num_moves>  
<player_number> <moves_played>  
x y  
...  
<player_number> <moves_played>  
x y  
...  
  • Check sample_check_board.txt for an example.
  • You'll get the scores of all players and a matrix representing the game board with points set to the player_number to which they belong as output.

Experiments Mode

This is a mode for experimental/statistical evaluation of your player. It is activated using the '-e' option. By default, GUI is off in this mode. Start your server specifying the number of experiments(n) via '-e', start your clients and the server will run n experiments, printing in the end the number of games won by each player. The client needs to be compliant for this mode to work. It should be able to reset it's state on receiving a RESTART command on the network.

Notes

  • We speeded up the GUI to be blazingly fast. Therefore, we have added a delay option to gravoronoi_reactor.py to delay each move by the seconds you enter. You can enter float values to indicate fraction of a second.
  • The scale option allows to half the resolution. Use 2 for that. Using 1 for this option switches back to 1000x1000 resolution.
  • The gui_on option allows you to enter whether to switch off all GUI. The options are 0 for no gui and 1 for gui. Its 1 by default. Its not very stable as it doesn't quit properly.
  • If you look at the GUI, you'll find a reset button. You can use it to wipe out the GUI board and make it forget all previous state. This way for the server version, you can restart your clients without having to restart the server.
  • Default values for server (gravoronoi_reactor.py):
    • num_moves (Number of moves per game) = 10
    • first_player (Player who goes first) = abc
    • num_players (Number of players) = 2
    • gui_on = 1
    • scale = 2
    • delay = 0
    • port = 1337

FAQ

  • How to install pyqt on mac with brew: brew install pyqt (For non-brewed Python, you'll have to set your PYTHONPATH as brew info pyqt will tell.)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published