Error: MOVE-TO expected input to be an agent but got NOBODY instead. NetLogo

474 views
Skip to first unread message

Rafaela Lorena

unread,
May 21, 2021, 9:59:04 AM5/21/21
to netlogo-users
Hello everyone,

Sorry to be pestering you. I am starting at NetLogo. And sometimes errors appear that I don't understand if someone can help with suggestions or models that already exist that do what I'm trying to code. I am very grateful.

I would like to encode the following:

  1. The world is closed (box) and has 5 colors: green, pink, cyan, blue and gray (represents vegetation types)

  2. The turtle asks what color the patch is in if it is green or pink, it can walk on the green or pink patches. If it is blue or cyan, the turtle can walk on blue or cyan patches

  3.  If the color patch is gray fd 1

error: MOVE-TO expected input to be an agent but got NOBODY instead.

The code bellow:

globals [ edge-size ]

to setup
    clear-all
      set edge-size 10
      set-patch-size 20
      let pcolors []
      set pcolors [135 55 105 85 5 ]
      ask patches [
        set pcolor item (random 5) pcolors
        ]
      crt 1 [
        set size 1
        set color black
        ;pen-down
      ]
    reset-ticks
    end

to go
  ask turtles [

    if pcolor = green or pcolor = pink ;; if own pcolor patch = green
    [ move-to one-of patches with [ pcolor = "green" or pcolor = "pink" ] ]
   
    if pcolor = blue or pcolor = cyan ;; if own pcolor patch = blue
    [ move-to one-of patches with [ pcolor = "blue" or pcolor = "cyan" ] ]
   
    if pcolor = gray ;; if own pcolor patch = gray
    [ fd 1 ]
  ]
end

vidus...@gmail.com

unread,
May 23, 2021, 11:30:27 PM5/23/21
to netlogo-users
Hi Rafael 

According to the conditions mentioned in your question,  you only want your turtle to skip grey patch and your turtle can move to any of green, pink , cyan or blue patch. 
Please correct me if I misunderstood this.   If this is the case, you can use ifelse to skip grey-patch. There are different ways you can do that. One way is :

to go
  ask turtles [
     let grey-patch neighbors with [ pcolor = grey ]
    fd 1 
    ifelse patch-ahead 1 = grey-patch  [ fd 2 ] [ move-to one-of neighbors with [ pcolor = green or pcolor = pink or pcolor = blue or pcolor = cyan ]] 
tick
end 
       
Hope this helps

Cheers 

Vidushi

Rafaela Lorena

unread,
May 24, 2021, 7:43:26 AM5/24/21
to vidus...@gmail.com, netlogo-users
Hi Vidushi,

Thanks a lot for your suggestion!

Cheers

--
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/cdbdff5c-addf-44f2-b81b-85917b8d7710n%40googlegroups.com.

Aaron Andre Brandes

unread,
May 24, 2021, 9:25:07 AM5/24/21
to Rafaela Lorena, netlogo-users

Hi Lorena,

The color names are NetLogo variables, so they should not be in quotes.

    [ move-to one-of patches with [ pcolor = green or pcolor = pink ]

 

If you type show pink in the command center it will output 135, the number corresponding to pink.

 

You could initialize your colors as set pcolors [green pink blue cyan gray ] if you wanted.

Aaron

 

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

 

 

From: <netlog...@googlegroups.com> on behalf of Rafaela Lorena <rafael...@gmail.com>
Date: Friday, May 21, 2021 at 9:59 AM
To: netlogo-users <netlog...@googlegroups.com>
Subject: [netlogo-users] Error: MOVE-TO expected input to be an agent but got NOBODY instead. NetLogo

 

Hello everyone,

Sorry to be pestering you. I am starting at NetLogo. And sometimes errors appear that I don't understand if someone can help with suggestions or models that already exist that do what I'm trying to code. I am very grateful.

 

I would like to encode the following:

1.       The world is closed (box) and has 5 colors: green, pink, cyan, blue and gray (represents vegetation types)

2.       The turtle asks what color the patch is in if it is green or pink, it can walk on the green or pink patches. If it is blue or cyan, the turtle can walk on blue or cyan patches

3.        If the color patch is gray fd 1

--

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.

Rafaela Lorena

unread,
May 24, 2021, 9:51:51 AM5/24/21
to Aaron Andre Brandes, netlogo-users
Hi Aaron Andre Brandes

Awesome, thanks! I  hadn't realized that I had put the quotes in the color.

Cheers
Reply all
Reply to author
Forward
0 new messages