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
LightLogo-0.0.1a1.tar.gz
(80.6 kB
view hashes)
Built Distribution
Close
Hashes for LightLogo-0.0.1a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d63d3340f4f63eab9cf92b13f4d82db47e71b70d7dc0226c4c9ded513715d256 |
|
MD5 | 6541eb840f766ca5266b9a22e8bcb39d |
|
BLAKE2b-256 | 99b0dbbae7394ee47a58dc09e44c9ed80fec71b151190498243cd264b8f87b95 |