Escape From The Maze: Part II ------ ---- --- ----- ---- -- The maze from the `escape' problem has been upgraded to be more difficult. The big new difficulty is that more than one monster is now present, and you can be trapped. Note that two monsters cannot occupy the same square (they will not fit). However, there is some good news. First, you now can hurl immobilizing juice at a monster to stop it from doing anything for a while. Exact rules for this are below. And in addition to seeing whether there is a wall, corridor end, exit, or monster in a particular direction, you can see how far away these things are. You have a flask which can hold any amount of immobil- izing juice. You can remove N units of this juice from the flask and hurl it at any monster you can see. This will immobilize the monster for N moves. You can occupy the same square as in immobilized monster WITHOUT being eaten. Jugs of immobilizing juice are on certain squares of the maze, and when you occupy such a square any juice in the square's jug will be automatically transferred to your flask. Furthermore, the jugs refill at the rate of one juice unit per R moves you make (1 <= R <= 5), so if you come back to a jug you will get more juice. You need not hurl the entire contents of your flask at a monster. Each jug has a maximum capacity of from 1 to 9 juice units. Jugs are represented in pictures of the maze by the digits 0 through 9 which tell how much juice is currently in each jug. A jug cannot occupy the exit square. To make things more interesting, the sizes of the the mazes have been increased for this problem. A maze can be at most 40 lines tall and 80 columns wide. You should set your terminal window to 48 lines tall times 80 columns wide to use debugging mode for maze2. Then you can type maze2 sample_escape2 > d1 > m5 5 0 2 1234 > f30 > f > f > f1 1000 > b1 1 > b10 > f > f10 to get a feel for the problem. There is no infallible solution to this problem. In order to make it tractable, a new j command is added to the maze program: see below. The Maze Program --- ---- ------- In the same fashion as the `escape' program, you test your program by running maze2 escape2 The `maze2' program has the same commands as the `maze' program except for one command that is changed and two new commands. The changed and new commands are: m M J F R S Four parameters, M, J, F, and R, are added to the maze creation command. M is the number of monsters, J the number of jugs, F the number of potion units initially in your flask, and R the number of moves you make before one unit of potion is added to a jug you have emptied. S is the random number generator seed as before. In addition, if you give NO parameters, but just input `m', the parameters are set from the FAILED_MAZE file written by the `j K' command below. j Your program is judged, using the same mazes (i.e., `m' command parameters) as the judge will use to score your program. If your program escapes a sufficient number of these mazes in a sufficiently small number of total moves, this command will print `SUCCESS!'. If not, it will print `FAILURE!'. The command will also print the number of mazes you escaped, your total number of moves, and the numbers required for success. A submission for which the `j' command produces `SUCCESS!' will be scored CORRECT, and a sub- mission for which `j' produces `FAILURE!' will be scored INCORRECT. Note that debugging is effectively off during the `j' command (so there is no way of seeing all the mazes you succeeded on). j K Same as j but the command stops on the K'th maze you fail to escape from and writes the `m' com- mand for this maze in the FAILED_MAZE file, which can be used by the `m' command above to permit you to debug your program on the first failed maze. Also, the mazes output by the `maze2' program have three features the `maze' program output does not have. First, a square with a potion jug has a digit, `0' though `9', indicating how full the jug is (the capacity of the jug is not indicated, but the jugs will be at capacity initially and will stop filling when they reach capacity). Second, an immobilized monster displays as an `I' instead of an `M'. And third, several things can be on the same square, and in that case the priority of display from lowest to highest is `Y', `X' or jug, `I' or `M'. Thus if you and an immobilized monster occupy the same square, you will see an `I' in that square. The number of mazes tested by the `j' command is large to prevent you from using `j' to extract all the judge's maze parameters within the time constraints of the con- test. The judge's solution has modest intelligence of a straight forward kind. BUT, to succeed in this problem you should have a plan for increasing the intel- ligence of your escape program as much as necessary. Note also that there is no limit on the number of moves you may make on any given maze, and no OUT OF TIME result for a single maze, but there is instead a limit on the number of moves you may make for all mazes tested by the `j' command. Escape2 Program Input ------- ------- ----- The `-...' and `p...' input lines are as for `escape'. A new `m' input line has been added, and the `nesw' line has been changed. The new or changed lines are: m F R F is the number of units of potion initially in your flask, and R is the number of moves you must make in order for one unit of potion to be put in any jug that is not full. Note: you are NOT told M, the number of monsters in the maze, or J, the number of jugs in the maze. neswx n, e, s, and w each denote one of the following STRING of characters: W #E #J#E #X #J#X #M #J#M Here the #'s stand for unsigned decimal integers. #E, #X, #M means there are # squares until the the corridor ends or there is an exit or there is a monster. # == 0 means the exit or monster is in the next square; 0E is never used (W is used instead). You cannot see beyond an exit or monster. #J means there are # squares until there is a jug. You can see corridor ends, exits, and monsters beyond a jug, but you cannot see another jug beyond a jug. You are NOT told whether or not the mon- ster is mobile. #M does not tell you about any immobil- ized monster in the same square as you, and #J does NOT tell you about any jug in the same square as you (but see #F below). If a square holds a monster and something else you see only the monster. x is one of the following strings of characters: "" (empty string) #F #F means there is a jug on your square from which # units of potion have just been transferred to your flask. There are no space characters in a neswx line. Escape2 Program Output ------- ------- ------ For each `neswx' line input you must output a line with one of the following formats: d #dd Here `d' is one of the direction characters, N, E, S, or W, as for `escape'. The last `d' is the direction in which you want to move. A preceding `#d' means you want to hurl # units of potion in direction d. Thus on input W4MW10E you might respond 2EW to hurl 2 units of potion at the monster to your East and then move yourself one square West. You may put debugging information on these lines after the character indicating the direction in which you move. You must not put any space characters before this character. If you output a line with more than 80 characters, only the first 80 will be kept. If you hurl potion in a direction in which there is no monster, the potion will have no effect. If you try to hurl more units of potion than you have, all the potion that you have will be hurled. In particular, if your flask is empty, hurling potion has no effect. File: escape2.txt Author: Bob Walton Date: Thu Oct 14 07:52:50 EDT 2010 The authors have placed this file in the public domain; they make no warranty and accept no liability for this file. RCS Info (may not be true date or author): $Author: walton $ $Date: 2010/10/14 11:58:14 $ $RCSfile: escape2.txt,v $ $Revision: 1.15 $