Thread: checkers game finally finished

  1. #16
    Registered User
    Join Date
    Apr 2019
    Posts
    808
    i think we are looking at the board differently here is how i am looking at it
    Code:
    //b= black square w = white square
    
    //row 7 w b w b w b w b  <---blacks end
    //row 6 b w b w b w b w
    //row 5 w b w b w b w b
    //row 4 b w b w b w b w
    //row 3 w b w b w b w b
    //row 2 b w b w b w b w
    //row 1 w b w b w b w b
    //row 0 b w b w b w b w <----whites end
    here is the truth table generated

    Code:
    //column |  row  | good square
    //    odd  |  odd  |   place piece
    //    odd  | even | invalid square
    //   even |  odd  | invalid square
    //  even  | even | place piece
    i guess having written that out i can use:

    Code:
    if (((i % 2 == 0) && (j  % 2 == 0)) || ((i % 2 != 0) && (j % 2 !=  0)))
    {
           board[i][j] = valid_square;
    )
    else
    {
            board[i][j] = invalid_square;
    }
    the code in the above post is just setting up the board and array for the beginning of the game so i have a physical reresentation of the board on the screen and an array to set and check pieces against

    hope this clears it up
    coop

  2. #17
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    Quote Originally Posted by cooper1200 View Post
    here is the truth table generated
    Code:
    //column |  row  | good square
    //    odd  |  odd  |   place piece
    //    odd  | even | invalid square
    //   even |  odd  | invalid square
    //  even  | even | place piece
    i guess having written that out i can use:
    Code:
    if (((i % 2 == 0) && (j  % 2 == 0)) || ((i % 2 != 0) && (j % 2 !=  0)))
    {
           board[i][j] = valid_square;
    )
    else
    {
            board[i][j] = invalid_square;
    }
    If you had the trouble building the truth table, should have notice that this function could be simplified to a simple XOR:
    Code:
    board[i][j] = ( ( i % 2) ^ ( j % 2 ) ) ? invalid_square : valid_square;
    Or, even better:
    Code:
    board[i][j] = ( ( i ^ j ) & 1 ) ? invalid_square : valid_square;
    Last edited by flp1969; 05-03-2019 at 04:08 PM.

  3. #18
    Registered User
    Join Date
    Apr 2019
    Posts
    808
    i have trouble with pointers i did just read the chapter on bit operations last night however i think of understand more nuclear physics than whats going on there ( it seems contrary to electronic and / or gates) I have seen similar look that was on my face on drunks trying to hold a conversation with their reflection in a shop window and not understanding why they aren't being answered.
    Last edited by cooper1200; 05-03-2019 at 04:41 PM.

  4. #19
    Registered User
    Join Date
    Apr 2019
    Posts
    808
    how ever i did think i could do somthing like
    Code:
    (((i % 2 == 0) && (j % 2 == 0 )) || ((i % 2 != 0) && (j % 2 != 0))) ? valid_square : invalid_square
    coop

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checkers game
    By Aeoskype in forum C++ Programming
    Replies: 11
    Last Post: 05-12-2013, 01:03 PM
  2. Extreme Breakout, finally it's finished
    By hdragon in forum Game Programming
    Replies: 16
    Last Post: 04-09-2006, 06:39 AM
  3. C++ Checkers Game
    By SnS CEO in forum C++ Programming
    Replies: 9
    Last Post: 09-07-2005, 01:21 AM
  4. My Roster program is finally finished!
    By face_master in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-02-2002, 02:33 AM
  5. finished my game, finally
    By agerealm in forum Game Programming
    Replies: 15
    Last Post: 10-12-2001, 08:01 AM

Tags for this Thread