如何根据谁号码用鼠标放置海龟?

时间:2018-12-30 16:42:58

标签: netlogo

我正在尝试重新创建泡泡射击游戏,在该游戏中,通过使用鼠标将相同颜色的气泡朝该方向倾斜,弹出的行中会有彩色气泡。但是,由于我使用海龟作为气泡,因此当我创建多于2个进行拍摄时,这些海龟不会按照它们的编号顺序进行射击,除非使用inspect,否则我无法分辨我正在使用什么颜色。 / p>

我试图用foreach要求每只乌龟将它们的颜色列出到显示的列表中,并按照它们的编号顺序组织它们。我可以根据他们的人数将他们分类为一个列表,以显示其颜色,但是我无法命令他们以正确的顺序被射出。

到目前为止,这是我的代码:

 ;creates the bubbles to be shot
 set list1 []
   cro 10
     [set color one-of [red green blue violet]
      setxy 0 -12
      set size 3
      set shape "circle"]
  foreach sort-on [who] turtles with [who >= 80] with [who <= 99]
   [the-turtles -> ask the-turtles [set list1 lput [color] of self list1]]
    user-message "The list in the command center shows the colors of the 
    bubbles listed here in consecutive order. Refer to the note on the side 
    of the screen for refernce. Click game1 to angle and fire"
  show list1

   to game1
   ;creates the launcher from which turtles are fired from
   ask turtle 1 [face (patch mouse-xcor mouse-ycor)]
   ;moves the bubbles to the target
   foreach sort-on [who] turtles with [size = 3]
    [the-turtles -> ask the-turtles [
     if mouse-down? [ask the-turtles [wait .1 move-to patch mouse-xcor 
      mouse-ycor
     if count turtles in-radius 4 with [color = [color] of self] with [size 
      = 4] >= 3
     [ask turtles in-radius 2 with [color = [color] of self] with [size >= 
      3] [die]]]]]]  
     end
     ;size 3 is the size of the turtles I'm firing with the mouse
     ;size 4 is the size of the rows of turtles that will be "popped"

与其按人头顺序输出海龟,不如按我的排序列表1随机排序海龟。任何建议表示感谢,谢谢!

0 个答案:

没有答案