Pascal Code

rsoll3
worldCupSoccer.doc

HW3: World Cup Soccer

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

There are always upsets during the World Cup and other tournaments. Is that because the rankings are faulty, or is it reasonable that random chance will tend to make upsets? Let’s explore that question.

WARNING: in order to keep your HW3 reasonably easy to program, I am making WILD assumptions about soccer that competitions, assumptions that are almost certainly not true. Please don’t worry about that.

Assume that team A scores, on average, X1 goals per game, where X1 is a real number. We will assume (yes, I know this is unrealistic) that during each game team A will score a random integer number of goals that is obtained by throwing a random number between 0.0 and 2*X, and then rounding to the nearest integer. (If the random number is exactly in the middle of two integers, round up.) Note that sometimes this could give an integer higher than the average, and sometimes it could give 0. Unfortunately, if your average goals per game is less than 0.25, this algorithm means you will never score a goal! (Remember, I am not claiming that this is realistic.)

Assume that team B scores, on average, Y1 goals per game. Again, assume that in any given match, B will score an integer number of goals determined as above by picking a random real number between 0.0 and 2*Y1, and rounding.

Assume that X, Y, and N are fixed. (More on N later.) Each time you run a simulation, you will simulate N matches between A and B. For each match, determine randomly how many goals A scores for this particular match, and how many goals B scores for this particular match. If A scores more goals than B, then A wins; if B scores more goals than A, then B wins; and if A and B score the same number of goals, then the match is a tie.

Your program should run N of these “matches,” and keep track of wins for A, wins for B, and ties.

At first, keep X1 and Y1 the same, and change N. Let N=10, 100, 1000, 10000, 100000, and 1000000. See how the % of wins for A, B, and ties change as you run more matches. (Use percentages, not the raw number of wins and ties, so that you can compare on the same graph the results you get for different N.) In your HW3, you will use this data to draw a graph with N on the X axis, and the % wins for A, for B, and ties. Notice that you have to be carefully about how you draw this graph, since the N values should not be evenly spaced on the X axis unless you use a log scale.

Next, fix N at 10000 and change X1 and Y1 to different values. (You should pick the values yourself to try to get interesting results for your HW3 graphs.) One possible idea: do enough different X1 and Y1 pairs so that you can draw the following interesting graph for HW3: on the X axis, plot the value (X1-Y1). It will make things easier if you always have (X1-Y1) >= 0; that would mean that team A always has at least as high an average as team B. On the Y axis of this graph, plot the % wins by A, % wins by B, and the ties. I would start out with X1=Y1=5 (or some other integer), and then try different integer averages such that X1 + Y1 = 10, and see what your graph looks like. (This could give you quite a few points.)