Skip to main content

The Great Elf Game adapted for Python North East - client & server

Project description

The annual Christmas Elves game server and client

Python North East December brings you the Christmas Elf Challenge. Your task, should you choose to accept it, is to collect the most

Running your Game

This part of the guide will give you the instructions to set up the game so you can start trying to set a high score!

Installation

Make sure you have Python installed - if you have Windows, check out the Beginner’s Guide of the Xmas Elves document.

Once you’re ready, you can get the client code running:

pyvenv venv
. venv/bin/activate
pip install pyne-xmas-elves

Building your Bot

Create your game file, called game.py:

from pyne_xmas_elves.client import BaseGame


class Game(BaseGame):
    """Your main Game Class.
    """

    PLAYER_NAME = 'Tom Cooper'

    def turn(self, elves_available):
        """Take a single turn.

        The elves_available argument will tell you how many elves you can use
        as a guide.
        """
        send_to_woods = elves_available // 2
        send_to_forest = (elves_available - send_to_woods) // 2
        send_to_mountains = elves_available - send_to_forest
        return (send_to_woods,
                send_to_forest,
                send_to_mountains)

Helper Attributes

While taking a turn, you can access the following attributes on self:

  • amount_raised - total money raised

  • current_turn - the current turn number

  • last_turn - what the last turn number will be

  • previous_weather - the weather from the previous expedition

Run the game

After creating your bot, you can run the game:

elves game

Running the Server

Installing Dependencies

The server is self-contained with an SQLite database, so just install the requirements:

pip install -r requirements.txt

Running

We’re using Django Channels, so running the server is as easy as:

python server/manage.py runserver

The API

To interact with the server session, we use a simple REST API to send new data into the server. The full API docs can be found by running a server and navigating to /docs/.

Starting a New Session

To start a new session, send a POST request with a name variable form-encoded to https://<host>/sessions/:

curl https://example.com/sessions/ -X POST -d player_name="Scott"

and you’ll get a simple JSON object back with a session URL that you post your turns against.

Taking a Turn

To take a turn, make a POST request against the day endpoint of a session.

Instructions and Rules

See the attached Google Doc for the rules and any of the latest tips and tricks.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyne-xmas-elves-0.7.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

pyne_xmas_elves-0.7.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pyne-xmas-elves-0.7.1.tar.gz.

File metadata

File hashes

Hashes for pyne-xmas-elves-0.7.1.tar.gz
Algorithm Hash digest
SHA256 c4bccf167cf2281545f828995fef311c6c5729b635901c30e4e19cc4d1389b81
MD5 90b35485882efccc5e27379bfe7c0217
BLAKE2b-256 37fccb85321f88405973e3a518a2459c48c823adc52c261d6e0e1e0792b76f60

See more details on using hashes here.

File details

Details for the file pyne_xmas_elves-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyne_xmas_elves-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56e5ba15d0941d8c4c668c83510e47935af979510953049c76eb002c5ea613c3
MD5 18267b94e681bcd134097fc83a15f28d
BLAKE2b-256 9696b268954f15782e7ce9cb5a08137aea91df7fd561918fbe1ec777dfd23af0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page