Sorting Algorithm | Sorts the random array of bars under the factory, once sorted a truck will appear and transport the products to the flag |
Shortest Path | Used by trucks to find the flag |
Maximum Flow | Calculates the flow of resources in the pipes |
Sorted List | Highscores |
Linked List | Map preview |
Map | Dictionary to change the language in the menu |
Graph | Used by Maximum Flow and Shortest Path |
Breath First Search | Used by Maximum Flow algorithm |
java -Djava.library.path=./resources_lib/native/linux -jar resources.jar
I like this one, although I don't quite understand how to play it :P
This might be useful to kids to learn algorithms, but for programming students...? they would have to be pretty darn stupid to use games to understand algorithms lol.
I like this one, although I don't quite understand how to play it :P
This might be useful to kids to learn algorithms, but for programming students...? they would have to be pretty darn stupid to use games to understand algorithms lol.
Also noticed a... glitch? that "Resume Game" is greyed out, but when you press "New game", "resume game" lights up.
package logic.sorting;
import java.util.Comparator;
/**
* A sorter for arrays of type T[].
*
* @author Deque
*
* @param <T> the type of the elements that are sorted
*/
public interface Sorter<T> {
/**
* Sorts the array in ascending order using the comparator to compare array
* elements and the swapper to change the position of array elements.
*
* (Doing so in another way won't work. Not the resulting array is used, but
* the steps you take. Steps won't be recognized if you don't use swapper
* and comparator.)
*
* @param array
* @param comparator
* @param swapper
*/
public void sort(T[] array, Comparator<T> comparator, Swapper<T> swapper);
}
package logic.sorting;
import java.util.Comparator;
/**
*
* @author Deque
*
* @param <T>
*/
public class BubbleSort<T> implements Sorter<T> {
@Override
public void sort(T[] array, Comparator<T> comparator, Swapper<T> swapper) {
boolean swapped;
do {
swapped = false;
for (int i = 1; i < array.length; i++) {
if (comparator.compare(array[i - 1], array[i]) > 0) {
array = swapper.swap(array, i - 1, i);
swapped = true;
}
}
} while (swapped);
}
}