Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7700189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:39:04+00:00 2026-05-31T22:39:04+00:00

Ive got troubles When using the Chesspresso 0.9.2 method Position#doMove(short move), in order to

  • 0

Ive got troubles When using the Chesspresso 0.9.2 method Position#doMove(short move), in order to add moves. Illegal moves seems to be accepted as well as legal moves, though the method Game#doMove() should throw IllegalMoveException

Here is my experimentation class :

package com.gmail.bernabe.laurent.j2se.chesspresso_test;

import javax.swing.JFrame;

import chesspresso.Chess;
import chesspresso.game.Game;
import chesspresso.game.view.GameBrowser;
import chesspresso.move.IllegalMoveException;
import chesspresso.move.Move;

public class ChessFrame extends JFrame {

    public ChessFrame(){
        setTitle("Chesspresso gamebrowser test");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        add(gameBrowser);
        pack();

        addMove(Chess.E2, Chess.E4, false, "Debut pour une partie ouverte");
        addMove(Chess.E7, Chess.E5, false, "Reponse symetrique forte");
        addMove(Chess.G1, Chess.F3, false, null);
        addMove(Chess.B8, Chess.C6, false, null);
        addMove(Chess.F1, Chess.B5, false, null);
    }

    private void addMove(int fromSquareIndex, int toSquareIndex,
            boolean isCapturingMove, String comment){
        try {
            short move = Move.getRegularMove(fromSquareIndex, toSquareIndex,
                    isCapturingMove);
            if (Move.isValid(move)) {
                chessGame.getPosition().doMove(move);
                if (comment != null && comment.length() > 0)
                    chessGame.addComment(comment);
            }
        } catch (IllegalMoveException e) {
            e.printStackTrace();
        }
    }


    private Game chessGame = new Game();
    private GameBrowser gameBrowser = new GameBrowser(chessGame);
    private static final long serialVersionUID = -6856238414376776882L;

}

And here is my main class :

package com.gmail.bernabe.laurent.j2se.chesspresso_test;


public class ChesspressoGraphicalTest {

    public static void main(String[] args) {
        ChessFrame chessFrame = new ChessFrame();
        chessFrame.setVisible(true);
    }

}

As you can see, I’ve inherited from the ChessPresso GameBrowser class in my JFrame custom class, in order to navigate in the chess opening I’ve coded (Ruy Lopez). And the method addMove wraps all the Chesspresso calls in order to add move and comment just in one line.

If you launch the class ChesspressoGraphicalTest, you will see a Frame which displays the board with letters for representing the piece (that is the default Chesspresso GameBrowser implementation and behaviour) : you can read moves, go to next move, going back to old move … thanks to the buttons at bottom of board.

So, what’s the problem ? It is very simple : when giving an illegal move (

 addPawnMove(Chess.E2, Chess.F8, false, "Debut pour une partie ouverte"); 

for example in place of the first move), this one isn’t detected at all. I did not get any IllegalMoveException.

Furthermore, if I remove the test Move.isValid(move) (in the addMove() method), nothing ever change : whatever legal status of all moves are.

Is it chesspresso problem, or a simple bad use of it ?

Any help appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:39:05+00:00Added an answer on May 31, 2026 at 10:39 pm

    The Move.isValidMove(move) checks if the move itself has been created as a valid move or invalid move. It does not check if the move itself is valid during some time of the game.

    What you need to do is to use the position of the game to get the list of valid moves (don’t create the moves yourself). You can also use chessGame.getPosition().getPieceMove(…) which will return either a valid or invalid move.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all! Ive got timezone troubles. I have a time stamp of 2010-07-26 23:35:03
Ive got the following code which I hacked together from website examples. It works
Ive got a view helper in library/my/view/helper/gravatar and so in any view I can
Ive got the following html setup: <div id=div1> <div id=content1>blaat</div> <div id=content1>blaat2</div> </div> it
Ive got a url: http://dev.local/foodies/view?id=bluedaniel and ive got in my bootstrap: protected function _initRoute()
ive got an object that looks like this with print_r(): SimpleDOM Object ( [0]
I've got a WPF app who's menu is using the commanding capabilities. Everything is
I've got a university project to create a site using a framework given to
I've got 3 dataset objects that are nested with each other using entity set
Using Delphi 2010, let's say I've got a class declared like this: TMyList =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.