Summary: The bug is found when I try to undo a minister movement. The program prompted that the move of minister is judged invalid. But I'm confident to say that it's a valid move of minister according to rules of Chinese Chess. Steps to Reproduce: 1. Run the program 2. Input command "new game" 3. Input command "2 0 4 2" Actual Results: The program prompt "The move you want to make is invalid!" Expected Results: This move is judged valid and successfully performed. No error message will be shown.
Created attachment 42 [details] Source code of the Minister Class. For HAN Guo's reference. Bug may exist in getPossibleMove() function.
(In reply to Marco from comment #1) > Created attachment 42 [details] > Source code of the Minister Class. > > For HAN Guo's reference. > Bug may exist in getPossibleMove() function. Bugs are found in getPossibleMove() function. Since the boundary of the loop is set wrongly. The code has changed as below int[] possibleX = {curx-2, curx+2}; int[] possibleY = {cury-2, cury+2}; for(int x1: possibleX){ for(int y1: possibleY){ if(checkLegal(x1, y1)) res.add(new ChessPosition(x1, y1)); } } return res; problem solved