Actors World
Functions
Basic
Orientation(value::Symbol)Defines a orientation. Possible values for value are defined in DIRECTIONS.
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.
Location(x::Int,y::Int)Stores a location defined by x and y on a gridded space.
location_move(lo::Location,or::Orientation)Moves one step into the direction defined by the Orientation or.
Size(width::Int,height::Int)Stores the size of a grid.
World
World(width::Int,height::Int)Creates a new world with a given height and a given width.
location_within_world(wo::World,lo::Location)Check if lo is within the bounds of the worlds size.
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.
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 stateJuliaKara.JuliaKara_noGUI.ActorsWorld.reset! — Function.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 statereset!(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)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-downlayer::Int: Defines the leayer the actor moves on
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)
)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)actor_delete!(wo::World,ac::Actor)Delete the actor ac from the World wo.
actor_moveto!(wo::World,ac::Actor,lo::Location)Moves ac to lo after validating.
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.
actor_rotate!(ac::Actor,direction::Bool)Rotate an actor ac by 1 step counter-clockwise for false and clockwise for true.
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.
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.
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.
get_actors_at_location(wo::World,lo::Location)Return a list of actors at lo. If no actor is at lo return [].
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 [].
actor_definition_at_location(wo::World,lo::Location,acd::Actor_Definition)Checks if an actor of type acd is at lo in wo.
is_actor_definition_left(wo::World,ac::Actor,acd::Actor_Definition)Checks if an actor of type acd is left of ac.
is_actor_definition_right(wo::World,ac::Actor,acd::Actor_Definition)Checks if an actor of type acd is right of ac.
is_actor_definition_front(wo::World,ac::Actor,acd::Actor_Definition)Checks if an actor of type acd is front of ac.
is_actor_definition_here(wo::World,ac::Actor,acd::Actor_Definition)Checks if an actor of type acd is here of ac.
Index
JuliaKara.JuliaKara_noGUI.ActorsWorld.ActorJuliaKara.JuliaKara_noGUI.ActorsWorld.Actor_DefinitionJuliaKara.JuliaKara_noGUI.ActorsWorld.LocationJuliaKara.JuliaKara_noGUI.ActorsWorld.OrientationJuliaKara.JuliaKara_noGUI.ActorsWorld.SizeJuliaKara.JuliaKara_noGUI.ActorsWorld.WorldJuliaKara.JuliaKara_noGUI.ActorsWorld.actor_create!JuliaKara.JuliaKara_noGUI.ActorsWorld.actor_definition_at_locationJuliaKara.JuliaKara_noGUI.ActorsWorld.actor_delete!JuliaKara.JuliaKara_noGUI.ActorsWorld.actor_move!JuliaKara.JuliaKara_noGUI.ActorsWorld.actor_moveto!JuliaKara.JuliaKara_noGUI.ActorsWorld.actor_pickup!JuliaKara.JuliaKara_noGUI.ActorsWorld.actor_putdown!JuliaKara.JuliaKara_noGUI.ActorsWorld.actor_rotate!JuliaKara.JuliaKara_noGUI.ActorsWorld.actor_validate_location_moveJuliaKara.JuliaKara_noGUI.ActorsWorld.get_actors_at_locationJuliaKara.JuliaKara_noGUI.ActorsWorld.get_actors_at_location_on_layerJuliaKara.JuliaKara_noGUI.ActorsWorld.is_actor_definition_frontJuliaKara.JuliaKara_noGUI.ActorsWorld.is_actor_definition_hereJuliaKara.JuliaKara_noGUI.ActorsWorld.is_actor_definition_leftJuliaKara.JuliaKara_noGUI.ActorsWorld.is_actor_definition_rightJuliaKara.JuliaKara_noGUI.ActorsWorld.location_fix_ooBoundJuliaKara.JuliaKara_noGUI.ActorsWorld.location_moveJuliaKara.JuliaKara_noGUI.ActorsWorld.location_within_worldJuliaKara.JuliaKara_noGUI.ActorsWorld.orientation_rotateJuliaKara.JuliaKara_noGUI.ActorsWorld.reset!JuliaKara.JuliaKara_noGUI.ActorsWorld.world_state_saveJuliaKara.JuliaKara_noGUI.moveJuliaKara.JuliaKara_noGUI.mushroomFrontJuliaKara.JuliaKara_noGUI.onLeafJuliaKara.JuliaKara_noGUI.putLeafJuliaKara.JuliaKara_noGUI.removeLeafJuliaKara.JuliaKara_noGUI.treeFrontJuliaKara.JuliaKara_noGUI.treeLeftJuliaKara.JuliaKara_noGUI.treeRightJuliaKara.JuliaKara_noGUI.turnLeftJuliaKara.JuliaKara_noGUI.turnRightJuliaKara.@World