Bug 417 - Error in isSquareSwappableExist() in Map.java
Summary: Error in isSquareSwappableExist() in Map.java
Status: CONFIRMED
Alias: None
Product: CandyCrush 2020
Classification: Unclassified
Component: Source Code (show other bugs)
Version: 1.0
Hardware: PC Windows
: --- enhancement
Assignee: jli262-c
URL:
Depends on:
Blocks:
 
Reported: 2020-11-18 22:14 HKT by ziruichen6-c
Modified: 2020-11-29 15:04 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ziruichen6-c 2020-11-18 22:14:13 HKT
The bug was found when running the JUnit test. testSquareExist8() and testSquareExist9() return false.

Steps to Reproduce:
Run testSquareExist8() and testSquareExist9() in TestMap.java

Actual Results:testSquareExist8() and testSquareExist9() in TestMap.java failures which means the isSquareSwappableExist() could not judge below situations:
X    |                         
  X  | X   X                             
X X  |   X X


Expected Results: testSquareExist8() and testSquareExist9() in TestMap.java pass the JUnit test
Comment 1 ziruichen6-c 2020-11-18 22:20:13 HKT
The error was caused by the error of judgment condition in isSquareSwappableExist().
The solution would be to correct the judgment condition in isSquareSwappableExist() in Map.java

Previous version:
(itemArray[i+1][j+1].isSame(itemArray[i+1][j]) && itemArray[i+1][j+1].isSame(itemArray[i][j+1]) && ((i > 0 && itemArray[i][j].isSame(itemArray[i-1][j])) || (j > 0 && itemArray[i][j].isSame(itemArray[i][j-1])))

After correcting:
itemArray[i+1][j+1].isSame(itemArray[i+1][j]) && itemArray[i+1][j+1].isSame(itemArray[i][j+1]) && ((i > 0 && itemArray[i+1][j+1].isSame(itemArray[i-1][j])) || (j > 0 && itemArray[i+1][j+1].isSame(itemArray[i][j-1])))
Comment 2 ziruichen6-c 2020-11-29 11:51:37 HKT
In version2, After further research, it is found that the four conditions detected in isSquareSwappableExist() will be covered by isHorizontalSwappableExist() and isVerticalSwappableExist(), so this function is deleted.