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

AREA UNDER CURVE, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

We need to decompile ex4 to mq4, We need to Decompile ex4 to mq4 I have ...

We need to Decompile ex4 to mq4 I have three expert advisors for mt4, which I need to decompile to its original mq4 code. Skills required are C Programming, C++ Programming,

Define commonly used built-in library functions, Define Commonly Used Built...

Define Commonly Used Built-in Library Functions? Comprise opened a file pointer you will desire to use it for either input or output. The C language supplies a set of functions

Write a program to find the area under the curve y =, Write a program to fi...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poin

Pebble merchant, there is a pebble merchant. he sells the pebbles,that are ...

there is a pebble merchant. he sells the pebbles,that are used for shining the floor.his main duty is to take the length of the room side but he sometines mistakes doing that and m

D, drawbacks in assignments in engeenirng

drawbacks in assignments in engeenirng

Define meaning of call by reference - computer programming, Define the Mean...

Define the Meaning of Call by reference? In "call-by- reference", as an alternative of passing the value of a variable, the location number (or the address) of the variable is

Compiler design-limit the methods, Problem : Compiler Design - Limit the me...

Problem : Compiler Design - Limit the methods Rahul is a newbie to the programming and while learning the programming language he came to know the following rules: ·

Random card generator, i need a program that generates this output: The hig...

i need a program that generates this output: The highest card wins! Suit Order is: clubs, diamonds, hearts and spades The computers card is the 5 of Spades. The player’s card is t

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