Creating a random shape (blob) of a given area in NetLogo

后端 未结 3 1024
失恋的感觉
失恋的感觉 2020-12-10 17:27

Is it possible to create random shapes (see below for example) of a given area in NetLogo?

\"enter

3条回答
  •  一生所求
    2020-12-10 17:48

    A first stab at Seth's suggestion #1. It creates a neat visual too!

    patches-own [ height ]
    
    to blobbify
      clear-all
      repeat (ceiling 2 * (ln (world-height * world-width))) [
        ask patch (round (random (world-width / 2)) - world-width / 4)
                  (round (random (world-height / 2)) - world-height / 4)
                  [ set height world-width * world-height ] ]
      while [ count patches with [ height > 1 ] < (world-width * world-height / 4)] 
            [ diffuse height 1
              ask patches with [ height > 0 ] [ set pcolor height ]
            ]
       ask patches with [ height > 1 ] [ set pcolor white ]
    end
    

提交回复
热议问题