views:

322

answers:

2

I am new to NetLogo software and I am trying to create a 5x5 grid with 2 exits and put some walls in it (in other words i want to create a maze or a labyrinth).

I was wondering if there is a way to make thicker or change the colour of only the side and not the whole patch.

I want to put only one agent inside and let him find the exit by rewarding him with some points. (Q-learning algorithm)

Does anyone have an idea?

If this is not possible can you suggest a code please?

Here is an example of what i want to create:

alt text

Because you asked me to post some of my work (although I said its a bit stupid to do this manually) here it is what I have done:

breed [frame frames]
to setup
  ca
    ask patches [ set pcolor white]

ask patch -7 8 [ set pcolor black]
ask patch -6 8 [ set pcolor black]
ask patch -5 8 [ set pcolor black]
ask patch -4 8 [ set pcolor black]
ask patch -3 8 [ set pcolor black]
ask patch -2 8 [ set pcolor black]
ask patch -1 8 [ set pcolor black]
ask patch 1 8 [ set pcolor black]
ask patch 0 8 [ set pcolor black]
ask patch 2 8 [ set pcolor black]
ask patch 3 8 [ set pcolor black]

ask patch 6 8 [ set pcolor black]
ask patch 7 8 [ set pcolor black]
ask patch 8 8 [ set pcolor black]

ask patch -7 7 [ set pcolor black]
ask patch -7 6 [ set pcolor black]
ask patch -7 5 [ set pcolor black]
ask patch -7 4 [ set pcolor black]
ask patch -7 3 [ set pcolor black]
ask patch -7 2 [ set pcolor black]
ask patch -7 1 [ set pcolor black]
ask patch -7 0 [ set pcolor black]
ask patch -7 -1 [ set pcolor black]
ask patch -7 -2 [ set pcolor black]
ask patch -7 -3 [ set pcolor black]
ask patch -7 -4 [ set pcolor black]
ask patch -7 -5 [ set pcolor black]
ask patch -7 -6 [ set pcolor black]
ask patch -7 -7 [ set pcolor black]

ask patch -7 -7 [ set pcolor black]
ask patch -6 -7 [ set pcolor black]
ask patch -5 -7 [ set pcolor black]
ask patch -4 -7 [ set pcolor black]
ask patch -3 -7 [ set pcolor black]
ask patch -2 -7 [ set pcolor black]
ask patch -1 -7 [ set pcolor black]
ask patch 1 -7 [ set pcolor black]
ask patch 0 -7 [ set pcolor black]
ask patch 2 -7 [ set pcolor black]
ask patch 3 -7 [ set pcolor black]
ask patch 4 -7 [ set pcolor black]
ask patch 5 -7 [ set pcolor black]

ask patch 8 -7 [ set pcolor black]

ask patch 8 8  [ set pcolor black]
ask patch 8 7  [ set pcolor black]
ask patch 8 6 [ set pcolor black]
ask patch 8 5 [ set pcolor black]
ask patch 8 4 [ set pcolor black]
ask patch 8 3 [ set pcolor black]
ask patch 8 2 [ set pcolor black]
ask patch 8 1 [ set pcolor black]
ask patch 8 0 [ set pcolor black]
ask patch 8 -1 [ set pcolor black]
ask patch 8 -2 [ set pcolor black]
ask patch 8 -3 [ set pcolor black]
ask patch 8 -4 [ set pcolor black]
ask patch 8 -5 [ set pcolor black]
ask patch 8 -6 [ set pcolor black]

ask patch -6 5 [ set pcolor black]
ask patch -5 5 [ set pcolor black]
ask patch -4 5 [ set pcolor black]
ask patch -4 4 [ set pcolor black]
ask patch -4 3 [ set pcolor black]
ask patch -4 2 [ set pcolor black]
ask patch -4 -1 [ set pcolor black]
ask patch -4 -2 [ set pcolor black]
ask patch -4 -3 [ set pcolor black]
ask patch -4 -4 [ set pcolor black]
ask patch -5 -4 [ set pcolor black]
ask patch -6 -4 [ set pcolor black]
ask patch -1 7 [ set pcolor black]
ask patch -1 6 [ set pcolor black]
ask patch -1 5 [ set pcolor black]
ask patch -1 4 [ set pcolor black]
ask patch -1 3 [ set pcolor black]
ask patch -1 2 [ set pcolor black]
ask patch 2 5 [ set pcolor black]
ask patch 2 4 [ set pcolor black]
ask patch 2 3 [ set pcolor black]
ask patch 2 2 [ set pcolor black]
ask patch 5 5 [ set pcolor black]
ask patch 5 4 [ set pcolor black]
ask patch 5 3 [ set pcolor black]
ask patch 5 2 [ set pcolor black]
ask patch 5 1 [ set pcolor black]
ask patch 5 0 [ set pcolor black]
ask patch 5 -1 [ set pcolor black]
ask patch 6 5 [ set pcolor black]
ask patch 7 5 [ set pcolor black]
ask patch -1 -1 [ set pcolor black]
ask patch 0 -1 [ set pcolor black]
ask patch 1 -1 [ set pcolor black]
ask patch 2 -1 [ set pcolor black]
ask patch 3 -1 [ set pcolor black]
ask patch 4 -1 [ set pcolor black]
ask patch -1 -2 [ set pcolor black]
ask patch -1 -3 [ set pcolor black]
ask patch -1 -4 [ set pcolor black]
ask patch 0 -4 [ set pcolor black]
ask patch 1 -4 [ set pcolor black]
ask patch 2 -4 [ set pcolor black]
ask patch 3 -4 [ set pcolor black]
ask patch 4 -4 [ set pcolor black]
ask patch 5 -4 [ set pcolor black]
end

But again this is the stupid way to do it. Even if I keep this way how can I merge 4 patches into 1 so that I can enter my agent inside and be centred???

Thank you in advance

A: 

Try looking at the code in this maze-maker netlogo model. The basic idea for the algorithm is to use a random walker that builds walls (path) as he walks. When he reaches a dead end he is teleported to a previous place where he took a turn.

Have fun! There is, of course a wikipedia entry on maze generation algorithms if you want to delve deeper.

Jose M Vidal
Thanks a lot. I'll have a look and i'll try it out.
A: 

To highlight the edge of a patch, you'll need to use a turtle. Make a turtle shape that just consists of a line, then create a turtle with that shape and position it accordingly. You'll probably want to use a separate breed of turtles (call them "walls", say).

Once you've created the turtle, you can either keep it around if you want to do something with it later, or you can have it do "stamp die" to kill it but first have it leave an image of itself behind in the drawing.

Seth Tisue