Thread: Rate this code? what could i have done better?

  1. #16
    Registered User
    Join Date
    Mar 2012
    Posts
    56
    Updated previous code

  2. #17
    Registered User
    Join Date
    Mar 2012
    Posts
    56
    is there a way to simply the AI of the computer in this program? instead of using alot of ifs... i could use switch but it would still be bulky and repetitive.

  3. #18
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    If a function takes no arguments, specify this with (void) instead of (), as in:
    Code:
    void f(void);
    Due to historical reasons, () means "unspecified number of arguments", not "no arguments"; (void) means "no arguments". Using (void) allows for proper type-checking.

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > is there a way to simply the AI of the computer in this program?
    Are you making use of the symmetry in the problem?

    X - -
    0 - -
    X - -

    X 0 X
    - - -
    - - -

    - - X
    - - 0
    - - X

    - - -
    - - -
    X 0 X

    From a strategy point of view, all of these board positions are the same.
    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.

  5. #20
    Registered User
    Join Date
    Mar 2012
    Posts
    56
    Quote Originally Posted by cas View Post
    If a function takes no arguments, specify this with (void) instead of (), as in:
    Code:
    void f(void);
    Due to historical reasons, () means "unspecified number of arguments", not "no arguments"; (void) means "no arguments". Using (void) allows for proper type-checking.
    cool didnt know that, ill will update =)

  6. #21
    Registered User
    Join Date
    Mar 2012
    Posts
    56
    Quote Originally Posted by Salem View Post
    > is there a way to simply the AI of the computer in this program?
    Are you making use of the symmetry in the problem?

    X - -
    0 - -
    X - -

    X 0 X
    - - -
    - - -

    - - X
    - - 0
    - - X

    - - -
    - - -
    X 0 X

    From a strategy point of view, all of these board positions are the same.
    yes they are the same, but dont know how else to implement it

  7. #22
    Registered User
    Join Date
    Mar 2012
    Posts
    56
    Can you guys recommend another game to make? i done this one and a blackjack game..
    trying to learn C and it seems like games are a good way to do so

  8. #23
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    945
    Minesweeper. That requires a variation of an area-filling algorithm, which is fairly easy to do recursively.

  9. #24
    Registered User
    Join Date
    Mar 2012
    Posts
    56
    Quote Originally Posted by christop View Post
    Minesweeper. That requires a variation of an area-filling algorithm, which is fairly easy to do recursively.
    nice idea!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rate my code
    By Baard in forum C++ Programming
    Replies: 2
    Last Post: 01-04-2004, 09:19 AM
  2. rate my directx code
    By revelation437 in forum Game Programming
    Replies: 9
    Last Post: 01-02-2004, 06:21 PM
  3. Rate My Code: Function Usage & File Streaming
    By KingZoolerius66 in forum C++ Programming
    Replies: 9
    Last Post: 12-28-2003, 10:23 PM
  4. Rate my source code :)
    By Terrance in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-17-2003, 01:09 PM
  5. rate my code
    By kashifk in forum C Programming
    Replies: 1
    Last Post: 06-07-2003, 12:18 PM