MAS115: SEMESTER 2 INDIVIDUAL PROJECT PAUL BLACKWELL Random Robots A robot moves on a rectangular array of squares, in accordance with a ‘program’ made up of simple instructions. The instructions are interpreted according to the way that the robot is facing—in the positive x direction (‘east’), the negative x direction (‘west’), the positive y direction (‘north’), or the negative y direction (‘south’). There are three basic instructions, assigned at random, according to some given set of probabilities. Rotate Left: The robot makes a quarter turn left i.e. anticlockwise. Rotate Right: The robot makes a quarter turn right i.e. clockwise. Move 1: The robot goes forward one square, in the direction in which it is currently facing. Background. This project is inspired by the excellent board game ‘RoboRally’ (see e.g. https://boardgamegeek.com/boardgame/18/roborally). In the game, instructions are represented by cards, and a player programs their robot by selecting cards from a hand that they have been dealt. The robots race around a hazardous factory environment. No knowledge of the game is needed to do the project. The basic task Your task is to write R or Python code that will simulate the movement of a robot as it obeys a sequence of k instructions, with each one being Move 1 with probability p (0 < p < 1), and otherwise equally likely to be Rotate Left or Rotate Right. Assume that the robot moves on a (2n + 1) × (2m + 1) board, starting on the centre square and facing east, with n and m large enough to avoid it reaching the edge of the board. Your program should specify values of k and p, and then simulate a large number of runs, each consisting of selecting a random set of instructions and carrying them out. It should record the distribution of the robot’s location after carrying out the k instructions; that is, for each square, the proportion of runs in which the robot finishes in that square. A suitable default value is k = 5, matching the original game. You should make sure your code is producing sensible results by testing it with several different cases that you can check by hand. 1 2 PAUL BLACKWELL Extending the project In addition to the basic task, you should investigate a way of extending the project further. Here are a few ideas: some are quite open-ended, and some may be hard to complete, but the idea is to investigate! Features of the original game. • Additional instructions might include moving forward by more than one square, or moving backwards one square. • If the robot does go off the edge of the board, it falls to destruction! How does the probability depend on the size of the board? • The board might contain other hazards—squares where the robot will be destroyed—or target squares. What is the probability of surviving k instructions? What is the probability of hitting the target in k instructions? Or ever? Without being destroyed first? More mathematical ideas. • Assuming n and m to be large, can you count the number of different squares in which the robot might end up, after k moves? Can you gives a general expression as a function of k, or some upper or lower bounds? • If k is large enough, the robot will eventually hit an edge of the board. Can you say anything mathematically about the probabilities of hitting different edges? • Can you exploit some of the symmetry in the original problem to improve the accuracy of your estimates based on simulation? Conversely, what happens if you drop the symmetry between left and right turns? Applications in biology. The process described above could be seen as a very simplified model of the movement a wild animal, for example as recorded by a GPS tag, or of a micro-organism in a laboratory experiment. Some of the extensions above may lead to slightly more realistic models. Alternatively, consider these ideas. • An animal is searching for randomly located patches that contain food, with each patch of size h × h squares. Do the probabilities of the different types of ‘instruction’ make a difference to how quickly it is likely to find a patch? • What if rotations of less than a quarter turn are allowed? You will need to think about how to ensure that makes sense. You could even dispense with the grid of squares completely. Feel free to extend in any other way you can think of. What you choose is up to you. But don’t try to do all of the above; something that is narrower but deeper is likely to be more interesting. MAS115: SEMESTER 2 INDIVIDUAL PROJECT 3 The project write-up Write up your project, including a description of how your code works, in a LATEX or markdown report of around 4 pages, and strictly no more than 6 pages. The title should be “MAS115: Semester 2 individual project”, and the ‘author’ should be your registration number. Do not include your name. Your report will be peer-assessed ; that is, it will be marked by your fellow students, with some oversight from staff. Your involvement in carrying out the peer assessment of other students’ reports is a required part of the project. You will submit the report online via the course website. The deadline for uploading is midnight at the end of Wednesday 13th May. Late work and plagiarism Late work. Due to the peer assessment of this work, it is important that work is submitted on time. Any work submitted after the deadline may be given a mark of zero. Anybody with circumstances affecting their ability to hand in the work must contact Prof Blackwell in advance of the hand-in date. Plagiarism. The project is an individual assignment and must be your own work. All the University rules on non-invigilated examinations apply. You must not copy work from other students. You can ask for help on the discussion board, but must not ask for help on any other internet discussion forum or email list or anything of a similar nature. Yellow stickers. If you have been assessed by the Disability and DyslexiaSupport Service (DDSS) and have been given yellow stickers to put on your work, please let Prof Blackwell know so that we can attach a virtual sticker to your mini-project.