Skip to main content

Linesim

Line simulation made with pygame for testing a robot's pathfinding abilities.

Intended for testing pathfinding code for Purdue's ENGR 161 Project 3.

Test track

Features

  • Multiple line sensor support
  • Default track with curves, broken lines, and multiple paths.

Installation

Linesim is available on PyPI.

pip install linesim

Note: If you are having difficulty installing pygame 2.1.2 and you are using Python 3.11, first run pip install pygame==2.1.3-dev8 before installing.

Usage

First, import the LineSimulation class.

from linesim import LineSimulation

Initialize the simulation and run sim.add_sensor(offset) for each sensor to initialize, with positive x values as horizontal offset and positive y vales as vertical offset from the center of the robot.

Note: pygame defines the positive y direction as downwards.

sim = LineSimulation()
robot = sim.robot
sensors = [
    sim.add_sensor((20, 10)),
    sim.add_sensor((20, -10)),
    sim.add_sensor((0, 0))
]

Now, create your loop. Use sim.running to check if the simulation is still running, and run sim.update() to update the game after every movement.

while sim.running:
    if sensors[0].read_line():
        robot.rotate(4)  # Turn right
    elif sensors[1].read_line():
        robot.rotate(-4)  # Turn left
    else:
        robot.move(4)  # Go straight

    sim.update()

Metadata

Release files for linesim 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linesim 0.1.2
File Size Uploaded
linesim-0.1.2.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for linesim 0.1.2
File Interpreter ABI Platform
linesim-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 31.4 kB

Release files / linesim-0.1.2.tar.gz

Download URL linesim-0.1.2.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3e7c036b59b3c8ec19cac21c427bd322be57c380a65687cbefb7b44223cb6543
BLAKE2b-256 checksum
How to use checksums
9f38de67c1766a3be04c12f91eca3a490b37736c5278ccc0f4487c11b8bf6235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / linesim-0.1.2-py3-none-any.whl

Download URL linesim-0.1.2-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db31723ce7ec4bb8f1576894d1673597998592ea6530fcdc3fd42f577fc2f23e
BLAKE2b-256 checksum
How to use checksums
e3919966ff753b4e3e3b84bd178b20e8840842a7bd1d11da9cd9cbf4369e639b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page