Skip to content

Commit

Permalink
Roboyard Android Version 10.2
Browse files Browse the repository at this point in the history
- Revert "cycle through different solutions if more than one solution is found" which was introduced in commit 43f94c5.
  • Loading branch information
rubo77 committed Dec 26, 2021
1 parent 4d655d9 commit eb7b98f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ CHANGELOG

### Version 11

- Show number of different solutions found by the AI
- cycle through different solutions if more than one solution is found

### Version 10.2

- Show number of different solutions found by the AI

### Version 10.1

- remove white circles in the background of robots
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "de.z11.roboyard"
minSdkVersion 19
targetSdkVersion 30
versionCode 38
versionName "11"
versionCode 39
versionName "10.2"
}
buildTypes {
release {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/roboyard/eclabs/GridGameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class GridGameScreen extends GameScreen {
private int solutionMoves = 0; // store the optimal number of moves for the solution globally
private int NumDifferentSolutionsFound = 0; // store the number of different solution globally
private int numSolutionClicks = 0; // count how often you clicked on the solution button, each time the shown count goes down by one
private int numDifferentSolutionClicks = 0; // count how often you clicked on the solution button again to show a different solution
private int numDifferentSolutionClicks = 0; // count how often you clicked on the solution button again to show a different solution (currently disabled)
private int showSolutionAtHint = 5; // interval between the first hint and the current optimal solution (will be set to random 3..5 later

private static int goodPuzzleMinMoves = 8; // below this number of moves there is a special hint shown from the start
Expand Down Expand Up @@ -388,7 +388,7 @@ public void update(GameManager gameManager){
isSolved = true;
buttonSolve.setEnabled(true);
NumDifferentSolutionsFound=solver.getSolutionList().size();
GameSolution solution = solver.getSolution(numDifferentSolutionClicks);
GameSolution solution = solver.getSolution();
solutionMoves=0;
for(IGameMove m : solution.getMoves()){
solutionMoves++;
Expand Down Expand Up @@ -772,7 +772,7 @@ public void execute(){
private class ButtonSolution implements IExecutor{
public void execute(){
if(numSolutionClicks >= showSolutionAtHint) {
GameSolution solution = solver.getSolution(numDifferentSolutionClicks);
GameSolution solution = solver.getSolution();
showSolution(solution);
if(NumDifferentSolutionsFound > 1){
// if solution is shown and there are more than 1 solutions found:
Expand All @@ -781,7 +781,7 @@ public void execute(){
}else{
numDifferentSolutionClicks++;
}
gameManager.requestToast("Press again to see solution " + (numDifferentSolutionClicks + 1), false);
// gameManager.requestToast("Press again to see solution " + (numDifferentSolutionClicks + 1), false);
}
}else{
numSolutionClicks++;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/roboyard/eclabs/solver/ISolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public interface ISolver extends Runnable {
void init(ArrayList<GridElement> elements);
void run();
SolverStatus getSolverStatus();
GameSolution getSolution(int num);
GameSolution getSolution();
List<Solution> getSolutionList();
}
8 changes: 5 additions & 3 deletions app/src/main/java/roboyard/eclabs/solver/SolverDD.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ public class SolverDD implements ISolver{

private SolverStatus solverStatus;
private Solver solver;
private Solution solution;
private List<Solution> solutions;
private final RRPiece[] pieces;

public SolverDD(){
solver = null;
solverStatus = SolverStatus.idle;
solution = null;
solutions = null;
pieces = new RRPiece[4];
}
Expand All @@ -51,7 +53,7 @@ public void run() {
try {
solutions = solver.execute();
if(solutions.size() != 0){
Solution solution = solutions.get(0);
solution = solutions.get(0);
System.out.println(solutions.size() + " solution(s) found; first solution:");
System.out.println(solution.toString());
solverStatus = SolverStatus.solved;
Expand All @@ -76,9 +78,9 @@ public List<Solution> getSolutionList(){
* @param num number of the solution in the solutions list
* @return GameSolution with all moves in that solution
*/
public GameSolution getSolution(int num){
public GameSolution getSolution(){
GameSolution s = new GameSolution();
Solution solution = solutions.get(num);

solution.resetMoves();
Move m = solution.getNextMove();
while (m != null){
Expand Down
Binary file added download/Roboyard_v10.2.apk
Binary file not shown.

0 comments on commit eb7b98f

Please sign in to comment.