Chess

Blitz3D Forums/Blitz3D Programming/Chess

Mr. Bean(Posted 2006) [#1]
Does anyone has examples for Chess.


GfK(Posted 2006) [#2]
If this is your first project (which, looking at some of the other questions you've asked I suspect it is) then I strongly recommend you start with something easier.


Boiled Sweets(Posted 2006) [#3]
What Gfk said.


t3K|Mac(Posted 2006) [#4]
what boiled said.


octothorpe(Posted 2006) [#5]
Two player chess isn't really that hard to pull off - writing the AI for a one player game is the difficult part.

Basically you need a two-dimensional array to represent the board. Each element will store which piece occupies that spot. For simplicity, you could use strings.

At the very least, you need a function which tells you where a piece can move to and a function which tells you whether a given board position puts a king in check. Using these, you can test for illegal moves, checkmate, and stalemate.


Ricky Smith(Posted 2006) [#6]
What octothorpe said ! Excellent starter project 2 player chess and you could always add in a single player option later.


Sir Gak(Posted 2006) [#7]
Yeah, wrting a chess game AI is something top programmers have sold their souls to do. I think it was IBM's supercomputer Deep Blue that won over some top-rated chess players back in 1997. It comes down to assessing moves, assigning values, developing strategies. A whole lot if IF-THEN conditions. If fact, almost ENTIRELY IF-THEN conditions would be the bread-and-butter, the meat, so to speak, of your program. But, you don't have to write a program that needs a supercomputer to run, if you stick with a simple two-player game. That way, humans are the decision-makers.


GfK(Posted 2006) [#8]
I think it was IBM's supercomputer Deep Blue that won over some top-rated chess players back in 1997.
It was Deep Blue. The guy it beat (in a rematch) was Gary Kasparov.

The way Deep Blue worked, was by playing the game through to every possible conclusion before making its move. You wouldn't expect a standard chess engine to play through any more than the next eight moves or so, as even that results in several million possibilities.

Yeah, two-player chess is relatively simple. But who'd want to play it?


Ross C(Posted 2006) [#9]
2 Players? :oP


GfK(Posted 2006) [#10]
2 Players? :oP
That rules you out then, Billy no-mates. :P


Ross C(Posted 2006) [#11]
Was hoping you'd join me, Nigel ;o)


big10p(Posted 2006) [#12]
When Deep Blue beat Gary Kasparov, it was a complete fix, by all accounts. IBM cheated and did him up like a kipper. There's a very interesting film about it. Can't remember what it's called, though.

Anyway, back on topic...


Sledge(Posted 2006) [#13]
This?


Sir Gak(Posted 2006) [#14]
Yeah, it was Deep Blue. Now, IBM is working on Blue Gene, which does some 30 trillion flops (petaflops). But, even that computer, as fast as it is, will be drarfed by its bigger brother will be coming out, with a performance of 360 petaflops. http://www.research.ibm.com/bluegene

I don't know about you, but I think 360 trillion ANYTHING is a lot (in miles, that's about 60 light years), the only exception being Avogadro's Number, 6.022 x 10^23, which makes even 360 trillion small by comparision because Avogadro's number is approx 1.6 billion times bigger.


big10p(Posted 2006) [#15]
Yep, that's the one, Sledge. :)


octothorpe(Posted 2006) [#16]
What a shitty film! Over-produced and lacking any insight into the games. Not a movie for a fan of chess.


Andy(Posted 2006) [#17]
>The way Deep Blue worked, was by playing the game through
>to every possible conclusion before making its move.

Not according to IBM.

>You wouldn't expect a standard chess engine to play
>through any more than the next eight moves or so, as even
>that results in several million possibilities.

True.

The difference between deep blue and deeper blue was in the dedicated chess hardware. The machine that beat Kasparov, was also trained specifically on every recorded Kasparov game. Even the IBM engineers later admitted that it was specifically designed as a kasparov killer, and that another chess master could very well have beaten it as it was playing from knowledge of Kasparov.


Andy


puki(Posted 2006) [#18]
http://www.blitzcoder.com/cgi-bin/showcase/showcase_download.pl?id=gjw08282003210710&fileurl=http://members.aol.com/gjwcarsaig/blitzbasic/chess.zip

Not my code. However, take a look.


puki(Posted 2006) [#19]
Now, not sure what level programmer you are "Mr Bean" - so don't take any offence.

My advise is to make copies of the source and then strip the code away in lumps.

If someone gives me a piece of code that is a complete game (I don't think this one is complete) - I reverse engineer the code, ie, I start remove whole sections that I would think were added after the initial stages. So, with this one, I would work it back to the setting up of the board itself - I'd then add in bits of code (in the order I think they should be added) - but avoid adding in non-essential code (such as load/save, timer code, additional features such as what appears to be saving a screen shot) and basically build the code back up with my own coding style.


Andy(Posted 2006) [#20]
Oh, I almost forgot...

The gamedev 'Chess programming' articles are a very good introduction to chessprogramming.

http://www.gamedev.net/reference/list.asp?categoryid=18


Andy


Damien Sturdy(Posted 2006) [#21]
I'd reccomend making Draughts ("Chequers" or whatever). It's a decent project but it's not so tough AI wise :) It was my second project, after "Pongo"- a penguin platform game which was pretty naff. (Talking way back on the BBC here.)


Sir Gak(Posted 2006) [#22]
Cygnus:
a penguin platform game which was pretty naff

What's "naff"?

Oh, and for a bonus, here's info on the Constellation Cygnus, thy namesake:
http://www.seds.org/Maps/Stars_en/Fig/cygnus.html


Kuron(Posted 2006) [#23]
What's "naff"?
In the UK I think it means "cool", in the USA it usually means "sucks". Haven't heard it routinely used in the USA since I was a kid though.


Kuron(Posted 2006) [#24]
For a good example of source code for Chess, go here and scroll down to "Chess".


Paul "Taiphoz"(Posted 2006) [#25]
Id like to not agree with you all.. lol..

About AI that is, Nintendo did an amazing job on gameboy chees and as far as I am told, its logic only scanned 2 moves, with 2 moves being the possible outcome of moving every peice of both players twice.

and that ai was damn good. and beat me more than I beat it.

you dont need to scan down so many levels to make a good chees ai , you simply have to scan a few levels and make sure your scoring system is good enough to allow for a clear choice to be made with such little scan data.


GfK(Posted 2006) [#26]
Saying it is one thing, Yavin. Doing it is quite another.


puki(Posted 2006) [#27]
Or you spend hour after hour after hour typing in book moves so that your engine plays smart as far as it can - in the hope that the player doesn't play a bizarre random move too soon in the game - then it switches to AI.

I remember my mates at Mastertronic creating something like 'Masterchess' - claiming that it did a move a second. What they didn't point out was it relied on you making book move responses to its moves.


Sir Gak(Posted 2006) [#28]
Yavin:
"And he that breaks a thing to find out what it is has left the path of wisdom" - Gandalf

Gandalf said lots of cool stuff.

Like, Fool of a Took. Next time, throw yourself in!


Andy(Posted 2006) [#29]
>Gandalf said lots of cool stuff.

You do realise that Gandalf is a fictional character from a book?!


Andy


puki(Posted 2006) [#30]
No - I saw him on the telly.


Andy(Posted 2006) [#31]
>No - I saw him on the telly.

So Darth vader and Luke Skywalker must be real as well.


Andy