File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Building a chess applet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Building a chess applet." Watch "Building a chess applet." New topic

Building a chess applet.

Neil James Frarey

Joined: Jul 03, 2003
Posts: 2
I would like to build a chess applet. Is this a difficult thing to do?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

Laying out a board and moving pieces around shouldn't be too much of a challenge. What might make such an undertaking interesting is the AI necessary to make the computer 'smart', or, if you are interested in a multi-player game, the networking and hand-shaking to make two instances of the game talk to each other.
Should be a fun and educational project!
[ July 03, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
James Clinton
Ranch Hand

Joined: Jun 23, 2003
Posts: 190
The AI can be solved using Search Trees and MiniMax Algorimiths. If you dont know how to code search trees find out.
You may want to search for bitboards. This is one of many solutions which could be used to represent the board, and personally I think its the best. It works by using a type long (64 bits, as this is the total number of squares on the board) to represent each peice.
Learn about this and if I were you, begin with noughts and crosses first.
See a online version of chess with different rules involving dice..!!

A great example of Flash and Java together.
/ James
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Neil!
I would like to build a chess applet. Is this a difficult thing to do?
It sounds like a good beginner's project. Go for it! Check back here often for feedback. I'm sure you'll find plenty amongst our thousands of programmers.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Neil James Frarey

Joined: Jul 03, 2003
Posts: 2
Thanks for all the encouragement!
I need all the help I can get, thanks for the tips!
Eric Hoskland

Joined: Oct 12, 2000
Posts: 29
A chess applet was my first Java/OO undertaking as well. I still have it on the web
It's not very good and still a little buggy but I get all nostalgic looking at it.
It's definitely a good beginning project, especially if you're not really familiar and comfortable with the whole OO paradigm.
The two pieces of advice I cannot stress enough and wish I would have followed when I started are:
"If you have too many special cases, you are doing it wrong."
"Get your data structures correct first, and the rest of the program will write itself."
(taken straight from Granny Java)
I rewrote the whole program like 3 times because my data structures and special cases got so nasty.
good luck and send me the URL when you get it up on the web
I agree. Here's the link:
subject: Building a chess applet.
It's not a secret anymore!