Uses the characteristics of an object to add a goal to it.
Usage
add_goal(object, ...)
# S4 method for class 'object'
add_goal(object, background, id = character(0), counter = 5, ...)Arguments
- object
Object or instance of the
object-class.- ...
Arguments passed on to
rng_point- background
Object of
background-classcontaining all objects in the environment that can have a goal attached to them in itsobjectsslot.- id
Character that serves as an identifier for the goal. Defaults to an empty character, triggering the random generation of an id.
- counter
Numeric denoting the number of time steps the agent should interact with the goal before the goal has been completed. Defaults to
5.
Value
Object of goal-class.
Details
Takes in an instance of object-class and uses its
characteristics to generate an instance of goal-class
that is attached to it. In practice, uses one of the objects in the
objects slot of a background-class instance.
Is defined for all instances of object-class except for
segment-class, which cannot contain goals due to its
primary function.
Examples
# Create a background
my_background <- background(shape = rectangle(center = c(0, 0),
size = c(2, 2)))
# Adjust the objects in the background for each of the different objects to
# showcase how add_goals works for each
objects(my_background) <- list(circle(center = c(0, 0), radius = 0.5))
add_goal(my_background@objects[[1]],
my_background)
#> Goal Attributes
#> busy: FALSE
#> counter: 5
#> done: FALSE
#> id: goal lqeqm
#> path:
#> [,1] [,2]
#>
#> position: -0.1306111 -0.4929916
#>
#> For more detailed information, please extract the wanted information from the background directly.
objects(my_background) <- list(rectangle(center = c(0, 0), size = c(1, 1)))
add_goal(my_background@objects[[1]],
my_background)
#> Goal Attributes
#> busy: FALSE
#> counter: 5
#> done: FALSE
#> id: goal ewkad
#> path:
#> [,1] [,2]
#>
#> position: 0 -0.5070711
#>
#> For more detailed information, please extract the wanted information from the background directly.
objects(my_background) <- list(polygon(points = cbind(c(0.5, 0.5, -0.5, -0.5),
c(0.5, -0.5, -0.5, 0.5))))
add_goal(my_background@objects[[1]],
my_background)
#> Goal Attributes
#> busy: FALSE
#> counter: 5
#> done: FALSE
#> id: goal sifmm
#> path:
#> [,1] [,2]
#>
#> position: 0.5070711 0
#>
#> For more detailed information, please extract the wanted information from the background directly.