How to place turtles with mouse based on who number?












1















I'm trying to recreate the bubble shooter game where there are color bubbles in rows that you pop by angling bubbles of the same color in that direction using the mouse. However, since I am using turtles as the bubbles, when I create more than 2 to shoot, the turtles do not shoot in the order of their who number and I can't tell what color I'm using unless I use inspect.



I tried to use foreach to ask each turtle to list their colors into a list that is displayed and organize them to be shot in the order of their who numbers. I was able to sort them into a list based on their who numbers to display their colors, but I can't order them to be shot out in the correct order.



Here is my code so far:



 ;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"


Instead of outputting the turtles shot in the order of their who number, the turtles are ordered randomly in comparison to my ordered list1. Any advice is appreciated thank you!










share|improve this question



























    1















    I'm trying to recreate the bubble shooter game where there are color bubbles in rows that you pop by angling bubbles of the same color in that direction using the mouse. However, since I am using turtles as the bubbles, when I create more than 2 to shoot, the turtles do not shoot in the order of their who number and I can't tell what color I'm using unless I use inspect.



    I tried to use foreach to ask each turtle to list their colors into a list that is displayed and organize them to be shot in the order of their who numbers. I was able to sort them into a list based on their who numbers to display their colors, but I can't order them to be shot out in the correct order.



    Here is my code so far:



     ;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"


    Instead of outputting the turtles shot in the order of their who number, the turtles are ordered randomly in comparison to my ordered list1. Any advice is appreciated thank you!










    share|improve this question

























      1












      1








      1








      I'm trying to recreate the bubble shooter game where there are color bubbles in rows that you pop by angling bubbles of the same color in that direction using the mouse. However, since I am using turtles as the bubbles, when I create more than 2 to shoot, the turtles do not shoot in the order of their who number and I can't tell what color I'm using unless I use inspect.



      I tried to use foreach to ask each turtle to list their colors into a list that is displayed and organize them to be shot in the order of their who numbers. I was able to sort them into a list based on their who numbers to display their colors, but I can't order them to be shot out in the correct order.



      Here is my code so far:



       ;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"


      Instead of outputting the turtles shot in the order of their who number, the turtles are ordered randomly in comparison to my ordered list1. Any advice is appreciated thank you!










      share|improve this question














      I'm trying to recreate the bubble shooter game where there are color bubbles in rows that you pop by angling bubbles of the same color in that direction using the mouse. However, since I am using turtles as the bubbles, when I create more than 2 to shoot, the turtles do not shoot in the order of their who number and I can't tell what color I'm using unless I use inspect.



      I tried to use foreach to ask each turtle to list their colors into a list that is displayed and organize them to be shot in the order of their who numbers. I was able to sort them into a list based on their who numbers to display their colors, but I can't order them to be shot out in the correct order.



      Here is my code so far:



       ;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"


      Instead of outputting the turtles shot in the order of their who number, the turtles are ordered randomly in comparison to my ordered list1. Any advice is appreciated thank you!







      netlogo






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 30 '18 at 16:42









      SamSam

      304




      304
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53979487%2fhow-to-place-turtles-with-mouse-based-on-who-number%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53979487%2fhow-to-place-turtles-with-mouse-based-on-who-number%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mossoró

          Error while reading .h5 file using the rhdf5 package in R

          Pushsharp Apns notification error: 'InvalidToken'