Be a Supporter!

Sakigirl24Sakigirl24

Main News Favorites Reviews Stats
Follow Sakigirl24
Sakigirl24
  • Add Friend
Age / Gender:
n/a, Female
Location:
Kansas City, Missouri
Joined:
10/19/08
All Stats >

User Statshot

Community Stats
Level 10 Gamer
Normal Whistle
Ranked as Civilian

Contact Info / Websites

Latest News

Who can write this program?

2011-10-24 17:32:01 by Sakigirl24

I need help with my assignment for my c++ class. I've been sick for a few days and I am not sure how to start this.

"Background: As some of you might know, Willie has a drinking problem. And when he falls off the wagon, it's almost always 30 days before he cleans up again. Everyday during that time he will get drunk at work and usually end up in a hedge or a closet or a basement sleeping it off. Willie wants you to write a program that will simulate his "behavior" during these times so that he can have more insight into his expected behavior. (With this information, he could just skip work for a week and roll the dice to find out if he's going to fall out a window, pass out in the hallway, or accomplish the assigned task that day. What a concept!) You will create his world (the school - an N x N gird of locations for him to be in), create Willie, place him in the middle of the school (that's the 2-D array just mentioned), randomly place a foul-smelling moldy sack lunch for him to try to find, place windows around the edge of the school, then set Willie off to try to find the sack lunch before he passes out or falls out of a window. Your program will repeat Willie's simulated journey 30 times and collect stats on the outcomes.

Specifications: You are going to write code that runs a simulation. That is, you will create "things" that "do stuff" at random, then collect statistics about the outcomes. For this particular simulation: you create a 10 x 10 2-D array, place Willie in the middle of this array, randomly place one sack lunch in the interior of the school, then repeatedly have Willie pick a random direction (up, down, left, or right) and take a step. You will use the first and last columns and top and bottom rows to be the walls of the school. In so doing, each cell will represent a section of the boundary wall. Regardless of the dimension of the school (10 x 10 in this example), you will place a window at every fourth section, not including corners. Thus, if you start in a corner spot, you will "mark" each 4th cell as a window until you get to the next corner (remember, no windows in the corners). Now, each time he takes a step, he will check to see if he found the lunch, fell out of a window (stepped into a cell marked as a window), bruised his forehead on a wall (stepped into a cell on the border that isn't a window), or just safely landed in an empty spot where he will repeat the process. [Note: if Willie's next step puts him "in" the wall, don't actually advance him into that cell. Increment his bruise count, and leave him where he was; his next step will be his chance to move again. If his next step puts him "in" a window, then take that to mean that he fell out of the window and that particular run ends.] Each run of this simulation allows Willie to take 40 steps before he passes out. So, a run can end with success (finds the sack lunch), Willie passing out, or Willie falling out of a window. At the end of 30 runs (simulating 30 days of drinking), you will report the following stats: the percentage of times he found the sack lunch, how many bruises he got from running into walls, the percentage of times he fell out of windows.

There are many ways to do this program, and you are once again going to make some design decision that will make a big difference how the coding will proceed. We suggest the following:

* Create an appropriately sized 2-D array of characters.
* Clear the array of garbage. Place a symbol, such as W for Willie, in the center.
* Designate the outer rows and columns to represent the walls, and place another symbol in those cells for the windows according to the way outlined above. Remember not to put windows in the corners. And you might want to use 'F' to represent a window. That's because window in German is fenster. It is the only other language that I know the word for window.]
* Now randomly place the moldy sack lunch.
* You can either create the array in main and pass it to a function that will run a simulation, or create it in that function. You will, in either case, have that fuction return an indication whether or not Willie was successful. You will also have to pass information back from that function stating the stats you wish to collect. You might want to "wrap that up" in a struct (appropriately named). Think carefully what that struct should represent and what it should contain.
* Pseudo-code for this program could look like this:

begin main
loop on simulation
create school
clear away garbage
place actors n'stuff // I love that word
loop on steps
Willie travels
gather information/stats
end loop on steps
tally stats
end loop on simulation
present results
end main

Here's a really cool picture that Josh created to exemplify the set up. It is clear from this picture that Josh knows a little German also. The 'B' in the non-window positions stands for "bumpinschtoppin", German for "wall".

Your output might look like this:

For 1000 runs of the simulator I got the following results:

35.8% Willie fell out the window.
40.4% Willie passed out on the floor.
23.8% Willie found the lunch.
Willie sustained a total of 1673 bruises. (Average 1.67 per run)
"

Who can write this program?


Recent Game Medals

Bound to the Earth 25 Points Oh my goodNess! Medal Stats.
Rank RPE 50 Points You Won! Medal Stats.
Rank RBH 50 Points You Won! Medal Stats.
The Last Fantasy 25 Points Should've kept you Locke-d up Medal Stats.
Barnyard Blitz 5 Points It sure is animaly in here Medal Stats.
Rank GAPI 50 Points You Won! Medal Stats.
You Win! 10 Points Good job! Medal Stats.
SECRET MEDAL 5 Points Unlock this medal to see it's details. Medal Stats.
Rank PBT 50 Points You Won! Medal Stats.
I don't Need That! 10 Points Beat a level without using all of the required folds. Medal Stats.


Total Medals Earned: 792 (From 126 different games.)

Latest Shared Creations

:-P Added to pumpkins for Carve n' Share Oct 21, 2010. Load Level