Package: netlogopy
Project  netlogopynetlogopy : Usage netlogo by pythonDeveloper byBOUAZIZ Nourddine :@Bouaziz19Installation1- install netlogo 🔗2-install netlogopycondainstallopenjdk-y
pipinstallnetlogopy
pipinstallnetlogopy--upgrade3- VS CodeSet Default Terminal In VS Code :Command Line Interface (CLI)🔗🔗Example TESTimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")n.close_model()ColorsColorsUsage/Examples1- pyturtleimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)car01=pyturtle(n,x=20,y=20,shape="car",size_shape=4,color=15,name="car01",labelcolor=15)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")n.close_model()2-set_backgroundimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagepath_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)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")n.close_model()3-streetimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")n.close_model()4-Fdimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")car01.fd(1)n.close_model()5-netlogoshowimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(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-distancetoimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")car01.fd(1)word=car01.distanceto(car02)print(word)netlogoshow(n,word)n.close_model()7-face_toimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")car01.fd(1)ifi==5:car01.face_to(car02)n.close_model()8-move_toimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")car01.fd(1)ifi==5:car01.move_to(car02)n.close_model()9-hideturtleimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")car01.fd(1)ifi==5:car01.hideturtle()n.close_model()10-set_shapeimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,100):time.sleep(1)print("***********  ",i,"  ********")car01.fd(1)ifi==5:car01.set_shape('default')n.close_model()11-getxyturtleimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(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-setxyimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,100):time.sleep(1)print("***********  ",i,"  ********")car01.fd(1)ifi==5:car01.setxy(10,10)n.close_model()13-distancebetweenimporttimefromnetlogopy.netlogopyimport*if__name__=="__main__":# Change netlogo_homenetlogo_home="C:/Program Files/NetLogo 6.2.2"n=run_netlogo(netlogo_home)# Resize worldresize_world(n,0,60,0,60)# Change path fo imagecar01=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)foriinrange(0,10):time.sleep(1)print("***********  ",i,"  ********")car01.fd(1)word=distancebetween(n,car01,car02)print(word)n.close_model()