Skip to content

adamchainz/owela-club

Repository files navigation

Owela Club

A Django project for playing the Namibian game of Owela against a dumb AI. Built following the rules described on the Mancala World wiki page for Owela.

Running

  1. Make a Python 3.9 virtual environment with dependencies:

    python3.9 -m venv venv
    source venv/bin/activate
    python -m pip install -U pip wheel
    python -m pip install -r requirements.txt

    The code was developed on Python 3.9 but may run on older versions.

  2. Run the tests:

    pytest

    This should show output starting with:

    === test session starts ===

    …and finishing with output like:

    === 28 passed in 0.74s ===
  3. Create the development database:

    python manage.py migrate
  4. Start the development server.

    On Linux and macOS:

    DEBUG=1 python manage.py runserver

    On Windows:

    set DEBUG=1
    python manage.py runserver

Developing

You’re free to edit the code already, but for the smoothest experience there are some extra tools you can set up.

First, there’s Editorconfig, which ensures your text editor is well configured for editing. Install the appropriate editorconfig plugin for your text editor and the plugin will automatically confgiure your text editor based on the .editorconfig file.

Second, there’s pre-commit, which runs several code quality tools whenever you run git commit. These tools are configured in the .pre-commit-config.yaml file. To set up pre-commit:

  1. Install pre-commit by following its instructions. You can use your virtual environment’s pip for the simplest setup.
  2. Install the pre-commit hooks into your local repository:

    pre-commit install

    This will configure Git to run pre-commit before each commit.

  3. Check all files in the repository pass your pre-commit setup:

    pre-commit run --all-files

    You should see many Passed messages, such as:

    isort....................................................................Passed
    flake8...................................................................Passed

Extra tasks

This site has only been built as a demo of using htmx with Django. It’s therefore missing some useful features for playing the game. Here are some ideas of how to extend it...

  • Deploy the game online by using hosting such as Heroku and following the Django deployment checklist.
  • Make the board look good, maybe using a stony texture or showing the actual seeds.
  • Display more information about the last two moves, such as highlighting selected squares and affected squares.
  • Make the AI smarter - perhaps based on some heuristics such as “move from the biggest square” or “prefer moves on the inner row”.
  • Have multiple AI functiosn and allow new games to pick which one to play against.
  • Allow selecting different board widths.
  • Allow rule variations such as Hus or regional/house rules.
  • Allow player-versus-player games. htmx’s hx-trigger polling can be used for simple updating of the board state.
  • Add a login function so players can track their games.

About

Play the Namibian game of Owela against a terrible AI. Built using Django and htmx.

Resources

License

Stars

Watchers

Forks