# This will probably fail if the way "ask" interacts with
# the RNG changes.  If this fails, all the model checksums
# are likely to change, too. - ST 1/9/07
AskRNG
  O> random-seed 0
  O> ask n-of 4 patches [ sprout 1 ]
  [(list xcor ycor color heading)] of turtle 0 => [3 3 95 57]
  [(list xcor ycor color heading)] of turtle 1 => [5 2 95 200]
  [(list xcor ycor color heading)] of turtle 2 => [3 2 125 236]
  [(list xcor ycor color heading)] of turtle 3 => [-4 3 25 215]

# version 1: use 1-input procedure to terminate the recursion
RecursiveCallInsideAsk1
  globals [glob1]
  to go1 crt 1 go2 5 crt 1 end
  to go2 [x] ask turtle 0 [ set glob1 glob1 + 1 if x > 0 [ go2 (x - 1) ] ] end
  O> set glob1 0
  O> go1
  count turtles => 2
  glob1 => 6

# version 2: 0-input procedure, use RNG to terminate the recursion
RecursiveCallInsideAsk2
  globals [glob1]
  to go1 crt 1 go2 crt 1 end
  to go2 ask turtle 0 [ set glob1 glob1 + 1 if random 10 > 0 [ go2 ] ] end
  O> set glob1 0
  O> random-seed 0
  O> go1
  count turtles => 2
  glob1 => 27

recursion-over-ask
  turtles-own [tvar]
  to explore if tvar = 0 [ set tvar 1 ask turtles-on neighbors [ explore ] ] end
  O> ask patches [ sprout 1 ]
  O> ask one-of turtles [ explore ]
  any? turtles with [tvar = 0] => false

AskInsideReporterProcedure
  globals [glob1]
  to-report foo ask turtle 1 [ set glob1 who ] report 10 end
  O> crt 2
  [foo] of turtle 0 => 10
  glob1 => 1

AskConcurrentDoesntWorkOnSingleAgent
  globals [glob1]
  O> crt 1 [ set glob1 self ]
  O> ask-concurrent glob1 [ set pcolor red ] => ERROR ASK-CONCURRENT expected input to be an agentset but got the turtle (turtle 0) instead.

AskAllTurtles
  O> crt 1
  O> ask one-of patches [ ask turtles [ die ] ] => ERROR Only the observer can ASK the set of all turtles.
  O> ask one-of turtles [ ask turtles [ die ] ] => ERROR Only the observer can ASK the set of all turtles.

AskAllPatches
  O> crt 1
  O> ask one-of patches [ ask patches [ sprout 1 ] ] => ERROR Only the observer can ASK the set of all patches.
  O> ask one-of turtles [ ask patches [ sprout 1 ] ] => ERROR Only the observer can ASK the set of all patches.

