How to remove the patches on the center square?

27 views
Skip to first unread message

Mustafa Ali Saba

unread,
Nov 10, 2019, 2:25:57 PM11/10/19
to netlogo-users

Dear community,

I am drawing the following world
crossing.jpg











My Netlogo code is the following,

to draw-crossing
  let top
-wall 0
  let bottom
-wall 0
  let right
-wall 0
  let left
-wall 0
 
  ask patches
[set pcolor 9]
 
 
; Draw top wall
  repeat
81 [
    ask patch top
-wall ((corridor-width + 1) / 2) [
     
set pcolor 0
      show top
-wall
   
]
   
set top-wall (top-wall + 1)
 
]
 
 
; Draw bottom wall
  repeat
81 [
    ask patch bottom
-wall (-((corridor-width + 1) / 2)) [
     
set pcolor 0
   
]
   
set bottom-wall (bottom-wall + 1)
 
]
 
 
; Draw right wall
  repeat
41 [
    ask patch
((corridor-width + 1) / 2) right-wall [
     
set pcolor 0
   
]
   
set right-wall (right-wall + 1)
 
]
 
 
; Draw left wall
  repeat
41 [
    ask patch
(-((corridor-width + 1) / 2)) left-wall [
     
set pcolor 0
   
]
   
set left-wall (left-wall + 1)
 
]
end

and the output of this is.
core view2.png











What I wanna do is to remove those lines which form that square on the middle, and let the figure be like the one above.

Warm regards.

Jacob Kelter

unread,
Nov 10, 2019, 10:45:19 PM11/10/19
to Mustafa Ali Saba, netlogo-users
Hi Mustafa,

Instead of using repeat, you can use a with statement like this to draw the top and bottom walls with the gap you want:
ask patches with [(abs pycor) = ((corridor-width + 1) / 2) and (abs pxcor) > corridor-width] [set pcolor 0]

You can use a similar statement to draw the left and right wall.

Best,
Jacob 

--
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/617aba50-197c-4310-97dc-d912335697f1%40googlegroups.com.


--

Wade Schuette

unread,
Nov 10, 2019, 10:47:39 PM11/10/19
to netlogo-users


On Sunday, November 10, 2019 at 11:25:57 AM UTC-8, Mustafa Ali Saba wrote:

Dear community,

I am drawing the following world
crossing.jpg










What I wanna do is to remove those lines which form that square on the middle, and let the figure be like the one above.

Warm regards.
===========
   Here's a work-around.  The filetypes are all .png,

   The easiest thing to do is draw your walls in some paint program as you already have done, and then use

       import-pcolors filename

  to import the results.    To export a view you can use

      export-view filename


 Otherwise you can clear both roads.  ask all patches with pycor between two values to set pcolor to white.  Then ask all patches with pxcor between two values to set pcolor to white.  Importing a png file is much nicer if the world becomes more complicated, such as a maze, or the interior walls of a building for modeling fire escape.


Reply all
Reply to author
Forward
0 new messages