TiledLand: Polygon-based simulation engine.

The main idea is to model a plan world (a land) as a collection of convex-polygons objects : tiles. Then, the land is mainly composed of an environnement - interconnected tiles - and agents distributed inside it.

To notice that, TiledLand is more a sandbox project to test approaches than an optimized, ready-to-use and well documented toolbox.

Not what are you looking for ?

You can look at concurrent/complementary projects:

  • Box2d a 2d physics game engine
  • pygame a python-based game engine
  • raylib a simple cross language game engine
  • shapely to manipulate in python geometric objects in the cartesian plane (based on GEOS)
  • cgal another Computational Geometry Algorithms Library (c++)

Install

The project and its dependancies can be installed with pip

pip install tiledland

The project is a Python program reling on Cairo library for rendering example, pyyaml to read yaml configuration files and hacka for distributed game programming.

You can also install tiledland from source on github.com - tiledland.

Getting started

Then, as an exemple, the following code will generate a grid land with 3 square agents in position 9, 14 and 26. The land is then rendered as a png graphic.

#!env python3
import tiledland as tll

# Create a new TiledMap as a grid:
scene= tll.Scene()
scene.initializeGrid([
    [0, 1, 1, -1, 0, 0, 0, 0], # -1 : means no cell at this location
    [5, -1, 0, 2, 0, -1, 5, 0], # 0 - n : give the group identifier
    [0, 0, 0, -1, 0, 1, 1, 0], # of the cell to create.
    [0, 4, 0, -1, 0, 2, 1, 6],
    [-1, -1, 0, 0, 0, -1, -1, -1]
])

# Agent 1
agent= scene.popAgentOn(9)

# Agent 2
agent= scene.popAgentOn(26)
agent.setMatter(13)

# Agent 3
agent= scene.popAgentOn(14)
agent.setMatter(15)

# Create an artist to render this scene:
pablo= tll.Artist().initializePNG( "shot-demo.png", 800, 600 )
pablo.fitBox( scene.box() )
scene.draw(pablo)
pablo.flip() # Uptate the support and return to a blanc page.

print( f"You can open now the './{pablo.support().filePath()}' file." )