Thread: Developing a C program - Pokemon

  1. #1
    Registered User
    Join Date
    Nov 2016
    Posts
    10

    Developing a C program - Pokemon

    Hi,can anyone help me to develop a C program?This project is quite challenging for me and i have tried to figure it out for so many times but i still could not make it.

    You are required to create a Pokemon Game Simulator (you may use other characters). In the game, player will be given a number of pokeball that will be used to capture as many pokemon as they can. After all the pokeball have been used up, the number of pokemon successfully captured will be displayed on the screen.

    Your game simulator should have the following features & functions :
    -Provide player the number of object (such as pokeball).
    -Spawn the characters randomly (minimum five characters).
    -Set the encounter rate and capture rate randomly (the result will be different every
    time the program run).
    -Able to calculate and display the total number of characters captured.
    -Able to display the number of captures for every single character.

    Thanks in advance😁

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    30 Requirements In this assignment you are required to 1 Apply - BIO - 100

    So apart from just posting your assignment, what other skills do you have?

    > This project is quite challenging for me and i have tried to figure it out for so many times but i still could not make it.
    Assignments are there to find out who can walk the walk, instead of just being able to talk the talk.

    You should at least be able to manage either the UI (how many pokeballs do you have) or assign random values through the use of rand().

    Put some effort in, and we'll help you figure out what to do next.
    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.

  3. #3
    Registered User
    Join Date
    Nov 2016
    Posts
    10
    ok,there is something i could not get it.Can rand() be used in fixed string?For example, i declare 3 string:
    "eevee","combusken" and "rattata".i want them to be randomly displayed.How can i do this?

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Yes it can. As long as the generator is seeded, any legal data type can be randomly chosen from a set. Generally if you were going to use strings, then store them in an array of strings then choose one at random.
    Double Helix STL

  5. #5
    Registered User
    Join Date
    Nov 2016
    Posts
    10
    Code:
    #include<stdio.h>
    #include
    <stdlib.h>
    int main
    {
    char pokemon[10] = {eevee,combusken,rattata}  
    
    printf("Wild %s appeared.", pokemon, rand())
    
    return 0;
    }
    Thanks a lot.Is there any problem with my coding, how come i could not run the program?

  6. #6
    Registered User
    Join Date
    Nov 2016
    Posts
    3
    create a string
    Code:
    char *s="this is a string";
    create a string array
    Code:
    char *str[]={ "first", "second string", "third" };
    print a (random) string of a string array of size 3
    Code:
    int n; n = rand() % 3;
    printf("print a string %s\n", str[ n ] );

  7. #7
    Registered User
    Join Date
    Nov 2016
    Posts
    10
    thanks,i get it now 😁😃

  8. #8
    Registered User
    Join Date
    Nov 2016
    Posts
    10
    how about if i wanna display a condition randomly?
    Code:
    char capture_rate[10] = {"capture","miss"};
    if (capture_rate =="capture")
    printf("Gotcha!The pokemon was caught.\n");
    else if(capture_rate=="miss")
    printf("Oh no!The pokemon broke free.Press enter to continue.\n");
    else
    printf("The pokemon escaped already.Press enter to continue.\n");
    
    int N;
    N = rand()%2;
    printf("",capture_rate);
    i know there's something wrong with my coding, but i just don know how to correct it.can anyone there help me to correct it? thanks in advance.
    there's another thing keep confusing me,is there any way to allow user to press enter to continue other than put a scanf("") line below the printf("")line as i don need to prompt and get from user.

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    For someone on a course which seems to be already fairly well advanced, you seem remarkably bad at programming.
    You should be able to post something which is syntactically valid, rather than a random assemblage of words.

    It seems to me you've been wandering from forum to forum getting others to do all the work, and you're not learning a damn thing. Are you paying for your education, because if you are, you're wasting your money.

    > how about if i wanna display a condition randomly?
    Go read au1064's post again.
    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.

  10. #10
    Registered User
    Join Date
    Nov 2016
    Posts
    10
    is there any wrong to ask something i don understand?im just learning this subject for two months.i have just learnt some basic skills.isn't this forum a learning space for beginners?im pretty sure that you are an expert for c programming,but what you did is mocking beginners,instead of guiding them.
    >Go read au1064's post again.
    i read again and again.i tried to start my coding and
    i found my doubts then i tried to ask.does it wrong for me to do this?

  11. #11
    Registered User
    Join Date
    Nov 2016
    Posts
    3
    Code:
     char capture_rate[10]
    This will make only one string with 10 characters (or better with 9 characters and one trailing zero)

    ps.
    if you want a correct and polite response, it is much better to ask a specific question about only one specific problem. nobody wants to go back to school and do the homework part again.

  12. #12
    Registered User
    Join Date
    Nov 2016
    Posts
    10
    Thanks for your explanation.
    Code:
    int N;
    N = rand()%2;
    i know that a condition is different from string.May i know how to randomly display two conditions?
    Sorry for any inconvenience caused for you.

  13. #13
    Registered User
    Join Date
    Nov 2016
    Posts
    1
    Your question has partially been answered, but to give you some hints on how to approach whatever you want to do:

    1. You should probably write some kind of function that returns a random number (integer in your case) given the limit (or size of your array).

    2. I would probably define the size of an array as a macro. Then you will be able to return it quite easily without writing out pencil-length statements.

    3. You initialize your array incorrectly. If you don't want to change your values, you should use something like
    Code:
    const char *capture_rate[2] = {"capture", "miss"};
    4. You would have to use some kind of control structure that prints your array value given that index (which is a random integer).

    Remember that copying won't really help you learn what's going on. In that case, you are missing out on some great and fun concepts and ideas. Get a book, watch videos / tutorials and learn the material. It's really worth it.

  14. #14
    Registered User
    Join Date
    Nov 2016
    Posts
    10
    Thanks for your advice.

  15. #15
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Might be an idea to get K&R (second edition). Read through it - it was written by the authors of the language. It will greatly help any beginner of the language.
    Double Helix STL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Developing program for solving logic equations
    By Mariano Sosto in forum C Programming
    Replies: 1
    Last Post: 05-01-2015, 11:00 PM
  2. Pokemon MMORPG?
    By FiftyNine50 in forum Projects and Job Recruitment
    Replies: 4
    Last Post: 07-25-2007, 04:05 PM
  3. [WinAPI] Developing a color customizable program
    By Templario in forum Windows Programming
    Replies: 6
    Last Post: 02-04-2003, 06:12 PM
  4. Pokemon talk and a couple useless stories
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 02-01-2003, 03:49 PM
  5. help me in developing a good anti virus program
    By sadat in forum C++ Programming
    Replies: 3
    Last Post: 04-04-2002, 02:09 PM

Tags for this Thread