##### # # # # #### # # ##### ###### ##### #### # # # # # ## ## # # # # # # # ###### # # # ## # # # ##### # # #### # # # # # # # ##### # ##### # # # # # # # # # # # # # # # ##### # # #### # # # ###### # # #### Programming Contest #2 I realize some of y'all were pretty ====================== slammed with classes during the last programming competition. As a result, I'm going to run this one right through break and the first couple weeks of the quarter. So, start chomping. Simple Description Your program will receive a simple array on standard input. This array will be composed of capital letters. You and all of the other entrants will start at the same cell in the array. On your turn, you can either move or eat. The bigger the letter you eat, the more points you get. Play continues until the array is empty or all players starve. The winner is the player with the most points accrued by the end of the game. Detailed Description 2 4 An example of the initial input is shown at 10 5 the left. ABCDEFGHIJ KLMNOPQRST The input will begin with four numbers. The UVWXYZTHIS first two numbers are which player number you ISNOTATEST are (players are numbered from 1 to K) and the ITISASQUID total number of players (K) in the game. The next two numbers are, respectively, the columns (M) and rows (N) in the array. Following these numbers will be M capital letters for each of N rows. Basically, white space will be as shown in the diagram. The first two numbers are separated by a single space (0x20) and followed by a newline (0x0A). The next two numbers are separated by a single space (0x20) and followed by a newline (0x0A). The array will have each row followed by a newline. There will be at least one minute between the time you receive the array and the start of the first turn. You can do any preparation you see fit in this time. 8 3 C At the start of each turn, you will be told the 1 3 E current position and last move of each player in 9 2 S order. Since, for our example, you are number 2 9 5 W of 4, the input at the left says that you are currently in column 1 and row 3 of the array. On your previous turn, you moved east. The columns are numbered from 1 to M and the rows are numbered from 1 to N. There will be one row of data for each entrant with three elements in each row. Even players that have met their maker (or their maker's maker) will still be listed. And, again, whitespace will be as shown at the left. Each line is terminated with a newline (0x0A) and each field is separated by a single space (0x20). From the moment you are given this update until the moment you reply with a move, I will be timing you. If you spend more than 45 seconds of your turn time without eating, you will starve. So, if you spend 30 seconds and decide to move East on one turn and another 25 seconds before deciding to Chomp on the next turn, you will have starved mid-ponder. You can think all you want when it's not your turn. I will only be timing you between the update and the receipt of your move. Your move must be a single character. There should not be a newline after it or any such thing. Your move should just be a single character: N, S, E, W, C, or D. These are move North, move South, move East, move West, Chomp, and Decompose. Any move that is not one of these characters will be considered to be a C. [Note: if you are using buffered output, be sure to flush the buffer.] [Note: you can emit whatever you so desire to standard error.] North, South, East, and West are fairly self-explanatory. However, because I'm a math weenie, I'm going to add one other bit. The array will be mapped onto the Projective Plane. What this means is that if you go off the edge of the array, you come back at the cell *diametrically opposed* to the cell from which you exited the array. So, in the 10 by 5 array above, if you were in the cell at (7,5) which contains a Q and you moved South, you would end up in cell (4,1) which contains a D. [Note: usually games that wrap around are mapped onto a torus. In such games, going off the left side brings you onto the right side and *maintains* your up/down position. Here, going off the left side brings you onto the right side and *mirrors* your up/down position (or, if you prefer... changes your up/down position to a down/up position).] If you Chomp while in a cell which has not already been chomped, you will be awarded points and you will have your starvation timer reset to the full 45 seconds. An A is worth 1 point, B is worth 2 points, ... Z is worth 26 points. But, if more than one player chomped that cell during that round, this point value is divided evenly amongst them (rounding up). So, if k entrants (including you) chomped a p-point cell during a particular turn, each of you would score: floor( ( p + k - 1 ) / k ) Once a cell has been chomped, it remains empty for the rest of the game. If you Chomp in an empty cell, your starvation timer is *not* reset. You cannot Chomp other entrants (not even the decomposing ones). A player may opt to Decompose. A player who has not eaten in 45 seconds of turn time will involuntarily Decompose. Once a player is decomposing, the player will forever be decomposing. A decomposing player will not receive any turn updates after the one announcing the commencement of his/her rotting. Decomposing players are dead. They cannot move around. They cannot eat. That's it. Look matey, this parrot wouldn't voom if I put four thousand volts through it. It's bleeding demised.... It's not pining, it's passed on. This parrot is no more. It has ceased to be. It's expired and gone to meet its maker. This is a lat parrot. It's a stiff. Bereft of life, it rests in peace. If you hadn't nailed it to the perch, it would be pushing up the daisies. It's rung down the curtain and joined the choir invisible. This is an ex-parrot. Remember, if you opt to decompose, you're dead. If you starve, you're dead. The game terminates when all cells have been chomped or when all contestants are decomposing. The winner is the program with the highest score at the time the game terminates. Submission Details All submissions must be received by 9:00am Monday 2000-03-27. Note: morning. I don't care what programming language you use. I just need to compile/run it. Your submission should be a tar-file. In the tar-file, there should be a README file listing your name, e-mail address, and text about any special hacks you'd like the judges to consider in your code. Also in the tar-file, there should be the source needed to compile your code and a gmake-compatible Makefile (if needed). Your program should be called ``pc2''. To make your program, I will type ``gmake''. To run your program, I will type ``pc2''. I will not set any special environment variables or pass any special flags to gmake or your program. I will allow use of the tournament program for testing. It is called ``ch'' and is in ~pat/src/pc/ch/. On the command-line, it takes the name of the input array file and the names of the directories containing submissions to run. For example, if you wanted to run a tournament on the array in array.txt pitting the program ``pc2'' in the current directory against the program ``pc2'' in the directory ``../blah'', you would use the command-line: ~pat/src/pc/ch/ch array.txt . ../blah There is an optional argument ``-start'' that takes parameters for the x and y location at which to start entrants. All entrants start in the same spot. If you want to specify all entrants start in column 3 of row 4, then use ``-start 3 4'' before the name of the array. And, if you only care that they start in row 4, then use ``-start R 4''. You must e-mail me (pat@csh.rit.edu) your submission by the deadline. If you do not wish your entry to be readable on the Programming Contest web page, be sure to tell me this in your e-mail. Prizes Prizes will be awarded in the following categories: Highest Score Slickest Code Most Maintainable Code There will also be a prize for ``highest score by a beginner''. So, if you're not a programmer, include some text in your README to tell us why this program was a really big step for you and we'll consider it.