![]() |
|
#1
|
||||
|
||||
Need a little coding helpHello everyone,
I've run into a bit of a problem. What I'm trying to do is figure how to check if a move in a chess game is a valid move. What I'd like to do is construct one function that would work for the Rook, Bishop, and Queen. Does anyone have any suggestions? |
|
#2
|
||||
|
||||
|
Why would you do that when the Rook, Bishop, and Queen all use different sets of moves? The Rook and Bishop do use subsets of the Queen's moves, but honestly, I don't think they could be combined to work for all 3. If I were you, I'd create a Move function for each type of chess piece instead of making it harder by trying to create one function to deal with 3 of them.
__________________
-Aaron |
|
#3
|
||||
|
||||
|
Well, how does your chess board looks like?? is it an array?? can you show the codes for the boards and how you pieces into the board?? that would be helpful to provide a clear solution for you..
Assume the board is 2d array of 10X10, then you have to consider moves as North, East,West,South,NE,NW.... __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#4
|
||||
|
||||
|
Quote:
CPP / C++ / C Code:
__________________
Age is unimportant -- except in cheese |
|
#5
|
||||
|
||||
|
ok here's the run down of how moving works:
1) Chess board is an 8x8 matrix with characters representing each piece. 2) Players are asked which piece they'd like to move(Everyone already helped me check that within this forum right here 3) After it is assumed that the player is moving to a valid space and they are moving a valid character I was hoping to check the actualy move. WaltP - your ideal seems intresting but I'm not really sure how to use it. Could you perhaps elaborate or give me a link to a tutorial that would help me out some. |
|
#6
|
||||
|
||||
|
Quote:
If you define a structure to define a piece's color, direction of movement, length of movement, and anything else specific to a piece, then create an array of this structure defining all 32 pieces, you can write one relatively simple routine to test if a move is legal. You won't have to do a lot of nested if's CPP / C++ / C Code:
__________________
Age is unimportant -- except in cheese |
Recent GIDBlog
Welcome to Baghdad by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pls help in this coding. | harsha | C++ Forum | 5 | 08-Apr-2004 20:48 |
| coding a sentinel controlled loop | tommy69 | C++ Forum | 2 | 10-Mar-2004 14:52 |
| coding a word with a givin factor | funnyf | C++ Forum | 2 | 13-Jan-2004 08:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The