Chess game

I need guidance on how to model a chess game that involves two human players. Since this a Java oriented game and I am a new user as well as a learner, I need to be guided on the number of classes that can be incorporated in this game as well as the substantial roles of each class. I have tried examining some of the classes to involve the Board class, Piece class, legal move checker which extends board as well as the GUI on which the entire game shall be run. I need guidance on how I can join all the classes as well as some hints on attributes and operations that shall be involved in these classes.
I have been thinking of sub classifying the piece class into sliding pieces and the non sliding pieces as well as representing pieces as images on the board. In my game, Enpassant rule is not operational, the pawn piece does not become updated at the end of the board and the castling rule does not apply too.
I need to have my players on the same computer not on different computers or the Internet.

As a new user/learner, you should try something a little less ambitious like checkers, and if thats too hard, Tic Tac Toe. It may sound like im joking about your abilitys, but creating Tic Tac Toe using classes for X's O's and the Board, will give you the basic understanding of how classes interact with each other, and how to design a basic object oriented game.
It's only a small step from Tic Tac Toe, to Chess IMHO since chess only adds more game logic rules, but the class scenario is going to function pretty much the same, only more methods and rules to follow. Once you reach the point of creating the chess game, it's only a matter of creating a basic piece thats extended by all the various piece types who define their own movement rules.
-Adam

Similar Messages

  • Chess game in Mac OS X is there a bug fix for it

    This is not a major issue but I have noticed it on all the Apple computers I have played the Chess game that comes with the Mac OS X and it seems to only involve the Pawn making an illegal move when capturing another piece. As we all know the Pawn can only capture by one space in a diagol move yet the Mac OS X supplied Chess game a Pawn will and can often capture an opponents piece that is directly next to it, yet still moves in diagnol fashion and for the same token this illegal move can is sometimes offered to me if I ask for a move hint. This is very frustrating as I play the supplied chess game often is there a fix for this bug

    Hello again Daniel...
    I found a thread where "cornelius" suggested corrupt preferences as a potential cause for Chess problems...
    His solution was to go to your Home > Library > Preferences and drag your com.apple.Chess.plist to the DeskTop and Restart your computer and reopen the Chess game...see the link
    http://discussions.apple.com/thread.jspa?messageID=2758136?
    Good Luck dave
    iMac G5 17/1.8/FirstGen/1GB RAM Mac OS X (10.3.9) Seagate200GB/WD160GB/iSight/Shuffle/SecGen Nano2GB
    iMac G5 17/1.8/FirstGen/1GB RAM   Mac OS X (10.3.9)   Seagate200GB/WD160GB/iSight/Shuffle/SecGen Nano2GB

  • Programming a Chess-game - Design Tips

    Hello,
    I'm definatly not new to programming, but I'm a beginner at Java. Now I'm trying to program a little chess-game, which should teach me some OOP-techniques and to get some experience with Java.
    Well, I have some ideas for the game in mind and already realized a few things, but I want to do it the right way and get some advice from you.
    - The chess board:
    Currently, I have a class handling the drawing of the board, getting the screen-coordinates, etc.. The class "GameBoard" extends a JPanel and I overwrite the "paintComponent"-method to draw the board.
    I have a second class "Field" that stores informations of one field: What color the field is, which piece is placed on this field and which player "owns" it. Also, each one of these "Field" is getting passed its coordinates on the screen from "GameBoard". This helps me later, when I want to decide, if the field is clicked or not.
    Now, is this a good way to implement the board and the fields? I have another option, which would be, that I throw out the class "GameBoard" and instead have a "FieldHandler" class. Now, the class "Field" would extend JPanel, overwrite "paintComponent" and draw a square on the screen. "FieldHandler" gives each "Field" the information, if it should be black or white. "FieldHandler" would also calculate the x- and y-coordinates for each field.
    Is this method better? I don't really know performance wise, because I have to add 64 JPanels to the contentPane, which means, that all 64 Panels need to be drawn seperately. I don't know if this is a good way, but maybe it doesn't really matter. One advantage would be, that I could change the color of a field easily, for example when I click or hover it, which is not that nercassary, but still nice.
    Maybe there is an even better way?
    - The Pieces:
    Well, I don't really have a clue how to draw the pieces on the board. I could also make them extend JPanel and then draw the image onto some coordinates. But that doesn't seem too right. What about BufferedImage? I don't really know how to use it, neither when it is appropriate to use. I think I get more advantage of this, when I have animations, but that's definatly not my intention.
    The only thing I know is, that I can show an image on the screen with:
    ImageIcon test = new ImageIcon("Test.gif");
            public void paintComponents(Graphics g) {
                test.paintIcon(this, g, 100, 100);
            }But is this right or even way to do it? I'm somehow unsure, if an "ImageIcon" is right for a chess-piece. Any other ways of doing this?
    The "Piece"-class itself is just an interface that the classes "Knight", "King", etc. extend. It draws the piece onto the screen, set the owning player, sets the coordinates of a piece (with the help of the "Field"-class; The Field doesn't know it's exact coordinates, just "A7", "E3", etc.) and some other functions. All pieces are handled by a "PieceHandler", which could provide functions for counting all pieces on the field, initialising every piece and maybe some more things.
    Anybody got some advice on this approach?
    This should be enough for now. I would be very thankful for any kind help, I really want my first project to be as good as possible, since I want to learn OOP and Java better.

    - The chess board:
    Currently, I have a class handling the drawing of the
    board, getting the screen-coordinates, etc.. The
    class "GameBoard" extends a JPanel and I overwrite
    the "paintComponent"-method to draw the board.
    I have a second class "Field" that stores
    informations of one field: What color the field is,
    which piece is placed on this field and which player
    "owns" it. Also, each one of these "Field" is getting
    passed its coordinates on the screen from
    "GameBoard". This helps me later, when I want to
    decide, if the field is clicked or not.
    Now, is this a good way to implement the board and
    the fields? I have another option, which would be,
    that I throw out the class "GameBoard" and instead
    have a "FieldHandler" class. Now, the class "Field"
    would extend JPanel, overwrite "paintComponent" and
    draw a square on the screen. "FieldHandler" gives
    each "Field" the information, if it should be black
    or white. "FieldHandler" would also calculate the x-
    and y-coordinates for each field.
    Is this method better? I don't really knowWhat I'd do: just paint a chessboard pattern from a static image. Can be loaded from a file, or can be generated once dynamically. Don't care at all about fields.
    Have some pixel-to-field coordinate mapping somewhere. Should be nothing but a simple multiplication.
    Have a List of chess pieces. Have those know what they look like (maybe using a delegate object which contains an image), have those know where they are and where they can go. When painting, iterate over the list, transform the coordinates to pixels, get the UI delegate and paint its image. Why bother calculating 64 fields if all you have are 32 pieces or less? And whether a field is black or white doesn't matter to the game.
    When the user clicks onto the board, get the coordinates of the click and transform them to the field coordinates, that you can then look up in the list of figures. If you find one, you can still paint a marker onto the board and underneath the piece image.
    This is what I'd do. Other approaches might make sense as well..

  • How to create chess game using Adobe flash CS3

    I want to develop a web application that when a user is login the game will automatically search for oppents onlinethat are accessing the same website. I want to design a chess game that does not contain any AI programming. What I want is that a simple chess setup that online user can only play.

    use google to search for tutorials.  that's a very complex undetaking so unless you feel you have advanced programming skills, you would be better served starting with a simpler game like tic-tac-toe.

  • Help in a chess game

    hi can anyone help me? i would like to create a simple chess game for only two players.

    hi can anyone help me? i would like to create a
    simple chess game for only two players.in contrast to a simple chess program for more than 2 players?
    A chess program for 2 players is rather simple, it only needs an engine to determine whether a proposed move is legal or not.
    The tricky part is adding a computer player.

  • Use j2me to develop a chinese chess game

    Hi, i am new to J2ME but i have some experience on J2SE.
    Until now i still have no idea how to develop a j2me system. i already install j2me tool kit but dunno how to use and also installed Forte. The forte is just like a java builder and i now is working on it.
    Can anyone help me with this programming? I have a project to do and the project title is Developing a Chinese Chess Game in PDA using J2ME.
    Pls help me and give me some references or some sample coding of j2me.

    Alot of stuff online. Here's some to get you started:
    wireless toolkit tutorial -
    http://developers.sun.com/techtopics/mobility/midp/articles/wtoolkit/
    sample codes and articles-
    http://developers.sun.com/techtopics/mobility/allsamples/
    http://developers.sun.com/techtopics/mobility/allarticles/
    http://developers.sun.com/techtopics/mobility/allttips/
    Hope this helps. Good Luck.

  • Chess game programming

    I have to create a text-based chess game between uppercase and lowercase letters against each other using a two-dimensional arrays.
    1. I have to create the board and initialize the position of the letters.
    2. I have to give the output of the initial state of the game, showing the board and the first positions of the letters.
    3. I have to create the moves.(Meaning that i have to create an input to perform the entering moves)
    And i have to make sure that with every bad input the program will to repeat the input....
    If anybody of you have programmed a chess game like this before, i would appreciate any kind of help....
    Edited by: 812599 on Nov 17, 2010 8:26 AM

    mario.beka wrote:
    meacod wrote:
    812599 wrote:
    I have to create a text-based chess game between uppercase and lowercase letters against each other using a two-dimensional arrays.
    1. I have to create the board and initialize the position of the checkers.Just to give you a nudge - are you familiar with chess? What's the size of the board? How might that affect the structure you store your 'pieces' in? How will you represent pawns as opposed to kings, queens, rooks, and so forth?
    Scratch out some ideas on paper,
    Turn that into some pseudocode,
    Write some Java,
    Then come back to us if you have a specific question.Yeah that's the problem, cuz i have never played chess in my life....I'm just reading around now for the rules and movements of this game...in that case, don't bother.
    A decent chess program requires in-depth knowledge of the game, knowledge only gained through years of playing it at competition level.
    I've a small library of books about chess, have played it for going on 30 years, plus 15 years experience using Java professionally, and I'd not consider writing a chess playing program in Java as something I'd undertake on my own (and yes, I've studied the possibility of writing just that in a variety of languages I know about over the years, and even made a start a few times only to abandon it when the project became too big for me to handle).
    If you're only looking to make a digital chessboard, that's a much simpler task and one that you can certainly attempt even without knowing the game (except maybe the starting positions and accepted icons for the pieces and the size and nomenclature for the board and its fields).
    Start with that, then add rules validation as players move pieces. Start with large rules (like enforcing that pieces can only move legally, in itself a somewhat daunting task as there are several pitfalls and special rules depending on piece positions).
    At this stage there's still no AI, no computer player option. That's where the real work sits, and it's very much a non-trivial task.

  • Chess Game On Oracle Form 6i

    Hi Friends
    I have created chess game on Oracle Developer Form 2000 6i & my problem is that i have created some function for moving of Bishops, Kings, Queen, Knight etc. on Push Button and my Function of Knight is ..
    FUNCTION check_move_knight(p_from in varchar2, p_to in varchar2) RETURN BOOLEAN IS
    BEGIN
    If
              abs(substr(p_from, 2,1) - substr(p_to, 2,1)) = 2     and
              abs(substr(p_from, 4,1) - substr(p_to, 4,1)) = 1
              or
                        abs(substr(p_from, 2,1) - substr(p_to, 2,1)) = 1     and
              abs(substr(p_from, 4,1) - substr(p_to, 4,1)) = 2
    then
              return true;
    else
              return false;
         END IF;
    END;
    I want to write Function of King and Queen please tell me which type of function i can write on form ... :)
    Thanks & Regards
    Adeel

    You are playing with a 8*8 matrix.
    I suppose that you have an in memory PL/SQL table to simulate this matrix, with 1 if there is an item else 0.
    The King (exept the special move he can do only once - castling ?) can move only one square around, so X and Y can be -1 or +1
    The Queen can move like a pawn, a bishop and a tower.
    Francois

  • Interface for chess game

    Hi all,
    I am new to java and in the process of finding a job. Last week i was asked by an interviewer how to design an interface for a chess game and implement it in a class. Pls. someone help with the best answer i can give.
    Thanks in Advance !

    johndjr wrote:
    I am new to java and in the process of finding a job. Last week i was asked by an >interviewer how to design an interface for a chess game and implement it in a class. Pls. someone help with the best answer i can give.When you don't know say, "I don't know".
    If you have to ask us you will never be able to pull off the fake.
    back when I had to interview people I would take an honest I don't know or I'm not familiar with that over someone trying to make up an answer and looking like a fool.Interviewees were also required to answer questions on the spot rather than being given time to search the internet and prepare a canned response.
    In fact in any job interview I've ever had (the last not 2 years ago) that was still the norm.

  • Chess game email

    Can anyone tell me why I open many emails, they are wmv and all I receive is a chess game?

    Hello Sandbayrr:
    Without more information, it is not possible to make constructive suggestions. You mentioned E-mail - what mail platform are you using? Are the E-mails from the same sender? The problem does not, on the surface, appear to be a browser related issue.
    Barry

  • Chess game hangs in Leopard

    Hi:
    This isn't really an earth-shattering problem, but I've found that the Chess game that is resident in Mac OS hangs up in Leopard. I'll be playing a game, and all of a sudden, the computer will simply not make a move, and that's it. Can't undo, can't go forward. Doesn't seem to matter whether I have the computer set to play stronger or faster.
    This never happened in 10.4 on my old Quicksilver G4, and I was wondering if anyone has any experience or insight into this?
    Thanks.

    The problem seems to be a bug in the logic, although I have not looked at the code to confirm it. For those that have the time, I have included the game log to cause the game to fail. From that, you should be able to identify the problem and offer a fix. Note, the earlier Chess version (2.1) running on Tiger does not seem to have the same bug, but the issue it could very well be an OS issue.
    Chess version 2.3, running Leopard on MacBook Pro.
    Player is White; Computer is Black (obviously);
    Moves:
    1. d2-d4 d7-d5
    2. h2-h4 a7-a5
    3. h4-h5 a5-a4
    4. Nb1-c3 Nb8-c6
    5. e2-e4 e7-e5
    6. e4xd5 Nc6xd4
    7. Ng1-f3 a4-a3
    8. b2-b3 Nd4xf3
    9. Qd1xf3 Bc8-d7
    10. g2-g4 Bf8-d6
    11. Nc3-e4 Bd6-b4
    12. c2-c3 Bb4-e7
    13. g4-g5 f7-f5
    14. g5xf6 Ng8xf6
    15. Ne4xf6 g7xf6
    16. h5-h6 Rh8-g8
    17. Qf3-h5 Rg8-g6
    To get Chess to "hang", White has to place the Black Rook at G6 in jeopardy by either moving White's Rook at H1 to G1 or White's Bishop at F1 to D3...either move will cause Chess to "hang" as Black never recovers and makes a move. The bug is inconsistent in that moving White's Rook at H1 to H2 and then from H2 to G2 does not cause the bug, but moving White's Bishop from F1 to E2 and then to D3 when Black's Rook at G6 is exposed (Black moves pawn F6 to F5 and then to F4) does cause the bug.
    On my system, this is the only time it hangs. Higher skill levels have never caused Chess to hang.
    Happy Bug Hunting.
    First one to fix it wins.
    -911eDoc

  • Chess Game Complete

    Hi Everyone
    I have finally completed the first launch of my AFCS chess game.
    Hopefully it will turn out to be a worthy example of what is possible with AFCS.
    Please have a try at http://www.happydaygames.com.au ( offcourse you might need to source an opponent as there are probably no players at the moment ). If you can't source an opponent there is also an example of a single-player Sudoku game I have developed on the site.

    Thanks Aponnusa
    It's great to have some positive feedback!
    I have put a new feature in which allows you to challenge a player that is not online. An email is sent to the player for acceptance. Hopefully this makes it easier to find a game.
    There are now two lobby tabs - one for online players (on click an AFCS challenge Alert is sent) and another for offline players (on click an email is sent)
    Enjoy!
    Oliver

  • Chess game opens unwanted windows

    Having a issue that just croped up in the chess game: now, when I go to NEW, another window opens, which I don't want.  I'd like to start over & play new game on/over the exsisting window (which is how it was working).  Any suggestions?

    Are you running Mavericks?  Mavericks does not run on PPC Macs.  PPC pre-dates 2006.

  • Chess game, PickTranslateBehavior

    Hi everyone,
    I am trying to create a 3d chess game. I have created the board and loaded some chess pieces in. I have constructed a PickTranslateBehavior to move the chess pieces across the board, but PickTranslateBehavior moves the pieces along the x, y axes. I need it to move along the x, z axes. How would I do this? Also, is there any way to change the mouse button for this behaviour from right to left?
    Thanks for your time,
    Michael

    um, i don't know much about java, but does anyone have a working java chess game or something along those lines? i really need help. if you could even just tell me of someone else who might? i would really apprectiate it

  • Chess Game Help

    OK, I'm creating a chess game where you play against the computer. I have a good idea of how I am going to program the AI, but I need some basic stuff. Is there any code out there that has everything in it except the AI? Or at least some that draws the pieces and lets you move them around so I can work off of them? Thanks for your help.

    Thank you very much Alex. That's exactly what I
    need! I didn't think to search for AI in Google. :-P
    I'll be sure to take a look at that tutorial!Geez, I don't know why that wasn't obvious? After all I would typically search for AI when asked for:
    [url #" style="font-size: 18; color:navy;]Is there any code out there that has everything in it except the AI?
    Yeah, that makes sense!

Maybe you are looking for

  • How do I change the way audiobooks display.

    When I use audiobooks (iTunes 11) now, and there are tracks to the books, they play out of order (1a, 2a, 3a, 1b, 2b, 3b, etc). There is not an obvious way to change the view of audiobooks to fix it or an obvious fix at all. Thanks for your help

  • How to send bulk mail in oracle apps 11i with pdf/Xls attachment

    hi, how to send bulk emails in one go ( aprrox 150-200 emails in one go) with attachment pdf file in oracle apps 11i thanks

  • Incoming Payment - Deposit function

    Hi All, My customer have a scenario whereby when received cheques from customer, it will bank into their account only after few days but however, other departments that is in charge of chasing payment, wanted customer balance to be clear so that they

  • People can't see my contact requests

    The last 2 people I have tried sending contact requests to have not received them, and then whent hey search for me they can't find me.  Is this a problem in my settings?  I checked but couldn't find anything.

  • DV Pal Movies displaying at 720 instead of 768

    HI I have a quicktime movie, square pixels, 768x576 When I open it in Quicktime player (I have Tiger) it says 768x576 in the info panel However, when viewing on my friends computer (Leopard) it displays as 720x576 Any clue as to why this is? is there