Jump to content

View New Content
Forums
Photo

Energy Balance - How to Download and Use Solver


  • Please log in to reply
2 replies to this topic

#1 Walter-kun

Walter-kun

    Silver Poster

  • Premium Trader
  • 1385 posts
  • LocationUnited States
  • PSN ID:Wdog-999
  • Feedback Score:16

User's Awards

                       

Posted 23 September 2017 - 07:26 AM

The purpose of this guide is to help out anyone who is confused on exactly how to get the solver for Energy Balance referenced in my guide as well as anyone who has managed to get it downloaded only for their heads to explode upon witnessing it.

 

Credit to bwoodhouse729 for creating the solver.
 
Downloading
 
Step 1: Get JGrasp: Before you download the solver, you'll need programming software to run it on as you will have to edit the code directly to use the solver. For the purposes of running the solver, I recommend using JGrasp as while it is not the best for overall programming, it is simple to use insofar as setting up the solver compared to other programs such as BlueJ. To download JGrasp, just go here to the official site and select the appropriate file for your computer. Note that this walkthrough will assume that you are using Windows as this is the only OS that the guide writer has.
 
Step 2: Get the Java Development Kit: In order to actually get anything running, you will also need JDK, which can thankfully be downloaded here free of charge and needs no additonal setup.
 
Step 3: Get the Solver: Now that you have something you can run the solver on, it is now time to actually get the solver. Simply go to here and download the solver. The easiest way to do this is to download the zip file and just unpack it. There should be two files in the folder, CombinationGenerator.java and Energy_Balance.java. Make sure to keep these in the same folder as Energy_Balance.java will need to interact with CombinationGenerator.java to work properly.
 
Step 4: Open Up the Solver: Now that you have JGrasp and the solver, you should just have to open up Energy_Balance.java. To do so, go into JGrasp and select File > Open. From here, navigate to the folder where you have the two classes and open up Energy_Balance.java. Also, you should click on the green plus sign on the top toolbar to compile the program, which will make sure that everything is connected properly.
 
Using
 
What Even Is This?: When you open up the program, you will notice a fair amount of colored text at the top of the program. None of this actually does anything other than explaining the program, so just scroll until you see the following three lines:
 
public static int[] original_values = {3, 1, 3, 7, 9};
 
public static int[][] addends = {{0, 1, 2}, {0, 3, 4}};
 
public static int[] sums = {11, 15};
 
The values past the equals sign on each line are what you'll be editing and are the only part of the program that you should ever touch unless you know what you're doing and want to try to make modifications to it.
 
original_values is an array consisting of the values of every numbered tile on the current board. Generally, the order of this is not terribly important since the program will be shuffling this countless times to find the solution anyway, but if you want to do it as intended or if you want to try to input a partially-solved puzzle to make it go quicker, you should input the values from left to right as if you were typing them off a line.
 
addends is a two-dimensional array that stores the rows and columns that have required sums as arrays. The general position of each slot in the row/column is determined not by it's actual position, but by how many times one would have to move one existing slot to the right to reach the slot.
 
For example, the example puzzle given in the comments at the top has a corner-shaped puzzle with one row and one column that are connected to one another by the top-left corner slot. The first slot in the puzzle is defined as 0, and the next two slots are defined as 1 and 2, respectively. Once it drops down a row, rather than resetting to 0, the count just keeps going, so the slots in the second and third rows are defined as 3 and 4, respectively.
 
Assuming you are using my trophy guide, I have already listed out all of the addends arrays for convenience as these are the only constant in puzzles, which is great because they can get incredibly tedious to input, especially when trying to intersect as much as possible between consecutive rows and columns and prioritize smaller rows/columns for maximum efficiency.
 
sums is an array consisting of the sums that each row and column of the puzzle must add up to. In order for this to work properly, each sum in this array must be in the same location as it's corresponding row/column array is in the addends array. Assuming you are using my guide, I have provided pictures that clearly mark what order you should be inputting the sums in to match the addends arrays I have provided.
 
When you have all of the inputs in, click on the little red running man on the toolbar to run the program.
 
Once you run the program, it will loop until it finds a solution. The program will write a new line every time it loops once and it should go at tens of thousands of iterations per second, so the command prompt at the bottom of the screen will be crowded. Thankfully, JGrasp will autoscroll to the bottom upon each new line, so you have nothing to worry about.
 
Once it has finally reached a solution, the game will print out the tiles in order of how they would be placed assuming that you place them left to right along each row. For example, for our example problem with the corner pieces, you could get an output as such:

 

Position 0: 3

Position 1: 1

Position 2: 7

Position 3: 3

Position 4: 9

 

The solution would thus be entered as:

 

3 1 7

3

9

 

Notice how the first position is considered Position 0, not Position 1. This is because in programming, counting starts at 0 rather than 1, so the first value in a list is represented by 0, the second by 1, the third by 2, and so on.

 

All of this is explained within the comments above the program itself, but I have explained it here as well in case you didn't quite understand it well enough.

 

The only other thing worth noting is that if you see a 1000 for one of the position values, this means that the position isn't being used for anything. Normally, this should only appear for those slots that are connected to neither a row nor a column, but if it shows up in a slot that is connected to something, that means that the value for addends was not created properly. For example, if a puzzle that had a 3X3 plus sign shape was given an addends value of {{0, 2, 4}, {1, 2}}, this would produce a 1000 for Position 3 as the program would recognize that it has to exist because it should have a corresponding initial value in original_values, but the program does not believe that it is connected to anything since it is in none of the arrays in addends. To fix this, you would change the second array in addends from {1, 2} to {1, 2, 3} to get the value you missed.

 

If you run into this problem and you used my addends value from the trophy guide, then please report it to me so that I can fix it ASAP.


SB59Vwy.png
Thanks to Haptism for the sig! :D
8UqfIEu.gif

Spoiler

#2 Walter-kun

Walter-kun

    Silver Poster

  • Premium Trader
  • 1385 posts
  • LocationUnited States
  • PSN ID:Wdog-999
  • Feedback Score:16

User's Awards

                       

Posted 23 September 2017 - 07:27 AM

Making this its own thread since I figure that'll be better than trying to explain this in a roadmap. :P


SB59Vwy.png
Thanks to Haptism for the sig! :D
8UqfIEu.gif

Spoiler

#3 Roughdawg4

Roughdawg4

    Platinum Poster

  • Site Owner
  • 29223 posts
  • LocationUnited States
  • PSN ID:Roughdawg4
  • Feedback Score:615

User's Awards

                                   

Posted 30 July 2018 - 07:07 AM

https://www.playstat...er-program.html


Someone made an easier solver, this should make the plat very easy to do




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users