Plinko Board Program

This is a discussion on Plinko Board Program within the C++ Programming forums, part of the General Programming Boards category; I am designing a simple plinko game program. Basically I am stuck on exactly how to make this unfold. How ...

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    Plinko Board Program

    I am designing a simple plinko game program. Basically I am stuck on exactly how to make this unfold. How to randomize the odds of where it hits(rand() % 2)???? and how to keep it going and the ending where they get cash. Here is a pic of how it works and here is my code below it so far.

    Name:  plinko.jpg
Views: 1832
Size:  31.8 KB

    Code:
    #include <iostream>
    
    
    using namespace std; 
    
    
    int main()
    {
    int choice;
    int selection;
    double user_winnings;
    bool gameOn = true;
    while (gameOn != false){
    cout << "***PLINKO MENU***\n";
    cout << " 1 - Drop one chip into one slot.\n";
    cout << " 2 - Drop multiple chips into one slot.\n";
    cout << " 3 - Exit.\n";
    cout << " Enter your choice and press enter: ";
    
    
    cin >> choice;
    
    
    switch (choice)
    {
    case 1:
        cout << "\n Which Slot would you like to Drop a chip in(Please enter a slot #0-8)?"<<"\n";
    cin >> selection;
    if((selection < 0) || (selection > 8))
    {
        break;
    }
    else ;
    //simulation description
        cout<<"You've won $" << "money" << "!" << endl;
    break;
    
    
    break;
    case 2:
    cout << "\n Which Slots would you like to Drop a chip in(Please enter a slot #1-9)?"<<"\n";
    // rest of code here
    break;
    case 3:
    cout << "End of Program.\n";
    gameOn = false;
    break;
    default:
    cout << "Not a Valid Choice. \n";
    cout << "Choose again.\n";
    cin >> choice;
    break;
    }
    
    
    }
    return 0;
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,335
    Well first, I would suggest you read up on and start practising code organisation.
    SourceForge.net: Indentation - cpwiki

    Next, just look at two rows of your peg board. Once you understand how this works, you just repeat it 6 times.
    Hint: this might make a good basis for a function within your code, which you call 6 times.

    Another function would be one to call the above 6 times, and tell you what slot the coin actually ended up in.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    11
    but i dont understand how it works

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,335
    Well if it starts in say column 3, then after passing two pegs, which columns is it likely to be in.

    If each peg is unbiased, so it's 50% either way, then it should be
    25% in column 2
    50% in column 3
    25% in column 4
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,403
    There was a contest with a similar theme here - check out the entries for hints on what to do
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  6. #6
    Registered User
    Join Date
    Jul 2012
    Posts
    87
    I built a plinko board simulation for my computer modelling class. You should look for a pattern in the pegs. Notice how the paths a ball can move through alternate b/t 8 and 9 choices to traverse (using the provided pic). I had to test different board widths and height and the point of the Plink board was that the balls will follow a normal distribution so a bell curve where most balls will fall into the middle slots below. So you need some loop to know how tall the board is and when to alternate b/t the total pegs it can land ont during each traversal down the board.

    EDIT: Actually, I built the Galton board which follows the bell curve (it uses a triangle of pegs), but Plinko is similar so you can look it up to get an idea. Here's a neat app online using Flash that let's you test around (Galton board also called the Quincunx, i know it sounds funny)
    http://www.mathsisfun.com/data/quincunx.html
    Last edited by monkey_c_monkey; 09-26-2012 at 11:12 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Should this board be a Java board?
    By Xterria in forum C# Programming
    Replies: 49
    Last Post: 02-18-2002, 06:46 AM
  2. New FAQ board.
    By Justin W in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-15-2001, 01:25 AM
  3. Welcome to the FAQ Board
    By kermi3 in forum FAQ Board
    Replies: 0
    Last Post: 11-01-2001, 09:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21