Written on 2019-09-16
monster_visible
.monster_visible
attribute of the environment. If shooting action is acted upon this environment, the monster will disappear, thus setting monster_visible
into False
.step()
function. When stepping, the agents will start processing the environment, perceiving and acting upon it; and the time will increase.simulator.py
programs.simulator.step()
.Written on 2019-09-19
remote_action
.set_remote_action(action)
function to pass the action (remote_action
) to the Unity side. The action will be then realized by the corresponding agent object in the Unity side./init
will initiate the time, environment and agents. The initiation procedure is passed as init_function
parameter when constructing Remote
module./step
will trigger the world step, moving the time forward. This endpoint accepts environment state in JSON format. These actions will be executed:remote_action
.remote_action
will be returned as HTTP Response. The Unity side will read this action and actuate it accordingly.Hunter
(player) object.Monster
object.Projectile
object that will hit the red cube out, making it fall off the ground (then destroyed).Hunter
object communicate with our Hunter agent in python? As discussed in the Idea section, we are going to make the Unity communicate with our python with an HTTP client.Simulator
) into our Unity scene. Then, add HunterSDK
and SimulatorScript
as components to Simulator
object.HunterSDK
is essentially the code to communicate with our server protocol. It provides the Initiate()
and Step()
method. The initiate()
method will send a request to /init
endpoint, initiating agents and environment representation in python side. The Step()
method accepts the current environment state in Unity, then send it in JSON format alongside a request to /step
endpoint, and then pass the respond to the callback function. The respond should be containing the action to be actuated.SimulatorScript
is a behavioural code that should define the behaviour of our agents and environment in Unity side. Initially in Start()
, it will run HunterSDK.Initiate()
. Then, after a fixed interval, it will periodically call the SimulatorScript.Step()
function. In this step function, you need to determine the current environment state with Unity functionality (e.g. Calculate the visibility of monster), then pass it to HunterSDK.Step(state)
. Finally, you also need to define what should be done to actuate action accordingly (e.g. Spawn a projectile).barton/concept.py
. Note that we will still be reusing the old concepts from alexander/concept.py
.flask
for its simplicity for running HTTP server. The HTTP server behavior is defined as follows:/init
will initiate the time, environment and agents. The initiation procedure is passed as init_function
parameter when constructing Remote
module./step
will trigger the world step, moving the time forward. This endpoint accepts environment state in JSON format. These actions will be executed:remote_action
.remote_action
will be returned as HTTP Response. The Unity side will read this action and actuate its accordingly.alexander/architecture.py
. The difference is that instead of changing state environment.monster_visible
directly, we will delegate the action to the Unity side through remote_action
.main
file. In main, we will define our init_function
that will instantiate the hunter environment and agent. Then we will pass the it to Remote
module, and run the python remote server.monster_visible
). Let's just implement that monster_visible
is true if the monster object exists and the distance between player object and the monster object is less than 4 unit."shoot"
, then we call the method playerScript.Shoot()
. This method is essentially spawn a projectile and add a big force toward the monster object direction. By the physics of Unity engine, the monster object will be pushed backward by the projectile and it will fall off the ground.SetAIEnabled()
to toggle the activation of the AI. This method is bound to the Toggle UI "Enable AI". There is also a SpawnMonster()
method that will be executed when clicking the button "Spawn Monster".Written on 2020-01-28
M x N
.Architecture
class.perceive
function, we just return a Percept instance containing the environment state.act
function, we just pass the action to remote environment through set_remote_action
.update_state
.__init__()
. The process()
, which implements the agent function, will perform three tasks when invoked:init_function
that will instantiate the hunter environment and agent. Then we pass the it to Remote module (Read Part 2), and run the python remote server.main.py
.cli_world.py
contains an implementation of hunter world environment. When running, it will communicate with the Hunter agent via HTTP connection and update itself in an eternal loop. In each loop step, it will update itself, send the environment state to agent, and actuate the action received from agent to the environment.