Comments and new elements

This commit is contained in:
L3o15 2025-05-12 19:28:22 +02:00
parent 3f77488b69
commit e4d54619f6
4 changed files with 24 additions and 13 deletions

View file

@ -1,14 +1,14 @@
package it.arnaldo.unibs.tamagolem;
public enum Element { // da fare diventare meme
FUOCO,
ACQUA,
ELETTRICO,
VENTO,
TERRA,
LUCE,
OMBRA,
PSICHICO,
FOLLETTO,
DRAGO
public enum Element {
ZANG_TUNG_TUNG,
TORE,
MERICIO,
TAGLIOSPACE,
ZAZZ,
BOLOGNINO,
PROXMOX,
FILO,
ECKER,
BACCO
}

View file

@ -8,13 +8,18 @@ public class WorldBuilder {
Random rand = new Random();
// da cambiare il numero a 8
//int numElements = 3 + rand.nextInt(8);
int numElements = 6;
// numero di elementi estratti a caso
int numElements = 5;
List<Element> selectedElements = new ArrayList<>(Arrays.asList(allElements));
// elementi scelti
Collections.shuffle(selectedElements);
selectedElements = selectedElements.subList(0, numElements);
ElementGraph world = new ElementGraph();
// mappa che contiene una mappa in modo che dato un elemento ti da una mappa con chiave un secondo elemento il cui valore è 1 se l'elemento infligge o -1 se l'elemento subisce
HashMap<Element, HashMap<Element, Integer>> linkDirections = new HashMap<>();
for (Element element : selectedElements) {
HashMap<Element, Integer> links = new HashMap<>();
@ -61,6 +66,7 @@ public class WorldBuilder {
System.out.println(linkDirections);
// hashmap che dato una coppia di element (è un set cosi AB = BA) ti torna la posizione all0interno dell'array di valori passato al sistema lineare
HashMap<Set<Element>, Integer> pairIndex = new HashMap<>();
int index = 0;
@ -74,9 +80,13 @@ public class WorldBuilder {
System.out.println(pairIndex);
// matrice incognite
int[][] A = new int[numElements][numElements * (numElements - 1) / 2];
// matrice termini noti
int[] b = new int[numElements];
// popolo le 2 matrici
int i = 0;
for (Element element : selectedElements) {
int[] line = new int[numElements * (numElements - 1) / 2];
@ -96,6 +106,7 @@ public class WorldBuilder {
}
// creo e risolvo il sistema lineare associato
LinearSystem system = new LinearSystem(numElements, A, b);
@ -107,7 +118,7 @@ public class WorldBuilder {
System.out.println();
// popola il grafo in base ai risultati del sistema lineare
for (Element element : selectedElements) {
GraphElement graphElement = new GraphElement(element);
for (Element el : selectedElements) {