A simple, lightweight and powerful 3D agent-based simulation toolkit with Logo
Project description
LightLogo: A lightweight Logo-based agent-based simulation toolkit
LightLogo (LLogo) aims to provide a simple, lightweight, and powerful 3D agent-based simulation toolkit for educational and scientific research.
Installation
pip install LightLogo
Features
-
Redesigned turtle and more agent types that support 3D contexts;
-
Easy integration with Python and its massive Python libraries to enhance experience;
-
Following the basic principles of Logo language but with significant improvement.
Usage
Example 1: Playground
from lightlogo.play3D import *
clearscreen()
reset()
setxyz(5,-5,0)
pendown()
repeat(8,[
left(45),
fd(5)
])
penup()
repeat_play()
Example 2: Full-scale agent-based simulation
from lightlogo.world3D import *
if __name__=="__main__":
# Step 1: Create a 3D world in LightLogo
w3d=world3D(x_range=[-10,10],y_range=[-10,10],z_range=[-10,10],title="Demo 2",)
w3d.create(style="seaborn-ticks")
# Step 2: Define an initialization function
def setup(world):
# create turtles
N=1
list_turtles=[
turtle3D(xyz=[0,0,0],color='red',shape='.',size=10) for _ in range(N)
]
list_turtles[0].left(45)
world.turtles(list_turtles)
# Step 3: Define a step function for each frame to update
def go(frame,world):
list_turtles=world.turtles()
print(f"Step {frame}\tTurtles Count: {len(list_turtles)}")
# turtle 1
turtle1=list_turtles[0]
if frame==0:
turtle1.pendown()
turtle1.forward(3)
# turtle1.setxrotate(45)
# turtle1.right(60)
# turtle1.up(45)
# turtle1.rollback(30)
# turtle1.setxrotate(45)
# turtle1.setxrotate(90)
if frame!=0 and frame % 1 == 0 and frame < 40:
turtle1.left(30)
t1=text3D(xyz=turtle1.pos(),color='green',text=f"p{frame}")
world.texts().append(t1)
if frame >=40:
turtle1.penup()
if frame>=10:
turtle1.hide()
if frame>=20:
turtle1.show()
list_turtles[0]=turtle1
world.turtles(list_turtles)
# Step 4 (final step): Run the simulation
w3d.run(go=go,setup=setup,interval=500,frames=1000,repeat=True)
Simulation screenshot
License
The LightLogo
project uses BSD 3-Clause License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file LightLogo-0.0.1a1.tar.gz
.
File metadata
- Download URL: LightLogo-0.0.1a1.tar.gz
- Upload date:
- Size: 80.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d15a2bf1ffa32e7e16ee09a2a6c886f7568744c1619d5e9e7088772228d147a |
|
MD5 | 1864bfb8c968d66c03dc437861680e10 |
|
BLAKE2b-256 | 5059299e3743496ca319953a17718ecfc176fc29a85e9ed0518706171e47881c |
File details
Details for the file LightLogo-0.0.1a1-py3-none-any.whl
.
File metadata
- Download URL: LightLogo-0.0.1a1-py3-none-any.whl
- Upload date:
- Size: 83.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d63d3340f4f63eab9cf92b13f4d82db47e71b70d7dc0226c4c9ded513715d256 |
|
MD5 | 6541eb840f766ca5266b9a22e8bcb39d |
|
BLAKE2b-256 | 99b0dbbae7394ee47a58dc09e44c9ed80fec71b151190498243cd264b8f87b95 |