ASPP / pelita_template

Default template to get started with the Pelita game.
3 stars 25 forks source link

Think about adding pyproject.toml to make pelita_template an installable module #71

Open Debilski opened 1 year ago

Debilski commented 1 year ago

Pelita already works with modules on the command line (for some pip-installed pelita player abcde, we can run a game with pelita abcde abcde on the command line).

For best-practices this might need some restructuring of the files (I think we would want to have all groupN related files in a subdirectory).

Also, we probably want to have a namespace convention so that we do not end up having group0 directly in site-packages.

A neat addition would be a __main__.py file, which could be used to easily start up network games using python -m

from pelita.scripts.pelita_player import with_zmq_router
import click

from pelita_player_groupN import groupN

@click.command()
@click.option('--address')
def main(address):
    with_zmq_router(groupN, address, advertise=True)

main()

which could be shrunk down to

from pelita.utils import publish_team
from pelita_player_groupN import groupN

publish_team(groupN)

The usage could then be python -m pelita_player_groupN --address 0.0.0.0:12345 to publish and advertise over mDNS a network player. (To be fair, the current way of doing this is not much more complicated either and does not need a __main__.py at all.)