Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M9532120

Have any Question?


Related Questions in C/C++

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As