Actors World

Actors World

Functions

Basic

Orientation(value::Symbol)

Defines a orientation. Possible values for value are defined in DIRECTIONS.

source
orientation_rotate(or::Orientation,::Type{Val{bool}})

Rotates a Orientation counter-clockwise for Val{false} and clockwise for Val{true}. Basically jumps to the next enty in DIRECTIONS. The last jumps to the first and the first to the last.

source
Location(x::Int,y::Int)

Stores a location defined by x and y on a gridded space.

source
location_move(lo::Location,or::Orientation)

Moves one step into the direction defined by the Orientation or.

source
Size(width::Int,height::Int)

Stores the size of a grid.

source

World

World(width::Int,height::Int)

Creates a new world with a given height and a given width.

source
location_within_world(wo::World,lo::Location)

Check if lo is within the bounds of the worlds size.

source
location_fix_ooBound(wo::World,lo::Location)

Fix a location lo which is out of bounds of the worlds size. The fix is made such that when leaving the world at one end the world is entered at the opposit end.

source
world_state_save(wo::World)

Conerts a world wo to a structure that holds all actors with their current location and orientation. Can be used with reset! to revert a world to a certain World_State.

Examples

julia> ws = world_state_save(some_world)
julia> # Do something in some_world
julia> reset!(some_world,ws)` # World is back to the saved state
source
reset!(wo::World,state::World_State)

Resets a wo back to a given state. The state is obtained from world_state_save.

Examples

julia> ws = world_state_save(some_world)
julia> # Do something in some_world
julia> reset!(some_world,ws)` # World is back to the saved state
source
reset!(wo::World_GUI)

Resets a world wo back to a given state wo.saved_world. Can be stored using store!(wo). Loading a world from a file stores to state at time of loading.

Examples

julia> store!(wo)
julia> # Do something in wo
julia> reset!(wo)
source

Actors

Actor_Definition(;<keyword arguments>)

Defines the behavior and the constraints of an actor.

Argmuments

  • moveable::Bool: Defines the movement of this actor.

  • turnable::Bool: Defines the rotation of this actor.

  • grabable::Bool: Defines if the actor can be picked-up and put-down

  • layer::Int : Defines the leayer the actor moves on

source
Actor(actor_definition::Actor_Definition,location::Location,orientation::Orientation)

Defines the actual actor which is placed on the world.

Examples

The following creates an actor which can be moved and turned. It is placed at (0,0) in the world and looks north.

julia> Actor(
    Actor_Definition(moveable=true,turnable=true),
    Location(0,0),
    Orientation(:NORTH)
)
source
actor_create!(wo::World,a_def::Actor_Definition,lo::Location,or::Orientation)

Creates a new actor defined by the actor definition a_def at Location lo, oriented in or. The actor is added to the world wo.

The functions returns the newly generated actor, thus to enable interaction it should be stored.

Examples

julia> wo = World(10,10)
julia> adef = Actor_Definition(
    moveable=true,
    turnable=true
)
julia> ac_new = actor_create(
    wo,adef,
    Location(1,1),Orientation(:NORTH)
)
julia> actor_move!(wo,ac_new,:NORTH)
source
actor_delete!(wo::World,ac::Actor)

Delete the actor ac from the World wo.

source
actor_moveto!(wo::World,ac::Actor,lo::Location)

Moves ac to lo after validating.

source
actor_move!(wo::World,ac::Actor,direction::Symbol[,parent::Bool])

Move the actor ac one step in the direction direction with the world wo. The optional attribute parent should never be used directly as its purpos is to only allow the movemnt of one consecutive moveable actor. It actually stops the movement recursion by switching from true to false, which only allows one nested layer of recursion.

source
actor_rotate!(ac::Actor,direction::Bool)

Rotate an actor ac by 1 step counter-clockwise for false and clockwise for true.

source
actor_pickup!(wo::World,ac::Actor)

Remove an grabable actor from the same location ac is at. Only elements one layer beneath the actors can be picked up.

source
actor_putdown!(wo::Word,ac::Actor,acd_put::Actor_Definition)

Create an actor of type acd_put at ac's location with ac's orientation. Only works if acd_put has grabable=true.

source
actor_validate_location_move(wo::World,a_def::Actor_Definition,lo::Location)

Validate if it's possible to place an actor of type a_def at lo.

source
get_actors_at_location(wo::World,lo::Location)

Return a list of actors at lo. If no actor is at lo return [].

source
get_actors_at_location_on_layer(wo::World,lo::Location,layer::Int)

Return a list of actors at lo on layer. If no actor is at lo return [].

source
actor_definition_at_location(wo::World,lo::Location,acd::Actor_Definition)

Checks if an actor of type acd is at lo in wo.

source
is_actor_definition_left(wo::World,ac::Actor,acd::Actor_Definition)

Checks if an actor of type acd is left of ac.

source
is_actor_definition_right(wo::World,ac::Actor,acd::Actor_Definition)

Checks if an actor of type acd is right of ac.

source
is_actor_definition_front(wo::World,ac::Actor,acd::Actor_Definition)

Checks if an actor of type acd is front of ac.

source
is_actor_definition_here(wo::World,ac::Actor,acd::Actor_Definition)

Checks if an actor of type acd is here of ac.

source

Index