Application for tag in the forest game, C/C++ Programming

Assignment Help:

Your program should use the Free Pascal compiler or the Lazarus IDE described in CSC 540. When you hand in your assignment to the digital dropbox, it should be a .PAS file, not zipped.

In the following scenario, X, P, M and N are used, but not defined. They will be defined later in this specification.

Imagine a "forest" represented by a square grid that measures X units on each side. (The units could be yards or kilometers... I don't care.) There are P players. P must be at least 2. The first player is placed at the lower left corner of the grid. Each player is placed on the edge of the playing field, evenly spaced apart counting the grid points along the outside of the square grid. If there are two players, they are on opposite corners. If there are four players, there is one player at each corner at the start of the game. If there are three players, the first player is at the lower left, the second player is somewhere on the right edge of the grid, and the third player is somewhere on the top of the grid. You place these players by dividing the perimeter of the playing field to get the distance between the players, placing the first person at the lower left corner, and playing the rest at the appropriate place around the perimeter.

The players cannot see or hear each other. At each tick of the clock (the clock may measure hours or milliseconds or years... I don't care), a player moves. The first player moves first, the second player second, until all players have moved; then that rotation starts over again. Each player moves in the following way: an integer D between 1 and 4 inclusive is chosen; 1 means north (up on the grid), 2 means west, 3 means south, and 4 means east. A second integer L is chosen between 1 and M. The selected played moves in the direction specified by D, the number of units specified by L. However, if the player's next step would take her off the grid, then she stops at the edge and her turn is over.

If at the end of a turn, the player who moved is in the same piece of the grid as another player, then the player who moved has "tagged" the other player, and wins the game. When this happens, that game is over, and a new game begins. The player who tagged the other player gets one point. Then you put the players back into their original positions, and start the game again. You keep playing until T time units have gone by; then you stop and record your data.

Each time you simulate this, you will set X (the size of the grid), P (the number of players), T (the maximum number of turns) and M (the maximum number of steps to take during a turn). Make sure your P players can fit on the outside of the grid; that is, P <= 4*X. You also probably want to have at least one tag when you run M turns, so make T big enough so that at least one tag occurs before T steps are done; more than one is even better. After each round of T turns, stop the simulation and record your results.

Your "results" should include how many points total were scored after T time steps, and how many points are scored by each player during that time. Also keep track of how many turns happened before someone got tagged, so you can keep track of the smallest, largest and average number of turns required to get a tag.

You have four variables that can serve as an independent variable: X, P, T and M. Fix three at a time, and change the fourth; then graph the things you measure on one or more graphs. For example, you could fix X at 10, fix P at 2, fix T at 1000000, and run one simulation for M=1, another simulation for M=2, and more simulations at M = 4, 8, 16, 32, and 64. Compare the measurements on a graph or graphs. Do the trends on the graph make sense to you?

Next, fix X, P, and M at numbers you think are reasonable, and change T to 10^3, 10^4, 10^5, 10^6, and 10^7. This gives you more data to graph. Look for patterns. If no one ever gets tagged, change X or P to increase the number of tags. If too many tags to take, again change X or P.

You can also fix X, T, and M and change P to get another set of data. Finally, you could fix P, T, and M and change X. Each time you collect and display your data, look for interesting trends.

This should give you plenty of interesting data for your next homework assignment.

Be careful to use qword instead of int variables for the appropriate declarations since some of these numbers will be way over 32,767 (the limit of a Pascal int).

Also, while you are debugging your program, it is wise to print out to the screen frequently so you can see what's going on (and perhaps what's going wrong!). But once you start running programs that do LOTS of calculations, then do input and output sparingly; input and output require FAR more time than other calculations, and you want simulations doing millions of trials to go quickly, not slowly.

 create a PowerPoint presentation that reports on your simulations and results.


Related Discussions:- Application for tag in the forest game

C program for function of count the interest , C Program for FUNCTION OF CO...

C Program for FUNCTION OF COUNT THE INTEREST float si(float,float,float); void main() {           float p=0,r=0,n=0,k=0;           clrscr();           printf("E

Create a program for decision structure , Create the following program or p...

Create the following program or propose one of your own. The program must include at least one of each of the following. Decision structure Repetitive structure fu

multithreaded server, Implement a multithreaded server that can be used as...

Implement a multithreaded server that can be used as a proxy server to access some designated file (say it reflects the proxy copy of two file1.txt, file2.txt). Now use a client to

Need epos programmng and building, Project Description: I have a barber ...

Project Description: I have a barber salon I am seeking someone to build me software for my PARTNER PT6910 touch screen till system. This software must add multiple staff login

Hwid spoofer for windows 7, Project Description: I want a simple program...

Project Description: I want a simple program that will spoof my hardware id. I should be able to prepare the id to spoof to in the program and press "random" button to spoof to

Sums a sequence of integers, assume that the first integer read with cin sp...

assume that the first integer read with cin specifies the number of values remaining to be entered. that program should read only one value each time cin is executed .a typical inp

Define the data type modifiers in c language, Define the Data Type Modifier...

Define the Data Type Modifiers in C language? There are three data types(int, float & double) above have the following modifiers. 1. short 2. long 3. signed 4. unsigned

In p = new fred(), Q: In p = new Fred(), does the Fred memory "leak" if  Fr...

Q: In p = new Fred(), does the Fred memory "leak" if  Fred constructor throws an exception? A: No.         If an exception take place during the Fred constructor of p = new F

Create a mathematical number guessing game, Create a mathematical number gu...

Create a mathematical number guessing game. Have the user prompt for the number of games that they want to play. Then each game consists of the following rules. a. The computer

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd