Is there a way to improve my program to draw this corridor?

12 views
Skip to first unread message

Mustafa Ali Saba

unread,
Sep 26, 2019, 1:24:28 AM9/26/19
to netlogo-users

Dear community,

I am drawing a simple corridor in NetLogo, I already have an horizontal corridor as this.
But I been wondering if there is another way of doing it, I mean a better one.

to draw-walls-x
  let top-wall 0
  let bottom-wall 0
  let width 5
  ; repeat 81 because my world has dimensions of 80 x 40.
  repeat 81 [ 
    ask patch top-wall ((width + 1) / 2) [ set pcolor black ]
    set top-wall (top-wall + 1)
  ]
  repeat 81 [
    ask patch bottom-wall (-((width + 1) / 2)) [ set pcolor black ]
    set bottom-wall (bottom-wall + 1)
  ]
end

Thanks to all suggestions!

------------------
Ali

Jacob Kelter

unread,
Sep 26, 2019, 3:02:55 PM9/26/19
to Mustafa Ali Saba, netlogo-users
I would suggest using with instead of repeat. So something like:
ask patches with [abs pycor = ((width + 1) / 2)] [set pcolor black]

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/cfeae8c1-1c2e-42b1-af03-4a070fe87b7f%40googlegroups.com.


--

Reply all
Reply to author
Forward
0 new messages