Difference between revisions of "Message-In-Stack Action"

From AgentCubes
Jump to navigation Jump to search
imported>Mike
imported>Corrina
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Image:Move action.png|150px]]  
+
[[Image:Message in stack.png|150px 150px]]  
  
 
{| width="100%" cellspacing="0" cellpadding="10" border="0"
 
{| width="100%" cellspacing="0" cellpadding="10" border="0"
 
|-
 
|-
 
| width="80" valign="top" align="left" | '''Definition:'''  
 
| width="80" valign="top" align="left" | '''Definition:'''  
| width="100%" valign="top" align="left" | The '''delayed-message''' action will trigger a message in this agent after a specified amount of time. Note that it is not possible to send delayed messages to other agents.&nbsp; <br>
+
| width="100%" valign="top" align="left" | &nbsp;'''message in stack''' action: ''will send a message in other agents in the stack''.&nbsp; <br>
 
|-
 
|-
 
| width="80" valign="top" align="left" | '''Parameters:'''  
 
| width="80" valign="top" align="left" | '''Parameters:'''  
| width="100%" valign="top" align="left" | [[Method parameter|method]], [[Message In Stack parameter|message_in_stack]]
+
| width="100%" valign="top" align="left" |  
 +
[[Method parameter|method]]: ''specifies which method to send''
 +
 
 +
[[Message In Stack parameter|agents_in_stack]]: ''which agents in this agent's stack should receive the spcified message.''&nbsp;
 +
 
 
|-
 
|-
| width="80" valign="top" align="left" | '''Example 1:'''  
+
| width="80" valign="top" align="left" | '''Example:'''  
 
| width="100%" valign="top" align="left" |  
 
| width="100%" valign="top" align="left" |  
'''Move after 2 second: '''This agent has two methods delayed_move and move, when it receives a delayed_move message it will wait 2 second then call its own move method which will move it randomly. &nbsp;  
+
'''Composite Agents:''' Imagine you wanted to create a tank that was a combination of a base agent for the wheels of the tank and a turret agent which would go on top.&nbsp; When moving the tank we could have the movement be syncrhonzied by using the '''transport '''action but in order to cause the turret to rotate with the base of the tank we could use the Message In Stack.&nbsp; In the following image we see the behavior of a tank agent which represent the base of the tank.&nbsp; When the left key is pressed before rotating itself, it send a rotate_turret_left message to itself.&nbsp; The method rotate_turret_left checks to make sure it stacked immediatley below a turret and if so it messages the agent immediatley above it with a rotate_left message (this method will also perform a -90 degree rotattion). &nbsp;  
 
 
[[Image:Delayed-message2.png]]
 
  
<br>
+
'''[[Image:Tank.png]]'''
  
 
|}
 
|}
  
 
[[Category:AgentCubes_Actions]]
 
[[Category:AgentCubes_Actions]]

Latest revision as of 18:52, 20 April 2012

150px 150px

Definition:  message in stack action: will send a message in other agents in the stack
Parameters:

method: specifies which method to send

agents_in_stack: which agents in this agent's stack should receive the spcified message. 

Example:

Composite Agents: Imagine you wanted to create a tank that was a combination of a base agent for the wheels of the tank and a turret agent which would go on top.  When moving the tank we could have the movement be syncrhonzied by using the transport action but in order to cause the turret to rotate with the base of the tank we could use the Message In Stack.  In the following image we see the behavior of a tank agent which represent the base of the tank.  When the left key is pressed before rotating itself, it send a rotate_turret_left message to itself.  The method rotate_turret_left checks to make sure it stacked immediatley below a turret and if so it messages the agent immediatley above it with a rotate_left message (this method will also perform a -90 degree rotattion).  

Tank.png