Mittwoch, 25. Januar 2012

I made it

Hi everyone,
latest status of my programing skills:
I canceled my gambling-program-project because I dont know how to sort multidimensional arrays without switching their value with each other.
You can imagine my problem like that:

You have 3 players and each player has a different value of points. Something like:
-Player 1 has 10 points
-Player 2 has 46 points
-Player 3 has 25 points

Now, it would be easy for me to sort it like this:
-Player 1 has 46 points
-Player 2 has 25 points
-Player 3 has 10 points

But I think you see why this is wrong. In that case, I would just sort the number of points but without looking at the player number. To add more problems, there arent always only 3 players. There can be up to 10 players.
So as long as I dont know how to deal with this problem, I have to do something else.


I also made another program which is already finished. Its a shell game (is that correct? shell game? oO).
You see 3 cups and in one of these cups is a balland you have to guess where.
You have 1 try to guess where the ball is by simply entering 1, 2 or 3. If you fail or win, you can choose if you want to try it again but then the ball is in an other cup (or maybe the same cup again... randomness all the way!).

I have found one or two bugs already. For example:
-When you get asked to type in if you want to try again and you type in "y" for yes and a number (for example "y3") then you choose to play another round AND have already choosen a cup.
-When you get asked to choose between 1, 2 or 3 and you insert a letter you get stuck in an infinite loop

Gonna try to sort them out.

you can find my program code -> here <-
I made a lot of comments in the program code so you can follow my thoughts in the program (more or less) and translated most of it into english. I didnt translate the names of the elements into english because thats not really necessary... at least not for the program code itself ;D
As a compiler I use Dev-C++, which is freeware and (for beginners like me) really good. Use my code if you want to =)

Bye :D

10 Kommentare:

  1. Neat idea about that gambling game. Would it help to analyze code from other such games, even if they weren't in the same format?

    AntwortenLöschen
  2. This shell game plays like a real game and not like those scammy street corner games, right?

    AntwortenLöschen
  3. It's a shame you couldn't get the gambling one sorted but you got something done at least :)

    AntwortenLöschen
  4. nor me but i wish you luck in where ever this post may take you ^_^ Hopefully not on nasty Krokidil !!! lul

    AntwortenLöschen
  5. Dude these are simple bugs to fix, I can fix them all for you.

    Daniweb....

    Also, parse your input so the input stream doesn't fail when it gets bad input leading to your infinite loop (probably).
    Also, clearing the error from the input stream varies from OS to OS so it's best to parse what you need.

    like this:

    [code]
    #include
    #include

    int main()
    {
    std::string input;
    std::getline(std::cin, input);
    if( input == "y" )
    std::cout << "Winrar!" << std::endl;
    }
    [/code]

    AntwortenLöschen