netlogopy : Usage netlogo by python
Project description
Project netlogopy
netlogopy : Usage netlogo by python
Developer by
- BOUAZIZ Nourddine : @Bouaziz19
Installation
1- install netlogo 🔗
2-install netlogopy
conda install openjdk -y
pip install netlogopy
pip install netlogopy --upgrade
3- VS Code
Set Default Terminal In VS Code :Command Line Interface (CLI) 🔗 🔗
Example TEST
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
n.close_model()
Colors
Colors
Usage/Examples
1- pyturtle
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
n.close_model()
2-set_background
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
path_image ="path/to/image/netlogopy.png"
# path_image= "C:/Nouveau dossier/netlogopy/Examples/netlogopy.png"
set_background(n,path_image)
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
n.close_model()
3-street
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
n.close_model()
4-Fd
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
n.close_model()
5-netlogoshow
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
word=str(car01.id) +" " +str(i)
netlogoshow(n,word)
print(word)
car01.fd(1)
n.close_model()
6-distanceto
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
word=car01.distanceto(car02)
print(word)
netlogoshow(n,word)
n.close_model()
7-face_to
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
if i==5:
car01.face_to(car02)
n.close_model()
8-move_to
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
if i==5:
car01.move_to(car02)
n.close_model()
9-hideturtle
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
if i==5:
car01.hideturtle()
n.close_model()
10-set_shape
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,100):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
if i==5:
car01.set_shape('default')
n.close_model()
11-getxyturtle
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
xy=getxyturtle(n,car01)
x=xy[0]
y=xy[1]
print("xy : ",xy)
print("x : ",x)
print("y : ",y)
n.close_model()
12-setxy
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,100):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
if i==5:
car01.setxy(10,10)
n.close_model()
13-distancebetween
import time
from netlogopy.netlogopy import *
if __name__ == "__main__" :
# Change netlogo_home
netlogo_home="C:/Program Files/NetLogo 6.2.2"
n=run_netlogo(netlogo_home)
# Resize world
resize_world(n,0,60,0,60)
# Change path fo image
car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)
car02=pyturtle(n,x=5,y=5,shape="car",size_shape=4,color=55,name="car02",labelcolor=55)
street( n,fromm=car01,too=car02,label="street",labelcolor=35,color=35,shape="aa",thickness=0.5)
for i in range(0,10):
time.sleep(1)
print("*********** ",i," ********")
car01.fd(1)
word=distancebetween(n,car01,car02)
print(word)
n.close_model()
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
netlogopy-0.0.14-py3-none-any.whl
(61.3 kB
view hashes)
Close
Hashes for netlogopy-0.0.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee81d34d25ac4c6ab10e32be8045ce8e4d5c08ce74cf5d01eea4b748c7a0a44d |
|
MD5 | 33bc2428491c859709ea08b31bdad279 |
|
BLAKE2b-256 | fccadbf9d02b199bcc49e8a2dc5e2d99c6efbe7afd47043c9ad4d70145c38ec7 |