Skip to main content

Play classic games in your Jupyter Notebook! Includes a collection of basic JS/HTML/CSS games from Steven Lambert (Github: straker)

Project description

jupyter-play

This package contains a number of basic HTML/CSS/JS games you can play in your jupyter notebook!

All credit for making the original game files goes to Steven Lambert.

snake_preview.gif

Installation

pip install jupyter-play

I recommend uv to all python users for managing their dependencies and virtual environments.

uv init # optional, creates a pyproject.toml 
uv venv --python 3.11 
source .venv/bin/activate
uv add --group fun jupyter-play # e.g. add a "fun" group under your development dependencies

The package source distribution includes a .zip of html games to play. setup.py includes a custom build step to unzip the game files from this html_games.zip; this means the files are unzipped in the installed version of the package (the "wheel"). More information on source distributions vs wheels can be found here.

  • To packaging workshop attendees (12/20/24): see if you can figure out how to exclude .zip from the installed state!

download_games.sh is the script to download and zip the game files from the original github gists.

Usage

## in an .ipynb file

from jupyter_play import PLAY

# View the list of games included
print(PLAY.list_games())

# Play any game you like
PLAY.SNAKE()

You can also run your own games (right now just from a string)

# Play your own game (load to string first)
from jupyter_play import play
with open('my_one_file_game.html', 'r') as file: 
    game_html = file.read()
play(game_html)

Please note that this package is only meant to work with basic, self-contained, one-file .html games in a jupyter notebook environment (i.e. with a running ipykernel).

Contributing

The games' creator intentionally left some core features lacking as an exercise for the reader. I may be making some of these additions myself, but if you're excited to contribute yourself please feel free to open a PR and edit one of the base game files in source_games.

I have other ideas for feature additions as well:

  • Basic AIs to play the games for you in a screensaver-like fashion.
  • Configure difficulty and speed settings.
  • Introduce new games.
  • Add new levels (procedurally generated?)

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

jupyter_play-0.1.0.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_play-0.1.0-py3-none-any.whl (62.8 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_play-0.1.0.tar.gz.

File metadata

  • Download URL: jupyter_play-0.1.0.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.9

File hashes

Hashes for jupyter_play-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5fc08cfd5a04e34f8587bcc30f24ba5c0dd58eda41e43eed0e1a00c7865ba629
MD5 5fce9afc987a65fa161dfddb270aaa0d
BLAKE2b-256 1939e5b044181c5c06df650dff05b23bf3fd2d66e04cf335aa24486a04bc011a

See more details on using hashes here.

File details

Details for the file jupyter_play-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_play-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe7b22fc47eb777b6908f309aad462cc338a801bfd6ff41b0ad3083894a18a07
MD5 8eabbfeea54913fe1baf475a886e8119
BLAKE2b-256 86eadf8792d07ef07f84d20d813e5c09c364db54a22f279b9d03e9068cbc85b5

See more details on using hashes here.

Supported by

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