Thread: !!NEED HELP!! - Stick Picking Game.

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    2

    Unhappy !!NEED HELP!! - Stick Picking Game.

    Hey guys I'm new here i was wondering if you guys could help me out.
    i need to make a game for school. its goes as.. 15 sticks arranged in 5 rows..

    eg:

    |
    | |
    | | |
    | | | |
    | | | | |

    and the user can pick any number of sticks from a row. and followed by the computer last person who picks the stick is considered as the loser of the game. and i should make sure that the computer wins all the time. forcing the user to lose i have seen some example with 21 sticks but for this i cant figure out a logic. if you guys could help me out i would really appreciate it. plus I'm new to c programming.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Get started on the project... get it as far along as you can.
    Then if you get stuck you should post your code (in code tags please) and ask specific questions about what's giving you troubles.

    We'll see what we can do...

  3. #3
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Read loops and nested loops...
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    2
    part of what i did. but err it getting complicated and long! i rewrote it! but i kind of still dont have a logic to begin with!

    Code:
    #include<stdio.h>
    int play(int, int, int);
    main()
    {
    	int r[5], row, usr, l_total, comp;
    	r[1]=1; r[2]=2; r[3]=3; r[4]=4; r[5]=5; l_total=15;
    	do
    	{
    		l_total=l_total-usr-comp;
    
    		if(row==1)
    		{
    			r[row] = play(row, usr, comp);
    		}
    
    	}
    	while(l_total==0);
    }
    int play(int row_t, int usr_pick, int comp_pick)
    {
    	int total;
    	total=row_t-usr_pick-comp_pick;
    	return(total);
    }
    Last edited by crazyren; 03-14-2011 at 02:35 AM.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > r[1]=1; r[2]=2; r[3]=3; r[4]=4; r[5]=5;
    Arrays start at 0, not 1
    So your last assignment is off in the weeds somewhere.
    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.

  6. #6
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Other than the problems metioned by Salem,
    Depending upon the compiler, your program will either end up after only one execution of while loop or it will become an infinite loop...
    Reason: variables usr and comp are not initialized.
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Event driven game engine
    By abachler in forum Game Programming
    Replies: 9
    Last Post: 12-01-2009, 06:03 AM
  2. Replies: 15
    Last Post: 10-20-2009, 09:39 AM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. Try my game
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-15-2004, 11:58 AM
  5. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM