Skip to main content

My implementation of our made up game

Project description

Title

summary

Swoggle Game Engine

Implements a silly game we invented last Christmas and have been playing recently.

Rules are TODO.

Install

Should be as easy as:

pip install swoggle

How to use

To get a board with the basic setup, use the swoggle class:

s = Swoggle(agents=[])
s.show()
[1.1][...][...][...][...][...][...][4.4]
[...][...][...][...][...][...][...][...]
[...][...][...][...][.d.][...][...][...]
[...][...][.d.][...][...][...][...][...]
[...][...][...][...][...][.d.][...][...]
[...][...][...][.d.][...][...][...][...]
[...][...][...][...][...][...][...][...]
[2.2][...][...][...][...][...][...][3.3]
Spa: []

Players can move (after rolling a dice). For example, player 1 could move to the square with a drone:

s.move(1, (0, 0), (3, 2), 5) # Only works if dice_roll is high enough
s.show()
Moved 1 (0, 0) (3, 2)
[..1][...][...][...][...][...][...][4.4]
[...][...][...][...][...][...][...][...]
[...][...][...][...][.d.][...][...][...]
[...][...][1d.][...][...][...][...][...]
[...][...][...][...][...][.d.][...][...]
[...][...][...][.d.][...][...][...][...]
[...][...][...][...][...][...][...][...]
[2.2][...][...][...][...][...][...][3.3]
Spa: []

You can move with the drone, but only half as far:

s.move(1, (3, 2), (1, 1), 5, drone=True) # Only works if dice_roll is high enough
s.show()
Moved 1 (3, 2) (1, 1)
[..1][...][...][...][...][...][...][4.4]
[...][1d.][...][...][...][...][...][...]
[...][...][...][...][.d.][...][...][...]
[...][...][...][...][...][...][...][...]
[...][...][...][...][...][.d.][...][...]
[...][...][...][.d.][...][...][...][...]
[...][...][...][...][...][...][...][...]
[2.2][...][...][...][...][...][...][3.3]
Spa: []

You can leave the drone behind to move elsewhere. But you cannot take an occupied base without the drone:

s.move(1, (1, 1), (7, 0), 6) # No drone - no luck
Invalid Move 1 (1, 1) (7, 0)

You can take a droned player with a drone for yourself or a powerjump:

s.move(1, (1, 1), (4, 0), 6, drone=True) # Put 1 in position
s.move(2, (7, 0), (4, 0), 6, powerjump=True) # take one with a powerjump
s.show()
Moved 1 (1, 1) (4, 0)
Player 1 sent to Swoggle Spa
Drone destroyed
Moved 2 (7, 0) (4, 0)
[..1][...][...][...][...][...][...][4.4]
[...][...][...][...][...][...][...][...]
[...][...][...][...][.d.][...][...][...]
[...][...][...][...][...][...][...][...]
[2..][...][...][...][...][.d.][...][...]
[...][...][...][.d.][...][...][...][...]
[...][...][...][...][...][...][...][...]
[..2][...][...][...][...][...][...][3.3]
Spa: [1]

Now player 1 must try to escape, by rolling a 5 ot 6

s.move(1, (0, 0), (0, 0), 4) # No escape with a 4
s.move(1, (0, 0), (0, 0), 5) # Escaped
s.show()
Player 1 did not escape
Player 1 escaped
[1.1][...][...][...][...][...][...][4.4]
[...][...][...][...][...][...][...][...]
[...][...][...][...][.d.][...][...][...]
[...][...][...][...][...][...][...][...]
[2..][...][...][...][...][.d.][...][...]
[...][...][...][.d.][...][...][...][...]
[...][...][...][...][...][...][...][...]
[..2][...][...][...][...][...][...][3.3]
Spa: []
s.move(1, (0, 0), (4, 0), 6) # Capture 2
s.move(1, (4, 0), (7, 0), 5) # Take 2's base to win the game
s.show()
Player 2 sent to Swoggle Spa
Moved 1 (0, 0) (4, 0)
Player 1 defeated player 2
Moved 1 (4, 0) (7, 0)
[1.1][...][...][...][...][...][...][4.4]
[...][...][...][...][...][...][...][...]
[...][...][...][...][.d.][...][...][...]
[...][...][...][...][...][...][...][...]
[...][...][...][...][...][.d.][...][...]
[...][...][...][.d.][...][...][...][...]
[...][...][...][...][...][...][...][...]
[...][...][...][...][...][...][...][3.3]
Spa: []

Adding agents

We have several agents to choose from. Let's create a game with 2 random agents and 2 basic agents and watch them play:

sr = Swoggle([RandomAgent(i+1) for i in range(2)]+[BasicAgent(i+3) for i in range(2)])
sr.show()
[1.1][...][...][...][...][...][...][4.4]
[...][...][...][...][...][...][...][...]
[...][...][...][...][.d.][...][...][...]
[...][...][.d.][...][...][...][...][...]
[...][...][...][...][...][.d.][...][...]
[...][...][...][.d.][...][...][...][...]
[...][...][...][...][...][...][...][...]
[2.2][...][...][...][...][...][...][3.3]
Spa: []
# Run repeatedly to see a game play out
sr.move_agents()
sr.show()
Moved 3 (6, 1) (7, 0)
Player 4 defeated player 3
Moved 4 (1, 6) (7, 7)
[...][...][...][...][...][...][...][4.4]
[...][...][...][...][...][...][...][...]
[...][...][...][...][.d.][...][...][...]
[...][...][.d.][...][...][...][...][...]
[...][...][...][...][...][.d.][...][...]
[...][...][...][.d.][...][...][...][...]
[...][...][...][...][...][...][...][...]
[...][...][...][...][...][...][...][...]
Spa: []

Where Next?

The point of this exercise was to 1) Learn NBev and 2) Get a gae ready for RL experiments. So far so good :)

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

swoggle-0.0.5.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

swoggle-0.0.5-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file swoggle-0.0.5.tar.gz.

File metadata

  • Download URL: swoggle-0.0.5.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for swoggle-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2e0657c87effd783e285425ddf665b0f98a8d8e6070cea2ab03b1e22abe56f0b
MD5 1a4ab41be9eb604f1471e39852239c36
BLAKE2b-256 b0c99c98681bd2e2d2efea151fa97ca9c9b89df4f9d27ff772a71cc09bebf4b6

See more details on using hashes here.

File details

Details for the file swoggle-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: swoggle-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for swoggle-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 523a42bf5a5c000d0e1f3b6b5116ae31b708222d322939499f28f5b3bb9879d2
MD5 9865e4064ae300431f32241aa91ae989
BLAKE2b-256 2d69d898fc7e5676a1513f558d2735bfcd02d51c5fdf78a2ca600464d6ac2ffb

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