Skip to main content

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.

Release files for pyne-xmas-elves 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyne-xmas-elves 0.7.1
File Size Uploaded
pyne-xmas-elves-0.7.1.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyne-xmas-elves 0.7.1
File Interpreter ABI Platform
pyne_xmas_elves-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.6 kB

Release files / pyne-xmas-elves-0.7.1.tar.gz

Download URL pyne-xmas-elves-0.7.1.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c4bccf167cf2281545f828995fef311c6c5729b635901c30e4e19cc4d1389b81
BLAKE2b-256 checksum
How to use checksums
37fccb85321f88405973e3a518a2459c48c823adc52c261d6e0e1e0792b76f60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyne_xmas_elves-0.7.1-py3-none-any.whl

Download URL pyne_xmas_elves-0.7.1-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56e5ba15d0941d8c4c668c83510e47935af979510953049c76eb002c5ea613c3
BLAKE2b-256 checksum
How to use checksums
9696b268954f15782e7ce9cb5a08137aea91df7fd561918fbe1ec777dfd23af0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

2 release files

0.6.3

2 release files

0.6.2

3 release files

0.6.1

2 release files

0.6.0

3 release files

0.5.1

3 release files

0.5

2 release files

0.4

2 release files

0.2

2 release files

0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page