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í
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
Kód: Vybrat vše
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.
Kód: Vybrat vše
curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots -d '{"name": "my_first_robot"}'
Sample output: píše:Kód: Vybrat vše
{
"id": "1",
"name": "my_second_robot"
}
* Get information about the robot
Kód: Vybrat vše
#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: píše:Kód: Vybrat vše
{
"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
Kód: Vybrat vše
#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: píše:Kód: Vybrat vše
{
"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)
Kód: Vybrat vše
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
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.
[line][/line]
[b]Oficiální zadání[/b]
[attachment=0]2018-02-13-Robots.zip[/attachment]
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.
[b]* List of existing robots[/b]
[code]curl -v -X GET http://u2-0.ms.mff.cuni.cz:8080/java/api/robots[/code]
Gets json array with list of exisitng robots and theirs ids.
[b]* Create a new robot (will be deleted after a minute without any activity).[/b]
The robot will be created at random position with random orientation.
[code]curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots -d '{"name": "my_first_robot"}'[/code]
[quote="Sample output:"][code]{
"id": "1",
"name": "my_second_robot"
}[/code][/quote]
[b]* Get information about the robot[/b]
[code]#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/[/code]
[quote="Sample output:"][code]{
"id": "1",
"name": "my_first_robot",
"state": "NEED_KILL",
"direction": "UP",
"posX": 7,
"posY": 8,
"surrounding": " * \n *\n R *\n *\n *\n"
}[/code][/quote]
[b]* Gets information about executed and scheduled actions[/b]
[code]#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[/code]
[quote="Sample output:"][code]{
"id": "1",
"name": "my_first_robot",
"executedActions": [
"TURN_LEFT",
"TURN_RIGHT"
],
"plannedActions": [
"FIRE",
"FIRE"
]
}[/code][/quote]
[b]* Schedule action of the robot[/b]
Output see GET method on the endpoint (see above)
[code]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"}'[/code]
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