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

Explain the declaration of multi dimensional arrays, Explain the Declaratio...

Explain the Declaration of Multi Dimensional Arrays? In the figure, the range in the first dimension is 3 and in the second dimension is 4. The shaded portion corresponds to th

Define local classes, A cl a s s c a n b e d e f i n e ...

A cl a s s c a n b e d e f i n e d i n s i d e a b l o c k o r f u n c t i o n.   T h i s t yp e cla s s i s known

C program to convert time in 24 hour format to 12., Aim: To implement a pr...

Aim: To implement a program to convert time in 24 hour format to 12 hour format. Code:                       #include #include #include class time24 {

Compute the average of five numbers, Step 1 Define the program headers and ...

Step 1 Define the program headers and the variables      #include   #include   #include   #include void main()   {       char prompt;     float a,b,c,d,e;     floa

Describe the oops concept - class, There are so many different concepts rel...

There are so many different concepts related with OOP (Object-oriented programming) such as: Class Object Inheritance Polymorphism Abstraction Encapsulation

Want wellness software, Project Description: We are looking to have soft...

Project Description: We are looking to have software that we will use to track employee information regarding our wellness program. We would like the system to be able to follow

Described access privileges in c++? what is the default , A: In C++ the acc...

A: In C++ the access privileges are public, private and protected. The default access level assigned to members of a class is private. Private members of any class are accessible o

How many non-boundary pits and peaks are on the map, Armed with your functi...

Armed with your function from above, we can do some interesting things. For instance, any pixel where the offsets are both zero is a pit (lower than all surrounding points) .

C program for string address, C Program for STRING ADDRESS #include std...

C Program for STRING ADDRESS #include stdio.h> #include conio.h> #include string.h> void main() {           char *name;           int length;           cha

Password Validation Prgram in C++, Create a .cpp program that verifies the ...

Create a .cpp program that verifies the strength of a password that a user is entering is strong (complex/secure) enough. In the main area of the program, prompt the user to enter

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