Main loop

Main loop

After sending the info byte the client enters the main loop. Each iteration of this loop is a simulation.

Reading the rules

The client will wait for the rules. First there comes 2 bytes with some boolean rules:

  1. Lower_X_Bound_Is_Known

  2. Upper_X_Bound_Is_Known

  3. Lower_Y_Bound_Is_Known

  4. Upper_Y_Bound_Is_Known

  5. Number_Of_Homes_Is_Known

  6. Number_Of_Items_Is_Known

  7. Number_Of_Enemies_Is_Known

  8. Number_Of_Dangers_Is_Known

  1. (agent direction is parallell with y-axis)

  2. (agent direction is negative)

  3. Ammunition_Is_Limited

  4. Cost_Is_Limited

  5. Score_Is_Limited

  6. Can_Recharge_Ammunition_At_Home

  7. Neutralized_Enemy_Becomes_Item

  8. Neutralization_Stops_At_First_Enemy

The bits about agent direction are combined into the rule Initial_Direction as follows:
negativeparallell with y-axisInitial_Direction
00East
01North
10West
11South

Then the client reads the following rules:

Size in bytesFormatRule
1NaturalNeutralization_Range
2NaturalMove_Cost
2NaturalTurn_Left_Cost
2NaturalTurn_Right_Cost
2NaturalGrab_Cost
2NaturalNeutralize_Cost
2NaturalItem_Reward
2NaturalNeutralize_Reward
2NaturalHome_Reward
4NaturalInitial_Cost
4IntegerInitial_Score

Then the client reads the following rules if and only if certain conditions are fulfilled. The conditions are based on previously read rules.

ConditionSize in bytesFormatRule
Lower_X_Bound_Is_Known1IntegerLower_X_Bound
Upper_X_Bound_Is_Known1IntegerUpper_X_Bound
Lower_Y_Bound_Is_Known1IntegerLower_Y_Bound
Upper_X_Bound_Is_Known1IntegerUpper_X_Bound
Number_Of_Homes_Is_Known2NaturalNumber_Of_Homes
Number_Of_Items_Is_Known2NaturalNumber_Of_Items
Number_Of_Enemies_Is_Known2NaturalNumber_Of_Enemies
Number_Of_Dangers_Is_Known2NaturalNumber_Of_Dangers
Ammunition_Is_Limited2NaturalAmmunition_Limit
Ammunition_Is_Limited2NaturalInitial_Ammunition
Cost_Is_Limited4NaturalCost_Limit
Score_Is_Limited4IntegerScore_Limit

The first percept

Then the client reads the first percept. The bits of the percept are interpreted as follwos:

  1. Home

  2. Item

  3. Hostility

  4. Bump

  5. Fear

  6. Enemy_Neutralized

  7. (unused)

  8. End

Information about known tiles

Then the client reads information about the tiles that the agent should know about (except for the tile at (0, 0) for which the client already got the information through the first percept). This is done in a loop. In each iteration it reads information about a tile. If the byte is 0, it exits the loop. Otherwise it reads the x-coordinate (1 byte) and the y-coordinate (1 byte). The tile information byte is interpreted as follows:

  • If bit 1 is True and bit 2 is True the tile is clear without enemy and

    • bit 3 tells wether the tile has a home.

    • bit 4 tells wether the tile has an item.

    • bit 5 tells wether the tile has percept hostility.

    • bit 6 tells wether the tile has percept fear.

  • If bit 1 is True and bit 2 is False the tile is clear with an enemy and

    • bit 3 tells wether the tile has a home.

    • bit 4 tells wether the tile has an item.

  • If bit 1 is False and bit 2 is True the tile is wall.

  • If bit 1 is False and bit 2 is False the tile is danger and bit 3 tells wether the tile has an enemy.

The percept <=> action cycle

The follwoing bytes are interpreted as percepts until the percept includes End. Then the following 4 bytes are interpreted as an integer containing the score. Then the main loop continues with a new iteration.

What the client can send

The client is allowed to send data while the simulation is performed. This data can be of a few different kinds:

  1. A request to perform an action.

  2. A request to clear all symbols on the map.

  3. A request to show a symbol on a tile. Only 1 symbol can be shown on a tile.

  4. A request to not show any symbol on a tile.

  5. A text message.

The first byte it sends tells the server what kind of data it is as follows:
NumberInterpretation
0Action Shut_Off
1Action Move
2Action Turn_Left
3Action Turn_Right
4Action Grab
5Action Neutralize
6Clear all symbols on the world map
7 .. 99(unused)
100 .. 199Symbol number 0 .. 99
200Symbol Number_Sign (#).
201Symbol Question (?)
202Symbol Question_Exclaimation (?!)
203Symbol Unreachable
204Symbol Irrelevant
205Symbol Possible_Enemy
206Symbol Enemy
207Symbol Possible_Danger
208Symbol Danger
209Symbol Plan_Shut_Off
210 .. 253(unused)
254Symbol None (remove)
255Text message

When sending a symbol the client should send 2 more bytes containing the x-coordinate and y-coordinate respectively. When sending a text message the client should send a 2 byte natural containing the size of the text message, followed by that number of bytes containing the message. The client can send any number of symbol and text message requests, but when it has sent an action it must wait for a percept before it is allowed to send again.

The agent is only allowed to send 1 action at a time. When it has sent one, it has to wait for a percept before it can send the next action.

KDE Logo