Bug 439 - The Evaluation function returns an error valuation
Summary: The Evaluation function returns an error valuation
Status: CONFIRMED
Alias: None
Product: CS3343 2020 Group 9_Chinese Chess
Classification: Unclassified
Component: Algorithm (show other bugs)
Version: V2.0
Hardware: All Windows
: --- normal
Deadline: 2020-11-22
Assignee: yinuowang3-c
URL:
Depends on:
Blocks:
 
Reported: 2020-11-22 22:17 HKT by yinuowang3-c
Modified: 2020-12-06 21:34 HKT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yinuowang3-c 2020-11-22 22:17:29 HKT
In the evaluate function in CEvaluation Class, the parameters x and y are reversed when determining whether a piece can move to a certain position.
Comment 1 yinuowang3-c 2020-11-29 16:28:50 HKT
WANG Yinuo 2020-11-22 COMMENT

Steps To Reproduce:
1. In testing, move chess pieces on the chessboard until there are only Kings, Guards, and bishops left.
2. Call the Evaluate function, passing in the current board.

Expected Result: The game is not over, so it should return a non-zero valuation, but it actually returns a zero.

WANG Yinuo 2020-11-22 EDT

Have checked out the private function "GetRelatedPieces()" called in the Evaluate function.
GetRelatedPieces() calls the "isValidMove()" function in the Switch loop that determines whether a chess piece can move to a certain position, but erroneously passes the order of x and y that represents the position of the target of the chess piece during argument passing.
As a result, isValidMove() returns a false value, resulting in a final result of zero.
Comment 2 yinuowang3-c 2020-12-06 19:58:55 HKT
(In reply to yinuowang3-c from comment #1)
> WANG Yinuo 2020-11-22 COMMENT
> 
> Steps To Reproduce:
> 1. In testing, move chess pieces on the chessboard until there are only
> Kings, Guards, and bishops left.
> 2. Call the Evaluate function, passing in the current board.
> 
> Expected Result: The game is not over, so it should return a non-zero
> valuation, but it actually returns a zero.
> 
> WANG Yinuo 2020-11-22 EDT
> 
> Have checked out the private function "GetRelatedPieces()" called in the
> Evaluate function.
> GetRelatedPieces() calls the "isValidMove()" function in the Switch loop
> that determines whether a chess piece can move to a certain position, but
> erroneously passes the order of x and y that represents the position of the
> target of the chess piece during argument passing.
> As a result, isValidMove() returns a false value, resulting in a final
> result of zero.

Solution:
Swap the parameters x and y in isValidMove() function in GetRelatedPieces() of CEvaluation Class.