I block in a problem.
I explain :
I haves 2 types of turtles : robots (shape "default") and balls (shape "dot")
The robots catch 1 to 3 balls
The robots must to lay dows theses balls into catchs, in order to form a pile of balls
I don't arrive to lay down the balls ? how can I do ?
Please help me
Thanks
Related
I am working on traffic simulation using netlogo. In attached image, i want to extend the road grids into two way road grid i.e. increase the width of each road grid. Here is the code that will need update but I am unable to do it myself.
set roads patches with [
(floor ((pxcor + max-pxcor - floor (grid-x-inc - 1)) mod grid-x-inc) = 0) or
(floor ((pycor + max-pycor) mod grid-y-inc) = 0)
]
Here is code that makes wider roads.
I tried to separate out the left lanes from the right lane so you can see what is happening if that helps you figure out where the cars should go.
I also separated the x-offset and y-offset values so you can adjust the grid in case you want to.
This code assumes that max-pxcor = 32, max-pycor = 32, and patch size = 6, so that the whole thing fits the same physical view area.
globals [
left-lanes
right-lanes
roads
]
to setup
clear-all
;; set the number of patches between lanes
let grid-x-inc 13
let grid-y-inc 13
;; offsets move the lanes slightly more to the right or further up
let x-offset grid-x-inc - 3
let y-offset -2
;; color the background
ask patches [set pcolor lime]
;; create the lanes
set left-lanes patches with [
(floor ((pxcor + max-pxcor - x-offset) mod grid-x-inc) = 2) or
(floor ((pycor + max-pycor - y-offset) mod grid-y-inc) = 2)
]
set right-lanes patches with [
(floor ((pxcor + max-pxcor - x-offset) mod grid-x-inc) = 1) or
(floor ((pycor + max-pycor - y-offset) mod grid-y-inc) = 3)
]
;; color the lanes for debugging purposes
; ask left-lanes [set pcolor yellow]
; ask right-lanes [set pcolor (yellow - 1) ]
;; merge left and right lanes into roads
set roads patches with [ member? self left-lanes or member? self right-lanes]
ask roads [ set pcolor yellow]
reset-ticks
end
to go
tick
end
OK, now I see what you are trying to do. You have a bigger problem than just drawing wider roads.
And I see now that you probably just want traffic just to go in one direction on each wider road, instead of simulating traffic going both directions.
OK, so you need to solve several design problems before anyone can answer your question about code.
(1) What do you want to display? Do you want just a wider yellow road? Or do you want pretty roads with lines along the sides like in the "Traffic 2 Lanes" model?
(2) Do you want the cars to actually use the two lanes, and include behavior such as changing-lanes and passing, like the "Traffic 2 Lanes" model?
AND ... the "Traffic 2 Lanes" model already includes all the logic and code you need for drawing wider roads, which would solve one of the two related questions you originally posted. Even if you only want fat yellow roads, not fancy roads with lines on them, the same logic could be used and you can just remove the part that draws lines.
This answers your first question:
i want to ... increase the width of each road grid.
BUT ... You actually asked a much harder question in your comment and in your original post's title:
i want to extend the road grids into two way road grid
I am not sure whether your original meaning has survived translation into English.
To me, a "two way road" means one road with two lanes, where there is traffic going both directions on the same road. Some cars would be heading North and some cars would be heading South.
This is far more complicated than the "Traffic Grid" problem in the Model Library In the "Traffic Grid" problem each road is only one lane wide, but it is also "one way".
Finally, I see that you did not give credit to Uri Wilensky or mention the models in the Model Library that is the source of most of the code you posted. It will be obvious to your college teacher that you copied large sections of code from someone else's work -- you should give credit to that person and cite the source of that code. It is still a major effort for your college final project to merge the logic from two models into one more complex model and get it to function.
I'm pretty new at NetLogo and coding
At the moment I am trying to make a bio-economical modell of fishery for my bachelor-thesis.
The basic model is working pretty good but I do have 1 problem:
at one point there are not enough fish left to make the boats stay in my system.( they just "die out")
Is it possible to just randomly spawn some boats, if there aren't any left, to solve that problem and how do i write it in my code?
thanks for als answers .
Edit:
the basicaly Problem I have, is that I don't know how to code this with NetLogo.
to
random-spawn
if count boats = 0
[breed 1 [rt random-float 360 fd 1]]
end
I just need another command instead of breed. (hatch isn't possible because there are no boats left and breed can't be right
I was using in-cone, but then I noticed my turtle was "missing" a lot of other turtles inside the cone. From what I understand, this is due to the fact that, for instance:
ask other turtles in-cone 6 60 [set seen? true]
only "detects" turtles if their xy is within the cone. They are basically points without dimensions. Is there an easy way to make a turtle of size 20 be much more "visible" than one of size 2? I've searched this and the yahoo group for answers and didn't find what I was looking for... maybe I'm not searching for the right terms... I'm new to programming and netlogo and everything so I'm probably missing something obvious here.
Thank you very much.
Imagine a city with streets that people move around the city and streets. How can i say to the turtles that move just in a certain ways or don't move in some ways(patches)?
Some relevant models in the Code Examples section of the Models Library that I suggest you look at and study:
Look Ahead Example: turtles look ahead of them before moving so they don't step on blue patches
Wall Following Example: turtles treat brown patches as "walls", walking alongside them
In Look Ahead Example, the crucial snippet of turtle code is:
ifelse [pcolor] of patch-ahead 1 = blue
[ lt random-float 360 ] ;; We see a blue patch in front of us. Turn a random amount.
[ fd 1 ] ;; Otherwise, it is safe to move forward.
In Wall Following Example, the behavior of the turtles is more complicated, so the code is a more complicated, too.
I am using an existing model in netlogo called Chemical Equilibrium and am adding some more code. I want to add turtles (catalyst) which have no effect on the reaction/other turtles but speeds up the FORWARD reaction, which has been defined as follows:
to react-forward [t]
ask t [ set color red ]
set color green
rt random-float 360
jump 2
end
I was thinking that I should put a switch and a slider, make the turtles into whitemols or I do a turtles-own [catalyst] and then define that like I have done with temperature and pressure. I tried the following but it didnt work.
turtles-own [speed catalyst]
crt whitemols
[ set color white
randomize
set speed 1
]
I know the above code is incorrect but am not sure how to code this particular feature.
There are many ways to do this, of course. I can't tell what is going on in your program from the little snipped you include.
One way would be to have the catalyst be of a different breed:
breed [catalysts catalyst]
breed [chemical-x chemical-x]
;and so on
;then the forward reaction is sped up by the existence of catalysts
to react-forward
let num-catalysts count catalysts
;speed up by num-catalysts
;...
end