aspose file tools*
The moose likes Game Development and the fly likes If you have an interest in chess programming using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "If you have an interest in chess programming using Java" Watch "If you have an interest in chess programming using Java" New topic
Author

If you have an interest in chess programming using Java

Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Have a look at my program, the link is in my signature. I'm interesting in collaborating with someone on an ongoing basis, so we can learn from each other. There's more potential work in this project than I'll ever have time for. I consider myself pretty adept with Java fundamentals, but kind of weak with advanced data structures and algorithms.

Anyways, if this is interesting to you, reply here or send a personal message, maybe we can work something out to our mutual advantage.

None of my firnds are into programming, and I have tried some sites dedicated to chess programming, but everyone has their own projects, and I don't see much room for collaboration there.

also, the link contains a technical overview page, which describes overall program design. If there are any comments or questions, I am all ears.

cheers.
Fred.
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
All ears?

1) Why work in something that's already done?
2) What are you really looking for?
3) How good are you at playing chess?
4) Is your goal to make a program that plays chess better than you?
5) Don't you believe there must be a formula for the Perfect Move?

Depending on your responses, we could have interesting things to talk about...
---o---
Let me invite you to play a nice game of chess online:
Click on the link http://www.fritzserver.org/PlayChessSetup.exe to download a chess client I like (33 mb).
Create your account and let me know about the name you chose. Later we could coordinate day and time for playing.
My name in that server is Sergio Campos (white spaces are valid). You can consult my ELO and other data.
Please, feel free to reject my invitation. I won't be offended. It's just to know each other better.


"There are times when the easy things should be quick and easy" [...] "and worry about the theory later" -Fred Hamilton-
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Thanks Sergio, I will check out fritzserver soon.

I have no real interest in "building a better mousetrap". This is just an interesting project for me, and a way to learn java. Call it a hobby. I have a few programs already on my computer that are better than anything I'll ever design. I just want to know what I can accomplish.

I have played chess for 30+ years. I'm ok, probab;y I can play about 2000 ELO on a good day. I doubt any program I write will ever beat me, but I would be a proud father if it ever happens.

p.s. I don't believe in a formula for a perfect move. Unless I am trying to calculate a forcing combination or something.
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
Fred Hamilton wrote:I would be a proud father if it ever happens
I received your message. How about playing today at the same time you sent the post quoted above.
At that time I'll check if you are conected. I'll do the same for a few days.
When I see you connected, I'll send you a challenge. I'll keep Google Talk open (firifirito@Gmail.com)
See you!
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Fred, your current program is a great first attempt towards chess programming. I play chess for a hobby and I am not good at it. So I may not be a good option in the game development.

"Sergio C. Campos J. " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Amit Ghorpade wrote:Fred, your current program is a great first attempt towards chess programming. I play chess for a hobby and I am not good at it. So I may not be a good option in the game development.

"Sergio C. Campos J. " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.


Well Amit, you don't have to be a good chess player to write a chess program, at least not one at this level. Just and understanding of the concepts of chess takes you a long way.

My program would be a lot better if I was fluent in recursive programming, but that stuff makes my head hurt. So I am slowly trying to build up my recursion skills with a study of basic, non chess related stuff.
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
I can play about 2000 ELO on a good day

Good game Mr. Hamilton... Human like. No need to use the server tools to discard chess software help.
Probably a draw? I don't think so. You won.
Time is also part of the game and a good player must not forget about it.

It was a friendly recognizing "flight"
I'm sure I haven't faced your strength.
But, since I'm a natural code breaker,
I believe you're a little bit mistaken about your ELO.
I estimate your ELO in a range of 1450-1700.
You played with a strength of about 1300 ELO.

---o---
Talking about chess programming:
Years ago I programmed a chess player in Pascal.
Now I'm only interested in the Perfect Move in chess (since it doesn't exist yet).
In the year 1997 chess world champion Kasparov lost a match against Deep Blue (a program)
He said his defeat doesn't mean the machine playing is perfect. Right!

Perfection cannot be demonstrated through defeating imperfect humans.
It must be proved with perfect simple code.

I think perfection in chess could be understood and reached through a philosophical approach.
In 1999 I got married. My wife went back to work before I did.
Free time... Free mind....
I programed in Visual Basic a solver for the Bishop & Knight checkmate.
Instant perfect responses, no matter the low speed of the machine.
I haven't seen it before (nor after).
I built a file storing 16777216 responses. I converted any position into a Long index number
indicating the place in the file where the appropriate response could be found.
My slow computer took six days to build that file. But the code making that job
could be far improved. And the file could be analyzed to find a pattern in the sequence of bytes.
This way, a formula can be determined. No doubt it already exists in nature.
Other Three, four or five piece endings could have their own formulas or could it be a wider
formula that covers all of them. A formula for the perfect move in any chess position is near from these concepts.
I feel I haven't seen a good enough ending engine. Bad philosophy everywhere...



Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Interesting, your Bishop and Knight checkmate routine sounds like you created a tablebase, it is just a question of doing a lookup, so no real thinking by the computer is involved? There are lots of chess tablebases out there.

In that sense, yes it is possible to have perfection in simple positions. In general, though I still say there is no perfection in chess, because in any given position, there are probably a few moves that are equally good. Ait also depends on playing style. In my program I end up with an array of moves that the program has evaluated as equal, then I select randomly from this list. The key to making the program stronger is to address the way in which this value is assigned to a move.

In regards to ELO, it is relative to the pool of opponents you play against. I have found that my rating in over the board tournament chess where I live is usually higher than my online rating. Like I said, 2000 on a good day, when I am at my peak, not rusty, and concentrating well.
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
In regards to ELO, it is relative to the pool of opponents you play against.


You're right. And there's a few different formulas to calculate it.

so no real thinking by the computer is involved
What is thinking?
What is that useful for when you have a package with all the answers?

I rather the task of packaging intelligence (if possible) so to spend thinking time only once.

By the way... The code I copied in "Who said Java is easy?"
is a logic game where the user have to guess a number of four different digits.
The "bet number" must comply the same.
Comparing user "bet number" against the "secret number"
a digit in the same position is called a "FIJA" ("F")
a digit in other position is called a "PICA" ("P")
For example: Secret number is 5942
Some attempts to guess it with corresponding count of FIJAS and PICAS:
After several attempts there is enough information to rightly guess then number.

I already know an algorithm where the computer guess a number (7 attempts at most)
simply discarding all the numbers not complying user responses (unintelligent but efficient).
Human cannot solve the problem this way. Nonetheless a disciplined human can guess the number in 7 attempts.
So it's always a fair match.

Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Sergio CamposJ wrote:

so no real thinking by the computer is involved
What is thinking?
What is that useful for when you have a package with all the answers?



Point taken, but even if it is theoretically possible to solve chess, it impossible to implement such an idea, the variations are just too vast.

I'll take some time to digest the rest of the post and respond to that later.
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
if it is theoretically possible to solve chess, it impossible to implement such an idea, the variations are just too vast.

I'm hearing that since I was seventeen
It is possible... You just need some faith...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18655
    
    8

Sergio CamposJ wrote:I'm hearing that since I was seventeen
It is possible... You just need some faith...


Well, no. If you have to implement an algorithm which will take billions of years to produce an answer, and you need an answer within the next few minutes, then faith isn't going to get you the answer using that algorithm.

But perhaps there's some other algorithm; or perhaps quantum computing will change the rules; or perhaps there's some other kind of answer which is much easier to compute and is nearly as good. One can always search for things like that. That's where the hope comes in. But the idealistic idea "You can do anything if you try hard enough" just isn't true on its own.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
I agree with Paul The numbers are astronomical. But ok Sergio, I assume you have given this some thought. What is your estimate of the amount of disk storage that would be required to store all the information required for perfect decision making in chess.
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
What is your estimate of the amount of disk storage that would be required to store all the information required for perfect decision making in chess.

300 bytes

But I think you'll need some faith to accept it
and quantum computing to understand it

P.S. I'm sorry to bother you with this discussion which is really going to anywhere
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Sergio CamposJ wrote:
What is your estimate of the amount of disk storage that would be required to store all the information required for perfect decision making in chess.

300 bytes

But I think you'll need some faith to accept it
and quantum computing to understand it

P.S. I'm sorry to bother you with this discussion which is really going to anywhere


300 bytes? okaaaayyy, if you say so. How's that for faith? Let me know when the prototype is ready.

anyways, I'm not bothered, so no need to be sorry on my account, you're the one who said it could be done, I was honestly curious as to how you might support that claim.

looking forward to another game on playchess, any time.

regards.
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
It is fair to state here that Mr. Hamilton has beaten me three times playing chess.
Three consecutive defeats surely say something: I've been tired these days... (lol)
Tirthankar Mukherjee
Ranch Hand

Joined: Apr 08, 2006
Posts: 51
Fred Hamilton wrote:Thanks Sergio, I will check out fritzserver soon.

I have no real interest in "building a better mousetrap". This is just an interesting project for me, and a way to learn java. Call it a hobby. I have a few programs already on my computer that are better than anything I'll ever design. I just want to know what I can accomplish.

I have played chess for 30+ years. I'm ok, probab;y I can play about 2000 ELO on a good day. I doubt any program I write will ever beat me, but I would be a proud father if it ever happens.

p.s. I don't believe in a formula for a perfect move. Unless I am trying to calculate a forcing combination or something.


I thought that I am the only crazy person to write my own chess GUI (with some positional search) ... but now I find some more ... I think we would have a good time in this thread. I want to develop the chess engine later .. now going through the standard algorithms. Programming is really a hobby to me and I develop what I need, so right now it is a good chess GUI and learning Java as well , and recession all over made it easier for me to provide time my joining in the MNC postponed till Sept '09 . Anyway so lot of time in hand ... and lots to work to do ...
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Tirthankar, do you have a web version of the GUI that you can show a link for? My main GUI class, along with all the event listeners and action handlers, is in a class that extends JPanel, so it works equally well in a desktop JFrame or in a JApplet like you see in my website.

So for what you see on my website, my main JApplet container class is as follows...
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Greetings.

I have done a lot of updates to the program and the website in my signature.

Finally the GUI is pretty much where I want it.

The engine features some improved recursive algorithms which set the stage for meaningful improvements in playing strength.

Anways, the website linked in my signature includes a description of all the features. Of interest to people here is a programmer's page which I have a lot of plans for. At the moment there is just a brief description of the engine as well as links to the complete java source code for the chess engine.

Questions/comments are of course welcome.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8829
    
    5
I can't help myself, I gotta throw my two cents in

Chess programs are already world champions! Same with Checkers programs, bridge, backgammon, Othello (I believe), and so on...

On the other hand, the best Go programs in the world aren't good enough to beat millions of Go "club players". Why not spend time working on a problem that hasn't been solved yet?

Full disclosure: Somewhat like Chess, Go has well defined subsets that can be addressed. For instance in Chess you could work on a program that could solve "mate with only a knight and a bishop" problems. I've been working on such a subset problem within the Go realm.


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11406
    
  16

Bert,

Give the guy a break!!! That's like telling someone who's never coded "Don't write a 'Hello, world!' program because it's been done. Write an intuitive spreadsheet application".


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8829
    
    5
Hey Fred,

Wait, it wasn't me who suggested that anyone write a Chess program - even though it's been pretty well solved, it's still HARD!

I was kind of suggesting taking on a smaller subset, either in Chess or Go

Bert
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
No problem Bert, this isn't the first time I have faced that question. My answer is the same, I have no interest in building a better mousetrap, There is free software that I have on my computer that plays far better chess than anything I will ever write. I just wanted a fun learning project, being a life long chess afficionado, a chess program was the logical choice. And it has become a hobby of sorts. And there are a lot of people out there who look at things the same way I do.

This is a long term hobby. Ten years down the road, I will still be tweaking my program, and maybe, just maybe, It might be strong enough to beat me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: If you have an interest in chess programming using Java