CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Jul 2010

    chess game ;array_bug selection_of_pieces_in_chess_game

    hey guys ...i m making a project of "CHESS GAME".....
    in which to identify any pieces of chess board ,i had used described mechanism....(see code of array)
    but it actually not working...it takes garbage value...it is working only for the "Rook"...
    i can't understand this behavior...so plz help me 2 find out d bugs..

    you can also give some more efficient mechanism for identify d piece on chess board...

    if you knw any thing which can help me 2 make chess game then plz post it...hurry up!!

    thnk u...

    code of array:
    jPieces = new String[8][8];
    jPieces[0][0] = "bRook";
    jPieces[0][1] = "bKnight";
    jPieces[0][2] = "bBishop";
    jPieces[0][3] = "bQueen";
    jPieces[0][4] = "bKing";
    jPieces[0][5] = "bBishop";
    jPieces[0][6] = "bKnight";
    jPieces[0][7] = "bRook";
    jPieces[1][0] = "bPawn";
    jPieces[1][1] = "bPawn";
    jPieces[1][2] = "bPawn";
    jPieces[1][3] = "bPawn";
    jPieces[1][4] = "bPawn";
    jPieces[1][5] = "bPawn";
    jPieces[1][6] = "bPawn";
    jPieces[1][7] = "bPawn";

    jPieces[6][0] = "wPawn";
    jPieces[6][1] = "wPawn";
    jPieces[6][2] = "wPawn";
    jPieces[6][3] = "wPawn";
    jPieces[6][4] = "wPawn";
    jPieces[6][5] = "wPawn";
    jPieces[6][6] = "wPawn";
    jPieces[6][7] = "wPawn";
    jPieces[7][0] = "wRook";
    jPieces[7][1] = "wKnight";
    jPieces[7][2] = "wBishop";
    jPieces[7][3] = "wQueen";
    jPieces[7][4] = "wKing";
    jPieces[7][5] = "wBishop";
    jPieces[7][6] = "wKnight";
    jPieces[7][7] = "wRook";

    for(int x=0;x<8;x++)
    for(int y=0;y<8;y++)

  2. #2
    Join Date
    May 2006

    Re: chess game ;array_bug selection_of_pieces_in_chess_game

    The code shown works, can you show the code that does not work.
    you can also give some more efficient mechanism for identify d piece on chess board.
    Each piece type should be represented by a class which probably should all inherit from a base class eg ChessPiece . The class type will then be the piece identifier and there could be a method eg isWhite() to determine which side the piece belongs too. Each piece class could also have methods to determine things such as all possible legal moves from the current position; handling of special rules such as castling, en passant and promotion etc.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999

    Re: chess game ;array_bug selection_of_pieces_in_chess_game

    Please post code in &#91;CODE]...&#91;/CODE] tags. Also, please don't use text speak - this isn't a chatroom. We'll make the effort to help you, if you make the effort with your questions.

    Judge a man by his questions, rather than his answers...
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

By using this site, you agree to the Privacy Policy