I need help, without code. :D

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
Exutus
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 4
Joined: Wed Nov 18, 2009 8:38 am

I need help, without code. :D

Post by Exutus »

Yo and welcome to the frog's first post :lol:
I'm at work, on lunch time, can't go in IRC here so I registered to the forum.
Well, since I started learning C the other day, I thought it was pretty cool... I went through a few things, and just learned about loops. (*EDIT: Forgot to mention the language... it's C )

So, this post is to ask if you cuold shed me some light, without giving me the code right away, you see my little game below; I want to upgrade it.

If you can give me a well detailed picture, I would appreciate since I need to learn, so neither a direct asnwer or formula would do.

I want:

1) The program to count the number of times the user tried a number before finding the random one.
printf("Contrats, after % number of times, you found it", variable)

2) I want the program to ask if the user want to try another game, using booleen (always true, false = endgame)

and 3rd) I want it to be a 2 players game, someone enters the "random" number, and the other person tries to find it... BUT! We MUST be able to choose wether its gonna be a 1 player (random generated number) or 2 players.

:)
I need some help from you coders :shock2:

Code: Select all

/*

Less or More Mini-game-------------

*/


#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main ( int argc, char** argv )
{
    int guessNumber = 0, inputNumber = 0;
    const int MAX = 100, MIN = 1;

    // Generating the random number

    srand(time(NULL));
    guessNumber = (rand() % (MAX - MIN + 1)) + MIN;

    /* Loop of the program. It repeats until the user finds the guessNumber
    */

    do
    {
        // It asks for the number
        printf("What is the number ? ");
        scanf("%d", &inputNumber);

        // We compare the input number with the guessNumber

        if (guessNumber > inputNumber)
            printf("It's more !\n\n");
        else if (guessNumber < inputNumber)
            printf("It's less !\n\n");
        else
            printf ("Congrats, you found the mysterious number !!!\n\n");
    } while (inputNumber != guessNumber);

}
andrew
Chaos Rift Regular
Chaos Rift Regular
Posts: 121
Joined: Mon Dec 08, 2008 2:12 pm

Re: I need help, without code. :D

Post by andrew »

Do you mean something like this?
guess game.PNG
guess game.PNG (15.26 KiB) Viewed 848 times
This might also be really helpful to you:
Lecture 6: Solving Problems - Richard Buckland UNSW 2008
Exutus
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 4
Joined: Wed Nov 18, 2009 8:38 am

Re: I need help, without code. :D

Post by Exutus »

Not really

1st, it asks "1 or 2 players ?"

If 1 player ---> the person plays against the computer, the computer generates a number (15 for instance), the player enter 21, the computer replies "Too high!", then the player tries 14, the computer replies "too low", then the player enter 15... The computer replies "Congrats, you found it after 3 tries!"

Then "Play again?"

Then it would re-play, still on the 1-player mode.
---

If 2 players ---> Let's say I enter a number for you to guess, it'll scanf my number, but then you have to try (no random number generating) and the game plays the same rules, if you get the number it then says "Congrats Player 2! You found the number that Player1 entered, it took you 5 times."

Then "Play again?"

Then it would re-play, still on the 2-players mode.

:)
User avatar
Trask
ES Beta Backer
ES Beta Backer
Posts: 738
Joined: Wed Oct 29, 2008 8:17 pm
Current Project: Building a 2D Engine
Favorite Gaming Platforms: Sega Genesis and Xbox 360
Programming Language of Choice: C/C++
Location: Pittsburgh, PA
Contact:

Re: I need help, without code. :D

Post by Trask »

int tries;
while(!answer)
{
cout << "number is too high/low";
tries++
}

if(answer)
{
cout << "You won after" << tries;
}

Horribly jumbled psuedo code... but the tries++ adds one to the variable 'tries' every time it loops through. I'm writing this rush style, but yeah... hopefully you get the point.
MarauderIIC wrote:You know those people that are like "CHECK IT OUT I just made Linux run on this piece of celery [or other random object]!!"? Yeah, that's Falco, but with ES.
Dear god, they actually ported ES to a piece of celery!
Martin Golding wrote: "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
Exutus
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 4
Joined: Wed Nov 18, 2009 8:38 am

Re: I need help, without code. :D

Post by Exutus »

What's up Trask
Hey isn't that for C++ ?
User avatar
Trask
ES Beta Backer
ES Beta Backer
Posts: 738
Joined: Wed Oct 29, 2008 8:17 pm
Current Project: Building a 2D Engine
Favorite Gaming Platforms: Sega Genesis and Xbox 360
Programming Language of Choice: C/C++
Location: Pittsburgh, PA
Contact:

Re: I need help, without code. :D

Post by Trask »

The code is a jumble, mostly C++. I'm tired as heck and I'm just answering the question. Bottom line is to add a +1 to a variable in a list of things you want to do when a user guesses wrong.

if(!answer)
{
guess = guess + 1;
}

Simply print out the 'guess' variable for the number of guesses.
MarauderIIC wrote:You know those people that are like "CHECK IT OUT I just made Linux run on this piece of celery [or other random object]!!"? Yeah, that's Falco, but with ES.
Dear god, they actually ported ES to a piece of celery!
Martin Golding wrote: "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
Post Reply