csce1030Project4_FA195.pdf

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

1 of 27

PROGRAM DESCRIPTION: Anthony the ant has decided that instead of following the pheromone levels as he did in Project 3, he wants to take over all of the adjacent ant colonies with his army of ants in Colony ‘A’. Therefore, in this C++ program, you will create a matrix (two-dimensional array) as you did in Project 3, except that it will be done dynamically. One difference, however, is that the columns will represent each ant colony neighborhood (i.e., ‘A’ through ‘J’) consisting of one ant colony and nine ant patrols (i.e., 1 to 10 ants, inclusively, deployed nearby to protect the ant colony). Then, you will have Anthony’s army attempt to take over the adjacent ant colonies, one column at a time, capturing ants (and adding to Anthony’s army) along the way. If Anthony and his army can get to the ant colony for column ‘J’ with at least 1 ant remaining, then Anthony and his army will have successfully taken over the adjacent ant colonies. REQUIREMENTS: 1. In the main() function, your program will do the following:

a. Your program’s output should initially call a function to display the department name, course number, your name, your EUID, and your e-mail address.

b. Then, to start Anthony’s quest, your program will call another function to display an introductory message, giving details about the game (see SAMPLE OUTPUT).

c. Declare a two-dimensional dynamic array of integers to represent the 10-by-10 matrix of colonies. Since the 2D matrix array is not global, you will pass the 2D matrix array to the needed functions as a pointer (actually, as a pointer to a pointer). You will need to make sure to return the memory for the two- dimensional array back to the freestore when your program is done using it (at the end). You may define a global constant for the size of the 2D array.

d. Initialize the 2D matrix array using a function, passing in the two-dimensional array along with the number of ants, which will be updated in the function. This function will initialize each location in the matrix to be either a colony with the number 0 or a patrol with a seeded, randomly generated number between 1 and 10, inclusively, to represent the number of ants at each patrol location. For each column (i.e., colony), you will use a seeded, randomly generated integer to determine which row is used for the ant colony. The number of ants in Anthony’s initial army will be the sum of all of the patrol numbers in the first column (i.e., colony ‘A’). This means that Anthony’s army may start out with different numbers each time!

e. You will then display the initial 2D matrix array showing only the values in the first column (i.e., Anthony’s colony), with all other columns hidden (showing “**” instead for each row-column entry) using a function, passing in the 2D matrix array and the current column (i.e., colony) that is being attacked by Anthony’s army. This function will display the row and column headers for the 2D matrix

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

2 of 27

array as well as the matrix itself (see SAMPLE OUTPUT). This function shall also be called after each row-selection made by Anthony’s army in trying to find the next ant colony. Only ant colonies that have been found will be revealed. Ant patrols that have been encountered shall be identified by “XX” instead of the patrol number.

f. Now, it’s time to play the game. Using a loop of your choice, prompt for and read in the row position in the column that is being attacked by Anthony’s army. If the row value is out of range (Note that the row value should be between 0 and 9, inclusively, as shown in the SAMPLE OUTPUT), you will display an error message and continue to re-prompt the user until a valid row value is entered. If a valid row value is entered, call a Boolean value-returning function to check the status of the selection, passing in the user-selected row, current column (i.e., colony) that is being processed, the number of ants that can be updated in this function, and the two-dimensional array. This function will check for the following:

i. If the ant colony is found (i.e., row-column entry of 0), return true, indicating that Anthony’s army can move to the next colony. One example is shown in red in the SAMPLE OUTPUT. In this scenario, Anthony's army found the cell in column 'B' with a value of zero in row 9, and hence have taken over colony 'B', capturing 12 ants in the process from unvisited patrols in column 'B' before moving on to colony 'C'.

ii. If a patrol has already been encountered, you will display an error message and return false (since the colony was not found). One example is shown in light blue in the SAMPLE OUTPUT. In this scenario, row 8 in column 'B' has already been visited (as indicated by the "XX" in the matrix), so an error message is displayed, but no impact to the number of ants.

iii. If a patrol has been newly encountered, you will assign some sentinel value to indicate that this patrol has been encountered, subtract the value of the patrol number from the number of ants in Anthony’s army total, display a message about the number of casualties, and then return false (since the colony was not found). One example is shown in orange in the SAMPLE OUTPUT. In this scenario, row 4 was selected, but contained a value of 10 representing the number of ants in the patrol at this location, so 10 was deducted from Anthony's initial army total of 53.

If the above function returns true (indicating that the any colony has been found for that column), you will loop through that column’s entries and add any patrol numbers that have not been encountered to the number of ants in Anthony’s army total, and then advance Anthony’s army to the next column. Whether or not Anthony’s army found the ant colony, you will display the current state of the 2D matrix array, revealing only the columns (i.e., colonies) that have been taken over by Anthony’s army. See SAMPLE OUTPUT.

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

3 of 27

The loop will terminate when either Anthony’s army has taken over all of the ant colonies from ‘B’ through ‘J’ or the number of ants remaining in his army is 0 or less.

g. If Anthony’s army has found all of the ant colonies from ‘B’ through ‘J’ with at least 1 ant remaining, display a congratulatory message along with the number of ants remaining in Anthony’s army; otherwise, display an appropriate message indicating that Anthony was not successful in his endeavor and call the function to display the 2D matrix array, revealing all of the columns.

2. You shall organize your program into three files:

• euidHW4.h will hold the include directives for the necessary libraries, any global constants, any enumerated data types, any type definitions, any structure definitions, and the list of function prototypes (i.e., function declarations).

• euidHW4main.cpp will hold the local include directive for the header file as well as the main function for the program.

• euidHW4func.cpp will hold the local include directive for the header file as well as all function definitions (not including main, of course) used in the program.

3. You may assume that all input by the user is of the correct data type, though perhaps out of range. Please pay attention to the SAMPLE OUTPUT for specific details about the flow and input/output of the program. You should contact your instructor if there is any question about what is being asked for.

4. Your code should be well documented in terms of comments. For example, good comments in general consist of a header (with your name, course section, date, and brief description), comments for each variable, and commented blocks of code.

5. Your program will be graded based largely on whether it works correctly on the CSE machines (e.g., cse01, cse02, …, cse06), so you should make sure that your program compiles and runs on a CSE machine.

6. You shall use techniques and concepts discussed in class – you are not to use global variables, goto statements, or other items specifically not recommended in this class.

BONUS OPPORTUNITY: Up to 15 Points For students who have completed all requirements for this program, you may add the following option to gain additional bonus points to your program score:

• You may add the option to "save" the game so that it can be resumed at a later time. This would entail saving the 2D matrix array (with all current values indicated) and the current column (i.e., colony) that is under attack by Anthony’s army. This information may be written to a file in any format you choose. Then when the program is run again, you can check If the user wants to resume the

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

4 of 27

previous game and, if so, open the file (if it exists) and load the data into memory to continue the game.

Please note that unless you have completed all other requirements for this program no credit will be given for trying this extra credit. In other words, make sure your program is complete before attempting this extra credit. DESIGN (ALGORITHM): On a piece of paper (or word processor), write down the algorithm, or sequence of steps, that you will use to solve the problem. You may think of this as a “recipe” for someone else to follow. Continue to refine your “recipe” until it is clear and deterministically solves the problem. Be sure to include the steps for prompting for input, performing calculations, and displaying output. You should attempt to solve the problem by hand first (using a calculator or perhaps a drawing of the scenario as needed) to work out what the answer should be for a few sets of inputs. This will also help in designing any loops that will process the two- dimensional array. Type these steps and calculations into a document (i.e., Word, text, or PDF) that will be submitted along with your source code. Note that if you do any work by hand, images (such as pictures) may be used, but they must be clear and easily readable. This document shall contain both the algorithm and any supporting hand-calculations you used in verifying your results. SAMPLE OUTPUT (input shown in bold green): $ ./a.out +----------------------------------------------+ | Computer Science and Engineering | | CSCE 1030 - Computer Science I | | Student Name EUID [email protected] | +----------------------------------------------+ Welcome to Anthony's Battle! ---------------------------------------------------------- Anthony the ant has decided that he wants to take over all the adjacent ant colonies with his army of ants from colo- ny 'A'. To do this, Anthony's army will attempt to capture ants from columns 'B' through 'J', with at least 1 ant re- maining when the column 'J' ant colony is found. Each col- umn's ant colony is identified with a 0 in one of the rows for that column, while patrols are represented by integers between 1 and 10 for the number of ants in that particular patrol. On the way to column 'J' if Anthony's army encoun- ters a patrol, the number in the patrol is subtracted from Anthony's army total. Once his army finds the colony, how- ever, any patrols not confronted will be added to his army total. If Anthony makes really good decisions, then he can take over all of the adjacent ant colonies; otherwise, his army will be defeated! ----------------------------------------------------------

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

5 of 27

Initializing board... A B C D E F G H I J +-------------------------------+ 0| 07 ** ** ** ** ** ** ** ** ** | 1| 08 ** ** ** ** ** ** ** ** ** | 2| 07 ** ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 04 ** ** ** ** ** ** ** ** ** | 5| 07 ** ** ** ** ** ** ** ** ** | 6| 03 ** ** ** ** ** ** ** ** ** | 7| 03 ** ** ** ** ** ** ** ** ** | 8| 00 ** ** ** ** ** ** ** ** ** | 9| 09 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Now let's begin... Anthony's army is 53 strong! Enter row position in column B to strike: 4 Anthony's army suffered casualties and has 43 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 ** ** ** ** ** ** ** ** ** | 1| 08 ** ** ** ** ** ** ** ** ** | 2| 07 ** ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 ** ** ** ** ** ** ** ** ** | 6| 03 ** ** ** ** ** ** ** ** ** | 7| 03 ** ** ** ** ** ** ** ** ** | 8| 00 ** ** ** ** ** ** ** ** ** | 9| 09 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 0 Anthony's army suffered casualties and has 39 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX ** ** ** ** ** ** ** ** | 1| 08 ** ** ** ** ** ** ** ** ** | 2| 07 ** ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 ** ** ** ** ** ** ** ** ** | 6| 03 ** ** ** ** ** ** ** ** ** | 7| 03 ** ** ** ** ** ** ** ** ** | 8| 00 ** ** ** ** ** ** ** ** ** | 9| 09 ** ** ** ** ** ** ** ** ** | +-------------------------------+

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

6 of 27

Enter row position in column B to strike: 8 Anthony's army suffered casualties and has 35 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX ** ** ** ** ** ** ** ** | 1| 08 ** ** ** ** ** ** ** ** ** | 2| 07 ** ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 ** ** ** ** ** ** ** ** ** | 6| 03 ** ** ** ** ** ** ** ** ** | 7| 03 ** ** ** ** ** ** ** ** ** | 8| 00 XX ** ** ** ** ** ** ** ** | 9| 09 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 2 Anthony's army suffered casualties and has 33 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX ** ** ** ** ** ** ** ** | 1| 08 ** ** ** ** ** ** ** ** ** | 2| 07 XX ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 ** ** ** ** ** ** ** ** ** | 6| 03 ** ** ** ** ** ** ** ** ** | 7| 03 ** ** ** ** ** ** ** ** ** | 8| 00 XX ** ** ** ** ** ** ** ** | 9| 09 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 1 Anthony's army suffered casualties and has 32 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX ** ** ** ** ** ** ** ** | 1| 08 XX ** ** ** ** ** ** ** ** | 2| 07 XX ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 ** ** ** ** ** ** ** ** ** | 6| 03 ** ** ** ** ** ** ** ** ** | 7| 03 ** ** ** ** ** ** ** ** ** | 8| 00 XX ** ** ** ** ** ** ** ** | 9| 09 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 7

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

7 of 27

Anthony's army suffered casualties and has 27 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX ** ** ** ** ** ** ** ** | 1| 08 XX ** ** ** ** ** ** ** ** | 2| 07 XX ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 ** ** ** ** ** ** ** ** ** | 6| 03 ** ** ** ** ** ** ** ** ** | 7| 03 XX ** ** ** ** ** ** ** ** | 8| 00 XX ** ** ** ** ** ** ** ** | 9| 09 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 8 Ant patrol at this location has already been removed. A B C D E F G H I J +-------------------------------+ 0| 07 XX ** ** ** ** ** ** ** ** | 1| 08 XX ** ** ** ** ** ** ** ** | 2| 07 XX ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 ** ** ** ** ** ** ** ** ** | 6| 03 ** ** ** ** ** ** ** ** ** | 7| 03 XX ** ** ** ** ** ** ** ** | 8| 00 XX ** ** ** ** ** ** ** ** | 9| 09 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 9 Anthony's army found ant colony in column B, captured 12 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX ** ** ** ** ** ** ** ** | 1| 08 XX ** ** ** ** ** ** ** ** | 2| 07 XX ** ** ** ** ** ** ** ** | 3| 05 06 ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 02 ** ** ** ** ** ** ** ** | 6| 03 04 ** ** ** ** ** ** ** ** | 7| 03 XX ** ** ** ** ** ** ** ** | 8| 00 XX ** ** ** ** ** ** ** ** | 9| 09 00 ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column C to strike: 0

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

8 of 27

Anthony's army suffered casualties and has 32 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX ** ** ** ** ** ** ** | 1| 08 XX ** ** ** ** ** ** ** ** | 2| 07 XX ** ** ** ** ** ** ** ** | 3| 05 06 ** ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 02 ** ** ** ** ** ** ** ** | 6| 03 04 ** ** ** ** ** ** ** ** | 7| 03 XX ** ** ** ** ** ** ** ** | 8| 00 XX ** ** ** ** ** ** ** ** | 9| 09 00 ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column C to strike: 3 Anthony's army suffered casualties and has 24 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX ** ** ** ** ** ** ** | 1| 08 XX ** ** ** ** ** ** ** ** | 2| 07 XX ** ** ** ** ** ** ** ** | 3| 05 06 XX ** ** ** ** ** ** ** | 4| 04 XX ** ** ** ** ** ** ** ** | 5| 07 02 ** ** ** ** ** ** ** ** | 6| 03 04 ** ** ** ** ** ** ** ** | 7| 03 XX ** ** ** ** ** ** ** ** | 8| 00 XX ** ** ** ** ** ** ** ** | 9| 09 00 ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column C to strike: 9 Anthony's army found ant colony in column C, captured 36 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX ** ** ** ** ** ** ** | 1| 08 XX 08 ** ** ** ** ** ** ** | 2| 07 XX 05 ** ** ** ** ** ** ** | 3| 05 06 XX ** ** ** ** ** ** ** | 4| 04 XX 05 ** ** ** ** ** ** ** | 5| 07 02 08 ** ** ** ** ** ** ** | 6| 03 04 01 ** ** ** ** ** ** ** | 7| 03 XX 06 ** ** ** ** ** ** ** | 8| 00 XX 03 ** ** ** ** ** ** ** | 9| 09 00 00 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 4 Anthony's army suffered casualties and has 54 ants remaining.

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

9 of 27

A B C D E F G H I J +-------------------------------+ 0| 07 XX XX ** ** ** ** ** ** ** | 1| 08 XX 08 ** ** ** ** ** ** ** | 2| 07 XX 05 ** ** ** ** ** ** ** | 3| 05 06 XX ** ** ** ** ** ** ** | 4| 04 XX 05 XX ** ** ** ** ** ** | 5| 07 02 08 ** ** ** ** ** ** ** | 6| 03 04 01 ** ** ** ** ** ** ** | 7| 03 XX 06 ** ** ** ** ** ** ** | 8| 00 XX 03 ** ** ** ** ** ** ** | 9| 09 00 00 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 1 Anthony's army suffered casualties and has 44 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX ** ** ** ** ** ** ** | 1| 08 XX 08 XX ** ** ** ** ** ** | 2| 07 XX 05 ** ** ** ** ** ** ** | 3| 05 06 XX ** ** ** ** ** ** ** | 4| 04 XX 05 XX ** ** ** ** ** ** | 5| 07 02 08 ** ** ** ** ** ** ** | 6| 03 04 01 ** ** ** ** ** ** ** | 7| 03 XX 06 ** ** ** ** ** ** ** | 8| 00 XX 03 ** ** ** ** ** ** ** | 9| 09 00 00 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 8 Anthony's army suffered casualties and has 42 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX ** ** ** ** ** ** ** | 1| 08 XX 08 XX ** ** ** ** ** ** | 2| 07 XX 05 ** ** ** ** ** ** ** | 3| 05 06 XX ** ** ** ** ** ** ** | 4| 04 XX 05 XX ** ** ** ** ** ** | 5| 07 02 08 ** ** ** ** ** ** ** | 6| 03 04 01 ** ** ** ** ** ** ** | 7| 03 XX 06 ** ** ** ** ** ** ** | 8| 00 XX 03 XX ** ** ** ** ** ** | 9| 09 00 00 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 2 Anthony's army suffered casualties and has 37 ants remaining.

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

10 of 27

A B C D E F G H I J +-------------------------------+ 0| 07 XX XX ** ** ** ** ** ** ** | 1| 08 XX 08 XX ** ** ** ** ** ** | 2| 07 XX 05 XX ** ** ** ** ** ** | 3| 05 06 XX ** ** ** ** ** ** ** | 4| 04 XX 05 XX ** ** ** ** ** ** | 5| 07 02 08 ** ** ** ** ** ** ** | 6| 03 04 01 ** ** ** ** ** ** ** | 7| 03 XX 06 ** ** ** ** ** ** ** | 8| 00 XX 03 XX ** ** ** ** ** ** | 9| 09 00 00 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 0 Anthony's army found ant colony in column D, captured 33 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 ** ** ** ** ** ** | 1| 08 XX 08 XX ** ** ** ** ** ** | 2| 07 XX 05 XX ** ** ** ** ** ** | 3| 05 06 XX 09 ** ** ** ** ** ** | 4| 04 XX 05 XX ** ** ** ** ** ** | 5| 07 02 08 08 ** ** ** ** ** ** | 6| 03 04 01 05 ** ** ** ** ** ** | 7| 03 XX 06 10 ** ** ** ** ** ** | 8| 00 XX 03 XX ** ** ** ** ** ** | 9| 09 00 00 01 ** ** ** ** ** ** | +-------------------------------+ Enter row position in column E to strike: 0 Anthony's army suffered casualties and has 61 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX ** ** ** ** ** | 1| 08 XX 08 XX ** ** ** ** ** ** | 2| 07 XX 05 XX ** ** ** ** ** ** | 3| 05 06 XX 09 ** ** ** ** ** ** | 4| 04 XX 05 XX ** ** ** ** ** ** | 5| 07 02 08 08 ** ** ** ** ** ** | 6| 03 04 01 05 ** ** ** ** ** ** | 7| 03 XX 06 10 ** ** ** ** ** ** | 8| 00 XX 03 XX ** ** ** ** ** ** | 9| 09 00 00 01 ** ** ** ** ** ** | +-------------------------------+ Enter row position in column E to strike: 4 Anthony's army suffered casualties and has 58 ants remaining. A B C D E F G H I J

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

11 of 27

+-------------------------------+ 0| 07 XX XX 00 XX ** ** ** ** ** | 1| 08 XX 08 XX ** ** ** ** ** ** | 2| 07 XX 05 XX ** ** ** ** ** ** | 3| 05 06 XX 09 ** ** ** ** ** ** | 4| 04 XX 05 XX XX ** ** ** ** ** | 5| 07 02 08 08 ** ** ** ** ** ** | 6| 03 04 01 05 ** ** ** ** ** ** | 7| 03 XX 06 10 ** ** ** ** ** ** | 8| 00 XX 03 XX ** ** ** ** ** ** | 9| 09 00 00 01 ** ** ** ** ** ** | +-------------------------------+ Enter row position in column E to strike: 3 Anthony's army found ant colony in column E, captured 30 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX ** ** ** ** ** | 1| 08 XX 08 XX 06 ** ** ** ** ** | 2| 07 XX 05 XX 01 ** ** ** ** ** | 3| 05 06 XX 09 00 ** ** ** ** ** | 4| 04 XX 05 XX XX ** ** ** ** ** | 5| 07 02 08 08 02 ** ** ** ** ** | 6| 03 04 01 05 02 ** ** ** ** ** | 7| 03 XX 06 10 06 ** ** ** ** ** | 8| 00 XX 03 XX 06 ** ** ** ** ** | 9| 09 00 00 01 07 ** ** ** ** ** | +-------------------------------+ Enter row position in column F to strike: 9 Anthony's army suffered casualties and has 82 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX ** ** ** ** ** | 1| 08 XX 08 XX 06 ** ** ** ** ** | 2| 07 XX 05 XX 01 ** ** ** ** ** | 3| 05 06 XX 09 00 ** ** ** ** ** | 4| 04 XX 05 XX XX ** ** ** ** ** | 5| 07 02 08 08 02 ** ** ** ** ** | 6| 03 04 01 05 02 ** ** ** ** ** | 7| 03 XX 06 10 06 ** ** ** ** ** | 8| 00 XX 03 XX 06 ** ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column F to strike: 6 Anthony's army suffered casualties and has 78 ants remaining. A B C D E F G H I J +-------------------------------+

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

12 of 27

0| 07 XX XX 00 XX ** ** ** ** ** | 1| 08 XX 08 XX 06 ** ** ** ** ** | 2| 07 XX 05 XX 01 ** ** ** ** ** | 3| 05 06 XX 09 00 ** ** ** ** ** | 4| 04 XX 05 XX XX ** ** ** ** ** | 5| 07 02 08 08 02 ** ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 ** ** ** ** ** | 8| 00 XX 03 XX 06 ** ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column F to strike: 1 Anthony's army suffered casualties and has 74 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX ** ** ** ** ** | 1| 08 XX 08 XX 06 XX ** ** ** ** | 2| 07 XX 05 XX 01 ** ** ** ** ** | 3| 05 06 XX 09 00 ** ** ** ** ** | 4| 04 XX 05 XX XX ** ** ** ** ** | 5| 07 02 08 08 02 ** ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 ** ** ** ** ** | 8| 00 XX 03 XX 06 ** ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column F to strike: 5 Anthony's army suffered casualties and has 64 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX ** ** ** ** ** | 1| 08 XX 08 XX 06 XX ** ** ** ** | 2| 07 XX 05 XX 01 ** ** ** ** ** | 3| 05 06 XX 09 00 ** ** ** ** ** | 4| 04 XX 05 XX XX ** ** ** ** ** | 5| 07 02 08 08 02 XX ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 ** ** ** ** ** | 8| 00 XX 03 XX 06 ** ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column F to strike: 3 Anthony's army suffered casualties and has 60 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX ** ** ** ** ** |

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

13 of 27

1| 08 XX 08 XX 06 XX ** ** ** ** | 2| 07 XX 05 XX 01 ** ** ** ** ** | 3| 05 06 XX 09 00 XX ** ** ** ** | 4| 04 XX 05 XX XX ** ** ** ** ** | 5| 07 02 08 08 02 XX ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 ** ** ** ** ** | 8| 00 XX 03 XX 06 ** ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column F to strike: 4 Anthony's army suffered casualties and has 59 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX ** ** ** ** ** | 1| 08 XX 08 XX 06 XX ** ** ** ** | 2| 07 XX 05 XX 01 ** ** ** ** ** | 3| 05 06 XX 09 00 XX ** ** ** ** | 4| 04 XX 05 XX XX XX ** ** ** ** | 5| 07 02 08 08 02 XX ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 ** ** ** ** ** | 8| 00 XX 03 XX 06 ** ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column F to strike: 0 Anthony's army suffered casualties and has 49 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX ** ** ** ** | 1| 08 XX 08 XX 06 XX ** ** ** ** | 2| 07 XX 05 XX 01 ** ** ** ** ** | 3| 05 06 XX 09 00 XX ** ** ** ** | 4| 04 XX 05 XX XX XX ** ** ** ** | 5| 07 02 08 08 02 XX ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 ** ** ** ** ** | 8| 00 XX 03 XX 06 ** ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column F to strike: 2 Anthony's army found ant colony in column F, captured 10 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX ** ** ** ** | 1| 08 XX 08 XX 06 XX ** ** ** ** |

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

14 of 27

2| 07 XX 05 XX 01 00 ** ** ** ** | 3| 05 06 XX 09 00 XX ** ** ** ** | 4| 04 XX 05 XX XX XX ** ** ** ** | 5| 07 02 08 08 02 XX ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 03 ** ** ** ** | 8| 00 XX 03 XX 06 07 ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column G to strike: 4 Anthony's army suffered casualties and has 51 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX ** ** ** ** | 1| 08 XX 08 XX 06 XX ** ** ** ** | 2| 07 XX 05 XX 01 00 ** ** ** ** | 3| 05 06 XX 09 00 XX ** ** ** ** | 4| 04 XX 05 XX XX XX XX ** ** ** | 5| 07 02 08 08 02 XX ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 03 ** ** ** ** | 8| 00 XX 03 XX 06 07 ** ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column G to strike: 8 Anthony's army suffered casualties and has 47 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX ** ** ** ** | 1| 08 XX 08 XX 06 XX ** ** ** ** | 2| 07 XX 05 XX 01 00 ** ** ** ** | 3| 05 06 XX 09 00 XX ** ** ** ** | 4| 04 XX 05 XX XX XX XX ** ** ** | 5| 07 02 08 08 02 XX ** ** ** ** | 6| 03 04 01 05 02 XX ** ** ** ** | 7| 03 XX 06 10 06 03 ** ** ** ** | 8| 00 XX 03 XX 06 07 XX ** ** ** | 9| 09 00 00 01 07 XX ** ** ** ** | +-------------------------------+ Enter row position in column G to strike: 7 Anthony's army found ant colony in column G, captured 43 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 ** ** ** | 1| 08 XX 08 XX 06 XX 08 ** ** ** | 2| 07 XX 05 XX 01 00 07 ** ** ** |

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

15 of 27

3| 05 06 XX 09 00 XX 05 ** ** ** | 4| 04 XX 05 XX XX XX XX ** ** ** | 5| 07 02 08 08 02 XX 05 ** ** ** | 6| 03 04 01 05 02 XX 03 ** ** ** | 7| 03 XX 06 10 06 03 00 ** ** ** | 8| 00 XX 03 XX 06 07 XX ** ** ** | 9| 09 00 00 01 07 XX 06 ** ** ** | +-------------------------------+ Enter row position in column H to strike: 9 Anthony's army suffered casualties and has 86 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 ** ** ** | 1| 08 XX 08 XX 06 XX 08 ** ** ** | 2| 07 XX 05 XX 01 00 07 ** ** ** | 3| 05 06 XX 09 00 XX 05 ** ** ** | 4| 04 XX 05 XX XX XX XX ** ** ** | 5| 07 02 08 08 02 XX 05 ** ** ** | 6| 03 04 01 05 02 XX 03 ** ** ** | 7| 03 XX 06 10 06 03 00 ** ** ** | 8| 00 XX 03 XX 06 07 XX ** ** ** | 9| 09 00 00 01 07 XX 06 XX ** ** | +-------------------------------+ Enter row position in column H to strike: 0 Anthony's army suffered casualties and has 83 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX ** ** | 1| 08 XX 08 XX 06 XX 08 ** ** ** | 2| 07 XX 05 XX 01 00 07 ** ** ** | 3| 05 06 XX 09 00 XX 05 ** ** ** | 4| 04 XX 05 XX XX XX XX ** ** ** | 5| 07 02 08 08 02 XX 05 ** ** ** | 6| 03 04 01 05 02 XX 03 ** ** ** | 7| 03 XX 06 10 06 03 00 ** ** ** | 8| 00 XX 03 XX 06 07 XX ** ** ** | 9| 09 00 00 01 07 XX 06 XX ** ** | +-------------------------------+ Enter row position in column H to strike: 1 Anthony's army found ant colony in column H, captured 35 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX ** ** | 1| 08 XX 08 XX 06 XX 08 00 ** ** | 2| 07 XX 05 XX 01 00 07 03 ** ** | 3| 05 06 XX 09 00 XX 05 05 ** ** |

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

16 of 27

4| 04 XX 05 XX XX XX XX 04 ** ** | 5| 07 02 08 08 02 XX 05 06 ** ** | 6| 03 04 01 05 02 XX 03 07 ** ** | 7| 03 XX 06 10 06 03 00 07 ** ** | 8| 00 XX 03 XX 06 07 XX 03 ** ** | 9| 09 00 00 01 07 XX 06 XX ** ** | +-------------------------------+ Enter row position in column I to strike: 5 Anthony's army suffered casualties and has 116 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX ** ** | 1| 08 XX 08 XX 06 XX 08 00 ** ** | 2| 07 XX 05 XX 01 00 07 03 ** ** | 3| 05 06 XX 09 00 XX 05 05 ** ** | 4| 04 XX 05 XX XX XX XX 04 ** ** | 5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 ** ** | 7| 03 XX 06 10 06 03 00 07 ** ** | 8| 00 XX 03 XX 06 07 XX 03 ** ** | 9| 09 00 00 01 07 XX 06 XX ** ** | +-------------------------------+ Enter row position in column I to strike: 4 Anthony's army suffered casualties and has 108 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX ** ** | 1| 08 XX 08 XX 06 XX 08 00 ** ** | 2| 07 XX 05 XX 01 00 07 03 ** ** | 3| 05 06 XX 09 00 XX 05 05 ** ** | 4| 04 XX 05 XX XX XX XX 04 XX ** | 5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 ** ** | 7| 03 XX 06 10 06 03 00 07 ** ** | 8| 00 XX 03 XX 06 07 XX 03 ** ** | 9| 09 00 00 01 07 XX 06 XX ** ** | +-------------------------------+ Enter row position in column I to strike: 2 Anthony's army suffered casualties and has 98 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX ** ** | 1| 08 XX 08 XX 06 XX 08 00 ** ** | 2| 07 XX 05 XX 01 00 07 03 XX ** | 3| 05 06 XX 09 00 XX 05 05 ** ** | 4| 04 XX 05 XX XX XX XX 04 XX ** |

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

17 of 27

5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 ** ** | 7| 03 XX 06 10 06 03 00 07 ** ** | 8| 00 XX 03 XX 06 07 XX 03 ** ** | 9| 09 00 00 01 07 XX 06 XX ** ** | +-------------------------------+ Enter row position in column I to strike: 9 Anthony's army suffered casualties and has 91 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX ** ** | 1| 08 XX 08 XX 06 XX 08 00 ** ** | 2| 07 XX 05 XX 01 00 07 03 XX ** | 3| 05 06 XX 09 00 XX 05 05 ** ** | 4| 04 XX 05 XX XX XX XX 04 XX ** | 5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 ** ** | 7| 03 XX 06 10 06 03 00 07 ** ** | 8| 00 XX 03 XX 06 07 XX 03 ** ** | 9| 09 00 00 01 07 XX 06 XX XX ** | +-------------------------------+ Enter row position in column I to strike: 8 Anthony's army found ant colony in column I, captured 17 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX 03 ** | 1| 08 XX 08 XX 06 XX 08 00 02 ** | 2| 07 XX 05 XX 01 00 07 03 XX ** | 3| 05 06 XX 09 00 XX 05 05 10 ** | 4| 04 XX 05 XX XX XX XX 04 XX ** | 5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 01 ** | 7| 03 XX 06 10 06 03 00 07 01 ** | 8| 00 XX 03 XX 06 07 XX 03 00 ** | 9| 09 00 00 01 07 XX 06 XX XX ** | +-------------------------------+ Enter row position in column J to strike: 4 Anthony's army suffered casualties and has 99 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX 03 ** | 1| 08 XX 08 XX 06 XX 08 00 02 ** | 2| 07 XX 05 XX 01 00 07 03 XX ** | 3| 05 06 XX 09 00 XX 05 05 10 ** | 4| 04 XX 05 XX XX XX XX 04 XX XX | 5| 07 02 08 08 02 XX 05 06 XX ** |

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

18 of 27

6| 03 04 01 05 02 XX 03 07 01 ** | 7| 03 XX 06 10 06 03 00 07 01 ** | 8| 00 XX 03 XX 06 07 XX 03 00 ** | 9| 09 00 00 01 07 XX 06 XX XX ** | +-------------------------------+ Enter row position in column J to strike: 3 Anthony's army suffered casualties and has 92 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX 03 ** | 1| 08 XX 08 XX 06 XX 08 00 02 ** | 2| 07 XX 05 XX 01 00 07 03 XX ** | 3| 05 06 XX 09 00 XX 05 05 10 XX | 4| 04 XX 05 XX XX XX XX 04 XX XX | 5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 01 ** | 7| 03 XX 06 10 06 03 00 07 01 ** | 8| 00 XX 03 XX 06 07 XX 03 00 ** | 9| 09 00 00 01 07 XX 06 XX XX ** | +-------------------------------+ Enter row position in column J to strike: 1 Anthony's army suffered casualties and has 87 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX 03 ** | 1| 08 XX 08 XX 06 XX 08 00 02 XX | 2| 07 XX 05 XX 01 00 07 03 XX ** | 3| 05 06 XX 09 00 XX 05 05 10 XX | 4| 04 XX 05 XX XX XX XX 04 XX XX | 5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 01 ** | 7| 03 XX 06 10 06 03 00 07 01 ** | 8| 00 XX 03 XX 06 07 XX 03 00 ** | 9| 09 00 00 01 07 XX 06 XX XX ** | +-------------------------------+ Enter row position in column J to strike: 9 Anthony's army suffered casualties and has 81 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX 03 ** | 1| 08 XX 08 XX 06 XX 08 00 02 XX | 2| 07 XX 05 XX 01 00 07 03 XX ** | 3| 05 06 XX 09 00 XX 05 05 10 XX | 4| 04 XX 05 XX XX XX XX 04 XX XX | 5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 01 ** |

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

19 of 27

7| 03 XX 06 10 06 03 00 07 01 ** | 8| 00 XX 03 XX 06 07 XX 03 00 ** | 9| 09 00 00 01 07 XX 06 XX XX XX | +-------------------------------+ Enter row position in column J to strike: 7 Anthony's army suffered casualties and has 78 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX 03 ** | 1| 08 XX 08 XX 06 XX 08 00 02 XX | 2| 07 XX 05 XX 01 00 07 03 XX ** | 3| 05 06 XX 09 00 XX 05 05 10 XX | 4| 04 XX 05 XX XX XX XX 04 XX XX | 5| 07 02 08 08 02 XX 05 06 XX ** | 6| 03 04 01 05 02 XX 03 07 01 ** | 7| 03 XX 06 10 06 03 00 07 01 XX | 8| 00 XX 03 XX 06 07 XX 03 00 ** | 9| 09 00 00 01 07 XX 06 XX XX XX | +-------------------------------+ Enter row position in column J to strike: 0 Anthony's army found ant colony in column J, captured 17 ants. A B C D E F G H I J +-------------------------------+ 0| 07 XX XX 00 XX XX 09 XX 03 00 | 1| 08 XX 08 XX 06 XX 08 00 02 XX | 2| 07 XX 05 XX 01 00 07 03 XX 06 | 3| 05 06 XX 09 00 XX 05 05 10 XX | 4| 04 XX 05 XX XX XX XX 04 XX XX | 5| 07 02 08 08 02 XX 05 06 XX 04 | 6| 03 04 01 05 02 XX 03 07 01 01 | 7| 03 XX 06 10 06 03 00 07 01 XX | 8| 00 XX 03 XX 06 07 XX 03 00 06 | 9| 09 00 00 01 07 XX 06 XX XX XX | +-------------------------------+ Congratulations! Anthony has taken over all ant colonies with 95 remaining! Here is more sample input and output, this time for an unsuccessful attempt: $ ./a.out +----------------------------------------------+ | Computer Science and Engineering | | CSCE 1030 - Computer Science I | | Student Name EUID [email protected] | +----------------------------------------------+ Welcome to Anthony's Battle! ----------------------------------------------------------

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

20 of 27

Anthony the ant has decided that he wants to take over all the adjacent ant colonies with his army of ants from colo- ny 'A'. To do this, Anthony's army will attempt to capture ants from columns 'B' through 'J', with at least 1 ant re- maining when the column 'J' ant colony is found. Each col- umn's ant colony is identified with a 0 in one of the rows for that column, while patrols are represented by integers between 1 and 10 for the number of ants in that particular patrol. On the way to column 'J' if Anthony's army encoun- ters a patrol, the number in the patrol is subtracted from Anthony's army total. Once his army finds the colony, how- ever, any patrols not confronted will be added to his army total. If Anthony makes really good decisions, then he can take over all of the adjacent ant colonies; otherwise, his army will be defeated! ---------------------------------------------------------- Initializing board... A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 08 ** ** ** ** ** ** ** ** ** | 5| 03 ** ** ** ** ** ** ** ** ** | 6| 04 ** ** ** ** ** ** ** ** ** | 7| 09 ** ** ** ** ** ** ** ** ** | 8| 07 ** ** ** ** ** ** ** ** ** | 9| 05 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Now let's begin... Anthony's army is 54 strong! Enter row position in column B to strike: 4 Anthony's army suffered casualties and has 44 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 ** ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 ** ** ** ** ** ** ** ** ** | 6| 04 ** ** ** ** ** ** ** ** ** | 7| 09 ** ** ** ** ** ** ** ** ** | 8| 07 ** ** ** ** ** ** ** ** ** | 9| 05 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 3

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

21 of 27

Anthony's army suffered casualties and has 37 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 ** ** ** ** ** ** ** ** ** | 6| 04 ** ** ** ** ** ** ** ** ** | 7| 09 ** ** ** ** ** ** ** ** ** | 8| 07 ** ** ** ** ** ** ** ** ** | 9| 05 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 8 Anthony's army suffered casualties and has 31 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 ** ** ** ** ** ** ** ** ** | 6| 04 ** ** ** ** ** ** ** ** ** | 7| 09 ** ** ** ** ** ** ** ** ** | 8| 07 XX ** ** ** ** ** ** ** ** | 9| 05 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 6 Anthony's army suffered casualties and has 23 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 ** ** ** ** ** ** ** ** ** | 6| 04 XX ** ** ** ** ** ** ** ** | 7| 09 ** ** ** ** ** ** ** ** ** | 8| 07 XX ** ** ** ** ** ** ** ** | 9| 05 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 5 Anthony's army suffered casualties and has 19 ants remaining.

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

22 of 27

A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 XX ** ** ** ** ** ** ** ** | 6| 04 XX ** ** ** ** ** ** ** ** | 7| 09 ** ** ** ** ** ** ** ** ** | 8| 07 XX ** ** ** ** ** ** ** ** | 9| 05 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 8 Ant patrol at this location has already been removed. A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 XX ** ** ** ** ** ** ** ** | 6| 04 XX ** ** ** ** ** ** ** ** | 7| 09 ** ** ** ** ** ** ** ** ** | 8| 07 XX ** ** ** ** ** ** ** ** | 9| 05 ** ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 9 Anthony's army suffered casualties and has 15 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 XX ** ** ** ** ** ** ** ** | 6| 04 XX ** ** ** ** ** ** ** ** | 7| 09 ** ** ** ** ** ** ** ** ** | 8| 07 XX ** ** ** ** ** ** ** ** | 9| 05 XX ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 7 Anthony's army suffered casualties and has 5 ants remaining.

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

23 of 27

A B C D E F G H I J +-------------------------------+ 0| 00 ** ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 XX ** ** ** ** ** ** ** ** | 6| 04 XX ** ** ** ** ** ** ** ** | 7| 09 XX ** ** ** ** ** ** ** ** | 8| 07 XX ** ** ** ** ** ** ** ** | 9| 05 XX ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 0 Anthony's army suffered casualties and has 3 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 XX ** ** ** ** ** ** ** ** | 1| 03 ** ** ** ** ** ** ** ** ** | 2| 10 ** ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 XX ** ** ** ** ** ** ** ** | 6| 04 XX ** ** ** ** ** ** ** ** | 7| 09 XX ** ** ** ** ** ** ** ** | 8| 07 XX ** ** ** ** ** ** ** ** | 9| 05 XX ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column B to strike: 2 Anthony's army found ant colony in column B, captured 3 ants. A B C D E F G H I J +-------------------------------+ 0| 00 XX ** ** ** ** ** ** ** ** | 1| 03 03 ** ** ** ** ** ** ** ** | 2| 10 00 ** ** ** ** ** ** ** ** | 3| 05 XX ** ** ** ** ** ** ** ** | 4| 08 XX ** ** ** ** ** ** ** ** | 5| 03 XX ** ** ** ** ** ** ** ** | 6| 04 XX ** ** ** ** ** ** ** ** | 7| 09 XX ** ** ** ** ** ** ** ** | 8| 07 XX ** ** ** ** ** ** ** ** | 9| 05 XX ** ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column C to strike: 4 Anthony's army found ant colony in column C, captured 46 ants. A B C D E F G H I J

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

24 of 27

+-------------------------------+ 0| 00 XX 03 ** ** ** ** ** ** ** | 1| 03 03 05 ** ** ** ** ** ** ** | 2| 10 00 01 ** ** ** ** ** ** ** | 3| 05 XX 09 ** ** ** ** ** ** ** | 4| 08 XX 00 ** ** ** ** ** ** ** | 5| 03 XX 05 ** ** ** ** ** ** ** | 6| 04 XX 02 ** ** ** ** ** ** ** | 7| 09 XX 08 ** ** ** ** ** ** ** | 8| 07 XX 07 ** ** ** ** ** ** ** | 9| 05 XX 06 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 0 Anthony's army suffered casualties and has 42 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 XX 03 XX ** ** ** ** ** ** | 1| 03 03 05 ** ** ** ** ** ** ** | 2| 10 00 01 ** ** ** ** ** ** ** | 3| 05 XX 09 ** ** ** ** ** ** ** | 4| 08 XX 00 ** ** ** ** ** ** ** | 5| 03 XX 05 ** ** ** ** ** ** ** | 6| 04 XX 02 ** ** ** ** ** ** ** | 7| 09 XX 08 ** ** ** ** ** ** ** | 8| 07 XX 07 ** ** ** ** ** ** ** | 9| 05 XX 06 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 1 Anthony's army suffered casualties and has 38 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 XX 03 XX ** ** ** ** ** ** | 1| 03 03 05 XX ** ** ** ** ** ** | 2| 10 00 01 ** ** ** ** ** ** ** | 3| 05 XX 09 ** ** ** ** ** ** ** | 4| 08 XX 00 ** ** ** ** ** ** ** | 5| 03 XX 05 ** ** ** ** ** ** ** | 6| 04 XX 02 ** ** ** ** ** ** ** | 7| 09 XX 08 ** ** ** ** ** ** ** | 8| 07 XX 07 ** ** ** ** ** ** ** | 9| 05 XX 06 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 2 Anthony's army suffered casualties and has 28 ants remaining. A B C D E F G H I J +-------------------------------+

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

25 of 27

0| 00 XX 03 XX ** ** ** ** ** ** | 1| 03 03 05 XX ** ** ** ** ** ** | 2| 10 00 01 XX ** ** ** ** ** ** | 3| 05 XX 09 ** ** ** ** ** ** ** | 4| 08 XX 00 ** ** ** ** ** ** ** | 5| 03 XX 05 ** ** ** ** ** ** ** | 6| 04 XX 02 ** ** ** ** ** ** ** | 7| 09 XX 08 ** ** ** ** ** ** ** | 8| 07 XX 07 ** ** ** ** ** ** ** | 9| 05 XX 06 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 5 Anthony's army suffered casualties and has 18 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 XX 03 XX ** ** ** ** ** ** | 1| 03 03 05 XX ** ** ** ** ** ** | 2| 10 00 01 XX ** ** ** ** ** ** | 3| 05 XX 09 ** ** ** ** ** ** ** | 4| 08 XX 00 ** ** ** ** ** ** ** | 5| 03 XX 05 XX ** ** ** ** ** ** | 6| 04 XX 02 ** ** ** ** ** ** ** | 7| 09 XX 08 ** ** ** ** ** ** ** | 8| 07 XX 07 ** ** ** ** ** ** ** | 9| 05 XX 06 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 8 Anthony's army suffered casualties and has 10 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 XX 03 XX ** ** ** ** ** ** | 1| 03 03 05 XX ** ** ** ** ** ** | 2| 10 00 01 XX ** ** ** ** ** ** | 3| 05 XX 09 ** ** ** ** ** ** ** | 4| 08 XX 00 ** ** ** ** ** ** ** | 5| 03 XX 05 XX ** ** ** ** ** ** | 6| 04 XX 02 ** ** ** ** ** ** ** | 7| 09 XX 08 ** ** ** ** ** ** ** | 8| 07 XX 07 XX ** ** ** ** ** ** | 9| 05 XX 06 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 6 Anthony's army suffered casualties and has 7 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 XX 03 XX ** ** ** ** ** ** |

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

26 of 27

1| 03 03 05 XX ** ** ** ** ** ** | 2| 10 00 01 XX ** ** ** ** ** ** | 3| 05 XX 09 ** ** ** ** ** ** ** | 4| 08 XX 00 ** ** ** ** ** ** ** | 5| 03 XX 05 XX ** ** ** ** ** ** | 6| 04 XX 02 XX ** ** ** ** ** ** | 7| 09 XX 08 ** ** ** ** ** ** ** | 8| 07 XX 07 XX ** ** ** ** ** ** | 9| 05 XX 06 ** ** ** ** ** ** ** | +-------------------------------+ Enter row position in column D to strike: 4 Anthony's army suffered casualties and has -3 ants remaining. A B C D E F G H I J +-------------------------------+ 0| 00 XX 03 XX ** ** ** ** ** ** | 1| 03 03 05 XX ** ** ** ** ** ** | 2| 10 00 01 XX ** ** ** ** ** ** | 3| 05 XX 09 ** ** ** ** ** ** ** | 4| 08 XX 00 XX ** ** ** ** ** ** | 5| 03 XX 05 XX ** ** ** ** ** ** | 6| 04 XX 02 XX ** ** ** ** ** ** | 7| 09 XX 08 ** ** ** ** ** ** ** | 8| 07 XX 07 XX ** ** ** ** ** ** | 9| 05 XX 06 ** ** ** ** ** ** ** | +-------------------------------+ Sorry, but Anthony's army has been defeated before taking over all ant colonies. A B C D E F G H I J +-------------------------------+ 0| 00 XX 03 XX 10 10 05 06 10 05 | 1| 03 03 05 XX 00 06 02 04 08 10 | 2| 10 00 01 XX 04 05 10 03 03 07 | 3| 05 XX 09 00 08 02 05 10 04 05 | 4| 08 XX 00 XX 08 04 03 04 02 00 | 5| 03 XX 05 XX 03 06 10 00 07 01 | 6| 04 XX 02 XX 03 08 00 04 09 06 | 7| 09 XX 08 04 05 08 05 08 00 09 | 8| 07 XX 07 XX 04 03 05 09 06 06 | 9| 05 XX 06 10 10 00 03 08 04 10 | +-------------------------------+

TESTING: Test your program to check that it operates as desired with a variety of inputs. Then, compare the answers your code gives with the ones you get from hand calculations. Once you're done writing your code and testing it, enjoy your game!! SUBMISSION:

CSCE 1030 – Project 4 Due: 11:59 PM on Tuesday, December 3, 2019

27 of 27

Your program will be graded based largely upon whether it works correctly on the CSE machines, so you should make sure your program compiles and runs on the CSE machines. Your program will also be graded based upon your program style. This means that you should use comments (as directed), meaningful variable names, and a consistent indentation style as recommended in the textbook and in class. We will be using an electronic homework submission on Canvas to make sure that all students hand their programming projects on time. You will submit both (1) the program source code files and (2) the algorithm design document to the Project 4 dropbox on Canvas by the due date and time. Note that this project may be done individually or in collaboration. If you collaborate with other students, you MUST provide a list of collaborators in a separate file, either included in the algorithm file or separately. You should also include this information as comments on your code. Program submissions will be checked using a code plagiarism tool against other solutions, including those found on the Internet, so please ensure that all work submitted is your own or includes the name(s) of collaborators. Any student determined to have cheated will receive an ‘F’ in the course and will be reported for an academic integrity violation. Note that the dates on your electronic submission will be used to verify that you met the due date and time above. All homework up to 24 hours late will receive a 50% grade penalty. Later submissions will receive zero credit, so hand in your best effort on the due date. As a safety precaution, do not edit your program (using vi or pico) after you have submitted your program where you might accidentally re-save the program, causing the timestamp on your file to be later than the due date. If you want to look (or work on it) after submitting, make a copy of your submission and work off of that copy. Should there be any issues with your submission, this timestamp on your code on the CSE machines will be used to validate when the program was completed.