1.

Solve : Programming Chess Game?

Answer»

Hi. I am making a chess game, in Blitz Basic but it's not the language I'm having difficulty with but the concepts. The basics are there and you can move pieces around. If anyone could help it'd be appreciated. I can send it to you if you like.

Check detection. The obvious method is to simply cycle through each cell and if it contains a piece, look at each cell to which it may capture and see if it contains a king, and do this for the whole board. However I am sure there must be a much better way of doing it. Another idea I had is to create two arrays the size of the board, one of white one for black, recording the number of pieces attacking each square. When moving a piece, each square to which the piece may capture has its value reduced by one, then in its new location each possible capturing square has its value INCREASED by one, to keep track of which squares are attacked. I imagine this could also be useful for the AI when deciding which squares are dangerous?

Castling. The only way I can think of is create two duplicate piece types, rook-uncastlable and rook-castlable, which are the same apart from only the castlable one may be castled. As soon as a rook-castlable is moved it is transformed into the uncastable type.

En-passent capturing. Similar possible solution. A pawn type for the normal one, and a seperate but otherwise identical type for those which have just moved forward two squares. Otherwise how can the difference be told between a pawn which has just moved 2 squares, or 1 square over two moves?

Checking for clear paths. When attempting to move a piece I have created a function into which one enters the starting x, y and finishing x, y. The function works out what kind of movement (horizontal, /-diagonal etc) from the coordinates entered. It then scans each square along that path to see if it is empty or contains a blocking piece. However I am having a bit of difficulty getting it to work properly all the time (only knights behave all the time - of course!!) What is the best way of doing it?

Thanks. After these have been sorted I shall try to add some AI. I've already experimented with minmax in a Reversi/Othello game which I can send you if you like, so I have some basic idea of how to implement it, but chess is far more complex. For a start there is more than one type of piece!


Well most of the concepts for a program are there. If you can program this, I believe you have the right ideas.

As far as efficiency...the chess programs today are Phenominal (Chess Master 10, Fritz) they calculate not just available squares, their AI is soooo advanced, can calculate combinations to attacks to gain material. They have databes of chess openings programmed (if this then this, rather than is this move safe). They can even adapt to the player and make moves BASED upon that.

I saw a game of X3D Fritz vs Gary Kasparov (best at that time) and Gary was losing, but pulled a draw out.

For the basics, you have it all down, I think, (I am ranked Class A in chess at the moment, very close to expert) from what I can see that's a good foundation.

P.S. Want to play? Thanks for your reply. I accept your challange to Chess! However I am still looking for some specific answers for the problems I posted. There must be a better way of doing check detection. For the AI I have read some things about USING a random hash table using XOR or something but I didn't quite understand it. I just need someone to clarify it a bit for me, and tell me in practical terms what I need to do. I don't want to create the next Deep Thought, just something that plays OK.First of all, for the pieces, they do not have to test the entire board, a check to see what moves are legally possible must be done first. There wouldn't be much of a point in checking if a pawn can move to the right 6 squares. So that limits the checking. I believe that is how AI does it, I am not sure there is another way.

Series of checking as follows..

All Possible moves for the piece->all possible squares that can be moved to without its own pieces in the way-> can a piece be taken/taken back with gaining material or having equal material after the trade.

As for XOR and other methods....not really sure. I only KNOW C pretty well, not a fan of blitz basic.

In C...or C++ actually since you can use OBJECTS....it is basically a bunch of checking with if statements for each peice.Thanks but do you have any help with the code?Sorry, I have no experience in blitz basic, and as for C I don't think it would be too fun or as easy to program all of it (or Assembler Yikes )It doesn't matter what language the principles are the same.Have you tried using gamemaker?

www.gamemaker.nl

Probably the highest level language i have seen.....function statements are replaced by icons, very easy to pickup.Quote

Probably the highest level language i have seen.....[highlight]function statements are replaced by icons[/highlight], very easy to pickup.


What? How is that a high level language?Yes I once used something similar to that called The Games Factory. GX1_Man, they are basically a bit like a "programming wizard". You have the "play" area where you drag and drop objects and things, you can set them to various modes such as wall, ladder, whatever. The actually programming part consists of various wizard like questions. For example, you'd create a new line about collision. You'd then select from a menu two object types you've created on the play area, then you'd add the actions you'd like, for example alien collides with player, playerlives = playerlives -1. Well that is how TGF worked, by a quick glance at the website that is how that works too. Although easy to use, their problem is that you can only really make what they are geared to make, that is arcadeish style games, and I don't think it would be suitable for creating a chess game, especially when it comes to AI. But thanks for the suggestion anyway, johnchain.No, I meant high level language as in not by complexity....you know....

Assembly being low level....
C being mid-level
Visual Basic being High Level

GML as stated on the website is like a combination of C++ and Visual Basic.http://en.wikipedia.org/wiki/High-level_programming_languageYes, yes, but does anyone have any actual HELP for my problems!?


Discussion

No Comment Found