author | date | title | |
---|---|---|---|
|
Wednesday 2nd February 2022 |
Software Sustainability - King's workshop exercises |
The below material assumes that the software sustainability course has been completed (https://www.youtube.com/playlist?list=PLxyHJ_wep1_DPbvtFl_-EGyoz2pVt-n1_), and that Python 3, Node.js, Git, Docker and Docker Compose are all installed.
We are going to write a piece of code that simulates the movement of a robot in a 2D space from its starting position to a goal position, which is provided by a user.
The robot being modelled is intelligent enough to know the direction it
needs to move in to reach the target position, and this should be
captured in the code. For example, before each move the robot always
starts at position
Once the simulated robot has reached its target position, our code should report the path it took to get there. As such, the simulation allows us to evaluate the robot's AI.
We should also be able to probe for the robot's position at any time.
-
A user enters a goal position of
$(3, 3)$ . The robot is at position$(0, 0)$ . -
The robot moves to position
$(1, 1)$ . -
The robot moves to position
$(2, 2)$ . -
The robot moves to position
$(3, 3)$ , which is the target position. -
The robot's path was
$(1, 1)$ ,$(2, 2)$ $(3, 3)$ , so this is reported back to the user.
Realise the simulation model described in Python code, adhering to the principles of coding practice discussed in the course.
Your code should accept a target position as input, simulate the movement of the robot towards that position, and report on the path the robot took to reach it.
Make a version of your software, and push it to a remote repository on King's Github (github.kcl.ac.uk). Call this repository 'robot'.
You will need to log in with your k-number and password, if you have not done so before.
Public Github (github.com), should also work for this task, but should only be used as a backup.
Additional versions should be made at appropriate points while completing the remaining tasks.
Write three tests to ensure the following:
-
The robot can move three steps down (backwards).
-
The robot can move a large amount to the left (e.g. 10,000 steps).
-
The robot is not still at position 0, when asked to move to position
$(3, 3)$ .
Modify your program such that these tests pass, if needed.
You are welcome to add additional tests also.
The supporting materials for this session are available at github.com/martinteaching/sustainability/tree/master/resources.
Wrap your Python robot simulation model in a server and run it.
Move the request for target position to a Javascript client, which, once acquired, sends this information to the server, waits for the robot simulation to complete, and then prints the path of the robot for the user.
Dockerise your program -- using a Dockerfile and Docker Compose -- allowing the Python server to run in a container, and the Javascript client to issue requests to it.
If you wish to expand on your solution, create a second Python service
that encapsulates the logic required to place
Under this setup, the client calls a service (robot), which in turn calls a second service (object) as a part of its operation before reporting the results back to the client.
Attendees at the workshop will be given time to review and start these exercises individually, and will then be asked to complete them fully with each other in an online collaborative environment.
Sufficient engagement with these collaborative sessions will result in a 'pass' mark for the workshop.