Thread: Matchstick game

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    47

    Matchstick game

    Can anybody gimme an idea as to how this can be done..?

    Write a program for a matchstick game being played between the computer and a user.
    Your program should ensure that the computer always wins. Rules for the game are as follows:

    -There are 21 matchsticks.
    -The computer asks the player to pick 1, 2, 3 or 4 matchsticks.
    -After the person picks, the computer does its picking.
    -Whoever is forced to pick up the last matchstick loses the game.


    I tried out some stuff..but as it is..my program was not quite organised..

    Code:
    #include<stdio.h>
    main()
    {
    	int matchsticks, total;
    
    	total = 21;
    
    	printf("Enter the number of matchsticks you wanna pick up at once:");
    	scanf("%d", &matchsticks);
    
    	matchsticks = total - matchsticks;
    
    	while (matchsticks<= 4)
    	{
    		printf("\n Computer Turn");
    		
    	/*	...the rest of the program is mystery! */
    Last edited by duffmckagan; 07-26-2006 at 09:59 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM