Zápočtový test 13. 2. 2018 (odpoledne; Jančík)

PObdr at 2018-02-14 16:51:31

Zadáním bylo v podstatě simulovat curl, schopnost odeslat POST a GET na server. Byla k tomu hra s roboty.

Poznámka: robot je ovládán z počítače, nemusí mít žádnou inteligenci.


Oficiální zadání

2018-02-13-Robots.zip

Goal
On the http://u2-0.ms.mff.cuni.cz:8080/java/api address runs a web server.
Your goals is using following HTTP calls to

  1. create a robot

  2. kill another robot

  3. go to the exit of the maze
    Number of robots is you can create is unlimited.
    The state of the simulation is show in server console and will be provided from the projector.

The server supports following endpoints.
*** List of existing robots**

curl -v -X GET http://u2-0.ms.mff.cuni.cz:8080/java/api/robots

Gets json array with list of exisitng robots and theirs ids.  

*** Create a new robot (will be deleted after a minute without any activity).**
The robot will be created at random position with random orientation.

curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots -d '{"name": "my_first_robot"}'

Sample output: wrote:

{
      "id": "1",
      "name": "my_second_robot"
}

*** Get information about the robot**

#curl -X GET http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/
curl -X GET http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/1/

Sample output: wrote:

{
      "id": "1",
      "name": "my_first_robot",
      "state": "NEED_KILL",
      "direction": "UP",
      "posX": 7,
      "posY": 8,
      "surrounding": " *   \n    *\n  R *\n    *\n    *\n"
}

*** Gets information about executed and scheduled actions**

#curl -v  http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions
curl -v  http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/1/actions

Sample output: wrote:

{
      "id": "1",
      "name": "my_first_robot",
      "executedActions": [
        "TURN_LEFT",
        "TURN_RIGHT"
      ],
      "plannedActions": [
        "FIRE",
        "FIRE"
      ]
}

*** Schedule action of the robot**
Output see GET method on the endpoint (see above)

curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions -d '{"action": "TURN_LEFT"}'
curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions -d '{"action": "TURN_RIGHT"}'
curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions -d '{"action": "MOVE_FORWARD"}'
curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions -d '{"action": "FIRE"}'

Notices:
Server source are located in Maven eclispse project (RobotServer.zip).
It build creates a "war" file - a part of this archive.
Run in various application server, tested in WLP (Websphere Liberty Profile), requred server.xml is provided in the archive
Copy the "robot" directory to WLP_HOME/usr/servers/
start the server WLP_HOME/bin/server start robot
logs with the state of the simulation can be found in WLP_HOME/usr/servers/robot/logs/console.log

Attachments: