( x . y )
email: frank@consxy.com | resume (pdf)

Package CLNL-NVM (link)

CLNL NVM

NetLogo Virtual Machine: the simulation engine.

Contents (link)

  • function agent-value* - agent-value is the general agent variable access function. For many NetLogo reporters, the compilation results is agent-value. The list of valid values are any builtin variable in the NetLogo dictionary, as well as any -own variable.
  • function ask - ask is equivalent to ask in NetLogo.
  • function clear-all - Clears ticks, turtles, patches, globals (unimplemented).
  • function count - count is equivalent to count in netLogo. Returns n, the number of agents in agentset.
  • function create-turtles - Creates n new turtles at the origin.
  • function create-world - Initializes the world in the NVM.
  • function current-state - Dumps out the state of the world.
  • function die - The turtle or link dies
  • function display - As of yet, this does nothing. A placeholder method for forced dipslay updates from the engine.
  • function export-world - Dumps out a csv matching NetLogo's export world.
  • function forward - Moves the current turtle forward n steps, one step at a time.
  • function hatch - The turtle in self creates n new turtles. Each new turtle inherits of all its variables, including its location, from self.
  • function lookup-color - Returns the number used to represent colors in NetLogo.
  • function of - of is equivalent to of in NetLogo.
  • function one-of - From an agentset, returns a random-agent. If the agentset is empty, returns :nobody. From a list, returns a random-value. If the list is empty, an error occurs.
  • function patches - Reports the agentset consisting of all the patches.
  • function random - Returns a random number strictly closer to zero than n.
  • function random-float - Returns a random number strictly closer to zero than n.
  • function random-xcor - Returns a random floating point number in the allowable range of turtle coordinates along the x axis.
  • function random-ycor - Returns a random floating point number in the allowable range of turtle coordinates along the y axis.
  • function reset-ticks - Resets the tick counter to zero, sets up all plots, then updates all plots.
  • function set-default-shape - Specifies a default initial shape for a breed. When a turtle, or it changes breeds, its shape is set to the given shape.
  • function setxy - Sets the x-coordinate and y-coordinate for the turle. Equivalent to set xcor x set ycor y, except it happens in one step inside of two.
  • function show - A command that prints the given NetLogo value to the command center.
  • function stop - Returns from the current stop block, which will halt the currently running thing, be that the program, current ask block, or procedure. Stop has odd semantics that are best gleaned from the actual NetLogo manual.
  • function tick - Advances the tick counter by one and updates all plots.
  • function ticks - Reports the current value of the tick counter. The result is always a number and never negative.
  • function turn-left - The turtle turns left by number degrees. (If number is negative, it turns right.)
  • function turn-right - The turtle turns right by number degrees. (If number is negative, it turns left.)
  • function turtles - Reports the agentset consisting of all the turtles.
  • function turtles-here - Returns the agentset consisting of all the turtles sharing the patch with the agent in by self
  • function with - with is equivalent to with in NetLogo.
  • function with-stop-handler - with-stop-handler is a convenience macro to handle when programs issue a stop condition. When one does, a simple :stop is returned.

Function AGENT-VALUE (link)

Syntax:

agent-value var &optional agent => result

Arguments and Values:

var---A variable name agent---an agent, defaulting to self result---the value of var

Description:

agent-value is the general agent variable access function. For many NetLogo reporters, the compilation results is agent-value. The list of valid values are any builtin variable in the NetLogo dictionary, as well as any *-own variable.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html for builtins

Function ASK (link)

Syntax:

ask agent-or-agentset fn => result

agent-or-agentset::= agent | agentset result::= :undefined

Arguments and Values:

fn---a function, run on each agent agent---a NetLogo agent agentset---a NetLogo agentset

Description:

ask is equivalent to ask in NetLogo.

The specified agentSET or agent runs the given fn. In the case of an agentSET, the order in which the agents are run is random each time, and only agents that are in the set at the beginning of the call.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#ask

Function CLEAR-ALL (link)

Syntax:

clear-all => result

result::= :undefined

Description:

Clears ticks, turtles, patches, globals (unimplemented).

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#clear-all

Function COUNT (link)

Syntax:

count agentset => n

Arguments and Values:

agentset---a netLogo agentset n---a number

Description:

count is equivalent to count in netLogo. Returns n, the number of agents in agentset.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#count

Function CREATE-TURTLES (link)

Syntax:

create-turtles n &optional breed fn => result

result::= :undefined

Arguments and Values:

n---an integer, the numbers of turtles to create breed---a breed fn---A function, applied to each turtle after creation

Description:

Creates n new turtles at the origin.

new turtles have random integer headings and the color is randomly selected from the 14 primary colors. If Fn is supplied, the new turtles immediately run it. If a breed is supplied, that is the breed the new turtles are set to.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#create-turtles

Function CREATE-WORLD (link)

Syntax:

create-world &key dims globals turtles-own-vars patches-own-vars breeds => result

```dims::= (:xmin xmin :xmax xmax :ymin ymin :ymax ymax) globals::= global turtles-own-vars::= turtles-own-var patches-own-vars::= patches-own-var breeds::= breed``` result::= :undefined global::= (global-name global-access-func)

Arguments and Values:

xmin---An integer representing the minimum patch coord in X xmax---An integer representing the maximum patch coord in X ymin---An integer representing the minimum patch coord in Y ymax---An integer representing the maximum patch coord in Y turtles-own-var---Symbol for the turtles own variable in the keyword package patches-own-var---Symbol for the patches own variable in the keyword package breed---A list of symbols representing the possible preeds global-name---Symbol for the global in the keyword package global-access-func---Function to get the value of the global

Description:

Initializes the world in the NVM.

This should be called before using the engine in any real capacity. If called when an engine is already running, it may do somethign weird.

Function CURRENT-STATE (link)

Syntax:

current-state => world-state

Arguments and Values:

world-state---A list, the current state of the whole world

Description:

Dumps out the state of the world.

This is useful for visualizations and also storing in a common lisp data structure for easy usage in a common lisp instance. It's preferable to use this when working with the nvm than the output done by export-world.

Currently this only dumps out turtle and patch information.

This is called current-state because export-world is an actual primitive used by NetLogo.

Function DIE (link)

Syntax:

die => result

result::= :undefined

Description:

The turtle or link dies

A dead agent ceases to exist. The effects of this include: - The agent will not execute any further code. - The agent will disappear from any agentsets it was in, reducing the size of those agentsets by one. - Any variable that was storing the agent will now instead have nobody in it. - If the dead agent was a turtle, every link connected to it also dies. - If the observer was watching or following the agent, the observer's perspective resets.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#die

Function DISPLAY (link)

Syntax:

display => result

result::= :undefined

Description:

As of yet, this does nothing. A placeholder method for forced dipslay updates from the engine.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#display

Function EXPORT-WORLD (link)

Syntax:

export-world => world-csv

Arguments and Values:

world-csv---A string, the csv of the world

Description:

Dumps out a csv matching NetLogo's export world.

This is useful for serializing the current state of the engine in order to compare against NetLogo or to reimport later. Contains everything needed to boot up a NetLogo instance in the exact same state.

Function FORWARD (link)

Syntax:

forward n => result

result::= :undefined

Arguments and Values:

n---a double, the amount the turtle moves forward

Description:

Moves the current turtle forward n steps, one step at a time.

This moves forward one at a time in order to make the view updates look good in the case of a purposefully slow running instance. If the number is negative, the turtle moves backward.

If the current agent is not a turtle, it raises an error.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#forward

Function HATCH (link)

Syntax:

hatch n &optional fn => result

result::= :undefined

Arguments and Values:

n---an integer, the numbers of turtles to hatch fn---A function, applied to each turtle after creation

Description:

The turtle in self creates n new turtles. Each new turtle inherits of all its variables, including its location, from self.

If Fn is supplied, the new turtles immediately run it.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#hatch

Function LOOKUP-COLOR (link)

Syntax:

lookup-color color => color-number

Arguments and Values:

color---a symbol representing a color color-number---the NetLogo color integer

Description:

Returns the number used to represent colors in NetLogo.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#Constants

Function OF (link)

Syntax:

of fn agent-or-agentset => result

agent-or-agentset::= agent | agentset result::= result-list | result-value

Arguments and Values:

fn---a function, run on each agent agent---a NetLogo agent agentset---a NetLogo agentset result-list---a list result-value---a single value

Description:

of is equivalent to of in NetLogo.

The specified agentSET or agent runs the given fn. In the case of an agentSET, the order in which the agents are run is random each time, and only agents that are in the set at the beginning of the call.

result-LIST is returned when the input is an agentSET, but result-VALUE is returned when only passed an agent.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#of

Function ONE-OF (link)

Syntax:

one-of list-or-agentset => result

list-or-agentset::= list | agentset result::= random-value | random-agent | :nobody

Arguments and Values:

list---A list agentset---An agent set random-value---a value in list random-agent---an agent if agentset is non empty

Description:

From an agentset, returns a random-agent. If the agentset is empty, returns :nobody. From a list, returns a random-value. If the list is empty, an error occurs.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#one-of

Function PATCHES (link)

Syntax:

patches => all-patches

Arguments and Values:

all-patches---a NetLogo agentset, all patches

Description:

Reports the agentset consisting of all the patches.

This agentset is special in that it represents the living patches each time it's used, so changes depending on the state of the engine.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#patches

Function RANDOM (link)

Syntax:

random n => random-number

Arguments and Values:

n---an integer, the upper bound of the random random-number---an integer, the random result

Description:

Returns a random number strictly closer to zero than n.

If number is positive, returns a random integer greater than or equal to 0, but strictly less than number.

If number is negative, returns a random integer less than or equal to 0, but strictly greater than number.

If number is zero, the result is always 0.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#random

Function RANDOM-FLOAT (link)

Syntax:

random-float n => random-number

Arguments and Values:

n---a double, the upper bound of the random float random-number---a double, the random result

Description:

Returns a random number strictly closer to zero than n.

If number is positive, returns a random floating point number greater than or equal to 0 but strictly less than number.

If number is negative, returns a random floating point number less than or equal to 0, but strictly greater than number.

If number is zero, the result is always 0.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-float

Function RANDOM-XCOR (link)

Syntax:

random-xcor => random-number

Arguments and Values:

random-number---a float, the random result

Description:

Returns a random floating point number in the allowable range of turtle coordinates along the x axis.

These range from min-pxcor - 0.5 (inclusive) to max-pxcor + 0.5 (exclusive)

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-cor

Function RANDOM-YCOR (link)

Syntax:

random-ycor => random-number

Arguments and Values:

random-number---a float, the random result

Description:

Returns a random floating point number in the allowable range of turtle coordinates along the y axis.

These range from min-pycor - 0.5 (inclusive) to max-pycor + 0.5 (exclusive)

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-cor

Function RESET-TICKS (link)

Syntax:

reset-ticks => result

result::= :undefined

Description:

Resets the tick counter to zero, sets up all plots, then updates all plots.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#reset-ticks

Function SET-DEFAULT-SHAPE (link)

Syntax:

set-default-shape breed shape => result

result::= :undefined

Arguments and Values:

breed---a valid breed shape---a string

Description:

Specifies a default initial shape for a breed. When a turtle, or it changes breeds, its shape is set to the given shape.

set-default-shape doesn't affect existing agents, only agents you create afterwards.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#set-default-shape

Function SETXY (link)

Syntax:

setxy x y => result

result::= :undefined

Arguments and Values:

x---a double y---a double

Description:

Sets the x-coordinate and y-coordinate for the turle. Equivalent to set xcor x set ycor y, except it happens in one step inside of two.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#setxy

Function SHOW (link)

Syntax:

show value => result

result::= :undefined

Arguments and Values:

value---a NetLogo value

Description:

A command that prints the given NetLogo value to the command center.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#show

Function STOP (link)

Syntax:

stop => result

result::= :undefined

Description:

Returns from the current stop block, which will halt the currently running thing, be that the program, current ask block, or procedure. Stop has odd semantics that are best gleaned from the actual NetLogo manual.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#stop

Function TICK (link)

Syntax:

tick => result

result::= :undefined

Description:

Advances the tick counter by one and updates all plots.

If the tick counter has not been started yet with reset-ticks, an error results.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#tick

Function TICKS (link)

Syntax:

ticks => current-ticks

Arguments and Values:

current-ticks---A positiv double, representing the current number of ticks

Description:

Reports the current value of the tick counter. The result is always a number and never negative.

If the tick counter has not been started yet with reset-ticks, an error results.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#ticks

Function TURN-LEFT (link)

Syntax:

turn-left n => result

result::= :undefined

Arguments and Values:

n---a double, the amount the turtle turns

Description:

The turtle turns left by number degrees. (If number is negative, it turns right.)

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#right

Function TURN-RIGHT (link)

Syntax:

turn-right n => result

result::= :undefined

Arguments and Values:

n---a double, the amount the turtle turns

Description:

The turtle turns right by number degrees. (If number is negative, it turns left.)

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#right

Function TURTLES (link)

Syntax:

turtles => all-turtles

Arguments and Values:

all-turtles---a NetLogo agentset, all turtles

Description:

Reports the agentset consisting of all the turtles.

This agentset is special in that it represents the living turtles each time it's used, so changes depending on the state of the engine.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#turtles

Function TURTLES-HERE (link)

Syntax:

turtles-here => turtles

Arguments and Values:

turtles---an agentset

Description:

Returns the agentset consisting of all the turtles sharing the patch with the agent in by self

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#turtles-here

Function WITH (link)

Syntax:

with agentset fn => result-agentset

Arguments and Values:

agentset---a NetLogo agentset fn---a boolean function, run on each agent to determine if included result-agentset---an agentset of valid agents

Description:

with is equivalent to with in NetLogo.

Returns a new agentset containing only those agents that reported true when fn is called.

See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#with

Function WITH-STOP-HANDLER (link)

Syntax:

with-stop-handler &rest forms => handled-form

Arguments and Values:

forms---body to be handled handled-form---body with handling

Description:

with-stop-handler is a convenience macro to handle when programs issue a stop condition. When one does, a simple :stop is returned.