Skip to content

Commit 5d7f056

Browse files
Update rules generation
1 parent 7d28eb3 commit 5d7f056

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

public/app.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,14 @@ async function fetchPreset(id) {
408408

409409
function buildGeneratedRuleConfig() {
410410
const config = window.AutomaginariumCore.normaliserConfiguration(controlsToConfig());
411-
const generator = controls.ruleGenerator.value;
411+
let generator = controls.ruleGenerator.value;
412+
413+
// Wolfram only works with neighborhood 3 and 1 output channel
414+
if (generator === "wolfram" && (config.taille_voisinage !== 3 || config.nombre_canaux_sortie !== 1)) {
415+
generator = "random";
416+
controls.ruleGenerator.value = "random";
417+
}
418+
412419
if (generator === "wolfram") {
413420
config.alphabet_entree = [0, 1];
414421
config.alphabet_sortie = [0, 1];

public/index.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ <h1 id="app-title">Automaginarium</h1>
8080
<h3>Univers</h3>
8181
<div class="field-grid compact-fields">
8282
<label>Alphabet<input id="alphabet-input-quick" type="text" placeholder="0,1,2" /></label>
83-
<label>Voisinage<input id="neighborhood-size-quick" type="number" min="1" max="9" step="1" /></label>
83+
<label>Voisinage<input id="neighborhood-size-quick" type="number" min="1" max="9" step="2" /></label>
84+
<label>Canaux sortie<input id="channel-count-quick" type="number" min="1" max="4" step="1" value="1" /></label>
8485
<label>Largeur<input id="grid-width-quick" type="number" min="21" max="401" step="2" value="805" /></label>
8586
<label>Hauteur<input id="grid-height-quick" type="number" min="20" max="240" step="5" value="500" /></label>
8687
</div>
@@ -261,7 +262,7 @@ <h2>Univers</h2>
261262
<label>Nom<input id="config-name" type="text" /></label>
262263
<label>Alphabet entr&eacute;e<input id="alphabet-input" type="text" placeholder="0,1,2 ou air,feu,eau" /></label>
263264
<label>Alphabet sortie<input id="alphabet-output" type="text" placeholder="0,1" /></label>
264-
<label>Voisinage<input id="neighborhood-size" type="number" min="1" max="9" step="1" /></label>
265+
<label>Voisinage<input id="neighborhood-size" type="number" min="1" max="9" step="2" /></label>
265266
<label>Canaux sortie<input id="channel-count" type="number" min="1" max="4" step="1" /></label>
266267
<label>Largeur<input id="grid-width" type="number" min="21" max="401" step="2" /></label>
267268
<label>Hauteur<input id="grid-height" type="number" min="20" max="240" step="5" /></label>
@@ -756,6 +757,7 @@ <h2>Configuration brute</h2>
756757
const syncPairs = [
757758
{ quick: 'alphabet-input-quick', main: 'alphabet-input' },
758759
{ quick: 'neighborhood-size-quick', main: 'neighborhood-size' },
760+
{ quick: 'channel-count-quick', main: 'channel-count' },
759761
{ quick: 'grid-width-quick', main: 'grid-width' },
760762
{ quick: 'grid-height-quick', main: 'grid-height' },
761763
{ quick: 'rule-mode-quick', main: 'rule-mode' },
@@ -772,9 +774,11 @@ <h2>Configuration brute</h2>
772774
mainEl.dispatchEvent(new Event('input', { bubbles: true }));
773775
mainEl.dispatchEvent(new Event('change', { bubbles: true }));
774776

777+
const generateBtnMain = document.getElementById('generate-rule');
778+
const ruleGen = document.getElementById('rule-generator');
779+
775780
// When neighborhood changes, regenerate the rule table to match new structure
776781
if (pair.quick === 'neighborhood-size-quick' && oldValue !== quickEl.value) {
777-
const ruleGen = document.getElementById('rule-generator');
778782
const newNeighborhood = Number(quickEl.value);
779783

780784
// If using Wolfram but neighborhood is not 3, switch to random generator
@@ -783,7 +787,13 @@ <h2>Configuration brute</h2>
783787
}
784788

785789
// Regenerate rules for the new neighborhood
786-
const generateBtnMain = document.getElementById('generate-rule');
790+
if (generateBtnMain) {
791+
setTimeout(() => generateBtnMain.click(), 100);
792+
}
793+
}
794+
795+
// When channel-count changes, regenerate the rule table to match new output structure
796+
if (pair.quick === 'channel-count-quick' && oldValue !== quickEl.value) {
787797
if (generateBtnMain) {
788798
setTimeout(() => generateBtnMain.click(), 100);
789799
}

0 commit comments

Comments
 (0)