Closed PK4teens closed 10 months ago
commands don't return anything in the java API for netlogo. So that is why you see the None. There is a pacth_report method in pynetlogo that might be used for what you try to do. But I am not sure.
Really thanks for your reply. I have solved the issue. I assigned a reporter in netlogo named dist to report the distance between two agents in observer mode. Then use netlogo.report to pass the distance to python.
Hi, I'm using pynetlogo to load the Airplane landing 3D model. In this process, I want to use netlogo.report to call the netlogo reporter 'distance', which could reports the distance from this agent to the given turtle or patch. I manage to use this reporter to return the distance between self airplane and opponent airplane. Code as follows:
It reports error:
Traceback (most recent call last): File "E:\pythonProject1\pythonProject2\lib\site-packages\pynetlogo\core.py", line 300, in report result = self.link.report(netlogo_reporter) org.nlogo.core.CompilerException: You can't use DISTANCE in an observer context, because DISTANCE is turtle/patch-only. at position 49 in
It seems that distance is an turtle/patch-only reporter. When I type it in netlogo command center, the object should be turtle-set but not the observer. So i manage to use netlogo.command to achieve it. Code as below:
It really works, but the distance data is typed in netlogo's command center, not python's results bar.In python, it types none in the bar: None None None None None None None None None None So i would like to know how to load netlogo.report in turtle-only state by pynetlogo ,or to convey the data by pynetlogo.command to python? Thanks you.