diff --git a/out/production/TamaGolem/it/arnaldo/unibs/tamagolem/WorldBuilder.class b/out/production/TamaGolem/it/arnaldo/unibs/tamagolem/WorldBuilder.class index f22256d..8f87357 100644 Binary files a/out/production/TamaGolem/it/arnaldo/unibs/tamagolem/WorldBuilder.class and b/out/production/TamaGolem/it/arnaldo/unibs/tamagolem/WorldBuilder.class differ diff --git a/src/LinearSystem.java b/src/LinearSystem.java index cddd80e..a1c6725 100644 --- a/src/LinearSystem.java +++ b/src/LinearSystem.java @@ -34,7 +34,7 @@ public class LinearSystem { while (tries-- > 0) { int[] lambdaValues = new int[indipendentVariables]; for (int i = 0; i < indipendentVariables; i++) { - lambdaValues[i] = (rand.nextInt(n) + 1); // valori tra 1 e 9 + lambdaValues[i] = (rand.nextInt(m) + 1); // valori tra 1 e 9 } solutions = constructSolution(extendedMatrix, lambdaValues, rank); @@ -45,14 +45,10 @@ public class LinearSystem { } private boolean validNumbers(int[] x) { - boolean positive = false; - boolean negative = false; for (int xi : x) { - if (xi > 0) positive = true; - else if (xi < 0) negative = true; - if (xi == 0) return false; + if (xi <= 0) return false; } - return positive && negative; + return true; } private int[] constructSolution(int[][] extendedMatrix, int[] parameters, int rank) { diff --git a/src/WorldBuilder.java b/src/WorldBuilder.java index 94f44ed..1a929d7 100644 --- a/src/WorldBuilder.java +++ b/src/WorldBuilder.java @@ -8,7 +8,7 @@ public class WorldBuilder { Random rand = new Random(); // da cambiare il numero a 8 //int numElements = 3 + rand.nextInt(8); - int numElements = 5; + int numElements = 6; List selectedElements = new ArrayList<>(Arrays.asList(allElements)); Collections.shuffle(selectedElements); selectedElements = selectedElements.subList(0, numElements); @@ -23,7 +23,7 @@ public class WorldBuilder { if (el == followingElement) { links.put(el, 1); } else if (el != element) { - links.put(el, 1); + links.put(el, 0); } } @@ -37,24 +37,24 @@ public class WorldBuilder { continue; } -// // controllo anche prima per evitare che magari da un estrazione si vada a togliere -// if (elementLinks.get(el) == 1){ -// linkDirections.get(el).put(element, -1); -// } -// -// if (elementLinks.get(el) == 0) { -// if (Math.random() < 0.5) { -// linkDirections.get(el).put(element, 1); -// } else { -// linkDirections.get(el).put(element, -1); -// } -// } -// -// if (elementLinks.get(el) == 1){ -// linkDirections.get(el).put(element, -1); -// } else { -// linkDirections.get(el).put(element, 1); -// } + // controllo anche prima per evitare che magari da un estrazione si vada a togliere + if (elementLinks.get(el) == 1){ + linkDirections.get(el).put(element, -1); + } + + if (elementLinks.get(el) == 0) { + if (Math.random() < 0.5) { + linkDirections.get(el).put(element, 1); + } else { + linkDirections.get(el).put(element, -1); + } + } + + if (elementLinks.get(el) == 1){ + linkDirections.get(el).put(element, -1); + } else { + linkDirections.get(el).put(element, 1); + } } } @@ -114,8 +114,8 @@ public class WorldBuilder { if (el == element) { continue; } - //int direction = linkDirections.get(element).get(el); - graphElement.addLink(new ElementLink(solution[getIndex(element, el, pairIndex)], el)); + int direction = linkDirections.get(element).get(el); + graphElement.addLink(new ElementLink(solution[getIndex(element, el, pairIndex)] * direction, el)); } world.addElement(graphElement); }