seed display

seeds are displayed in pause menu and intro map
seeds from your previous run is displayed in settings after you die
fixed some minor seed inconsistency
This commit is contained in:
landgreen
2022-02-06 21:07:52 -08:00
parent 775f45b863
commit d51a9d6dd8
8 changed files with 45 additions and 27 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -94,6 +94,7 @@
<label for="seed">randomization seed:</label> <label for="seed">randomization seed:</label>
<input type="text" id="seed" name="seed" autocomplete="off" spellcheck="false" minlength="1" size="20" style="width: 120px;"> <input type="text" id="seed" name="seed" autocomplete="off" spellcheck="false" minlength="1" size="20" style="width: 120px;">
<br> <br>
<span id="previous-seed" style="color:#bbb"></span>
<label for="difficulty-select" title="effects: number of mobs, damage done by mobs, damage done to mobs, mob speed, heal effects">combat difficulty:</label> <label for="difficulty-select" title="effects: number of mobs, damage done by mobs, damage done to mobs, mob speed, heal effects">combat difficulty:</label>
<select name="difficulty-select" id="difficulty-select" style="background-color: #fff"> <select name="difficulty-select" id="difficulty-select" style="background-color: #fff">

View File

@@ -6,12 +6,17 @@ Math.hash = s => { for (var i = 0, h = 9; i < s.length;) h = Math.imul(h ^ s.cha
// const date1 = new Date() // const date1 = new Date()
// Math.seed = date1.getUTCDate() * date1.getUTCFullYear(); // daily seed, day + year // Math.seed = date1.getUTCDate() * date1.getUTCFullYear(); // daily seed, day + year
// Math.seed = Date.now() //random every time: just the time in seconds UTC // Math.seed = Date.now() //random every time: just the time in seconds UTC
Math.seed = Math.floor(Date.now() % 100000000) //random every time: just the time in seconds UTC // Math.seed = Math.abs(Math.hash(String(Date.now()))) //update randomizer seed in case the player changed it
// document.getElementById("seed").placeholder = Math.seed = Math.initialSeed = Math.floor(Date.now() % 100000) //random every time: just the time in milliseconds UTC
document.getElementById("seed").placeholder = Math.initialSeed = String(Math.floor(Date.now() % 100000))
Math.seed = Math.abs(Math.hash(Math.initialSeed)) //update randomizer seed in case the player changed it
Math.seededRandom = function(min = 0, max = 1) { // in order to work 'Math.seed' must NOT be undefined Math.seededRandom = function(min = 0, max = 1) { // in order to work 'Math.seed' must NOT be undefined
Math.seed = (Math.seed * 9301 + 49297) % 233280; Math.seed = (Math.seed * 9301 + 49297) % 233280;
return min + Math.seed / 233280 * (max - min); return min + Math.seed / 233280 * (max - min);
} }
document.getElementById("seed").placeholder = Math.seed //display seed in settings
//Math.seed is set to document.getElementById("seed").value in level.populate level at the start of runs //Math.seed is set to document.getElementById("seed").value in level.populate level at the start of runs
// console.log(Math.seed) // console.log(Math.seed)
@@ -269,6 +274,7 @@ ${botText}
<br>position: (${player.position.x.toFixed(1)}, ${player.position.y.toFixed(1)}) &nbsp; velocity: (${player.velocity.x.toFixed(1)}, ${player.velocity.y.toFixed(1)}) <br>position: (${player.position.x.toFixed(1)}, ${player.position.y.toFixed(1)}) &nbsp; velocity: (${player.velocity.x.toFixed(1)}, ${player.velocity.y.toFixed(1)})
<br>mouse: (${simulation.mouseInGame.x.toFixed(1)}, ${simulation.mouseInGame.y.toFixed(1)}) &nbsp; mass: ${player.mass.toFixed(1)} <br>mouse: (${simulation.mouseInGame.x.toFixed(1)}, ${simulation.mouseInGame.y.toFixed(1)}) &nbsp; mass: ${player.mass.toFixed(1)}
<br> <br>
<br>seed: ${Math.initialSeed}
<br>level: ${level.levels[level.onLevel]} (${level.difficultyText()}) &nbsp; ${m.cycle} cycles <br>level: ${level.levels[level.onLevel]} (${level.difficultyText()}) &nbsp; ${m.cycle} cycles
<br>${mob.length} mobs, &nbsp; ${body.length} blocks, &nbsp; ${bullet.length} bullets, &nbsp; ${powerUp.length} power ups <br>${mob.length} mobs, &nbsp; ${body.length} blocks, &nbsp; ${bullet.length} bullets, &nbsp; ${powerUp.length} power ups

View File

@@ -221,7 +221,10 @@ const level = {
} }
}, },
populateLevels() { populateLevels() {
if (document.getElementById("seed").value) Math.seed = Math.hash(document.getElementById("seed").value) //update randomizer seed in case the player changed it if (document.getElementById("seed").value) {
Math.initialSeed = String(document.getElementById("seed").value)
Math.seed = Math.abs(Math.hash(Math.initialSeed)) //update randomizer seed in case the player changed it
}
if (simulation.isTraining) { if (simulation.isTraining) {
level.levels = level.trainingLevels.slice(0) //copy array, not by just by assignment level.levels = level.trainingLevels.slice(0) //copy array, not by just by assignment

View File

@@ -1044,7 +1044,7 @@ const powerUps = {
}, },
pauseEjectTech(index) { pauseEjectTech(index) {
if (tech.isPauseEjectTech || simulation.testing) { if (tech.isPauseEjectTech || simulation.testing) {
if (Math.random() < 0.03) { if (Math.random() < 0.04) {
tech.removeTech(index) tech.removeTech(index)
m.energy += 20.48; m.energy += 20.48;
} else { } else {

View File

@@ -521,6 +521,14 @@ const simulation = {
}, },
firstRun: true, firstRun: true,
splashReturn() { splashReturn() {
document.getElementById("previous-seed").innerHTML = `previous seed: <span style="font-size:80%;">${Math.initialSeed}</span><br>`
document.getElementById("seed").value = Math.initialSeed = Math.seed //randomize initial seed
//String(document.getElementById("seed").value)
// Math.seed = Math.abs(Math.hash(Math.initialSeed)) //update randomizer seed in case the player changed it
simulation.clearTimeouts(); simulation.clearTimeouts();
simulation.onTitlePage = true; simulation.onTitlePage = true;
document.getElementById("splash").onclick = function() { document.getElementById("splash").onclick = function() {
@@ -695,6 +703,7 @@ const simulation = {
// simulation.makeTextLog(`input.key.left<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.left}</span>", "<span class='color-text'>ArrowLeft</span>"]`); // simulation.makeTextLog(`input.key.left<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.left}</span>", "<span class='color-text'>ArrowLeft</span>"]`);
// simulation.makeTextLog(`input.key.down<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.down}</span>", "<span class='color-text'>ArrowDown</span>"]`); // simulation.makeTextLog(`input.key.down<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.down}</span>", "<span class='color-text'>ArrowDown</span>"]`);
// simulation.makeTextLog(`input.key.right<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.right}</span>", "<span class='color-text'>ArrowRight</span>"]`); // simulation.makeTextLog(`input.key.right<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.right}</span>", "<span class='color-text'>ArrowRight</span>"]`);
simulation.makeTextLog(`Math.seed <span class='color-symbol'>=</span> ${Math.initialSeed}`);
simulation.makeTextLog(`<span class='color-var'>const</span> engine <span class='color-symbol'>=</span> Engine.create(); <em>//simulation begin</em>`); simulation.makeTextLog(`<span class='color-var'>const</span> engine <span class='color-symbol'>=</span> Engine.create(); <em>//simulation begin</em>`);
simulation.makeTextLog(`engine.timing.timeScale <span class='color-symbol'>=</span> 1`); simulation.makeTextLog(`engine.timing.timeScale <span class='color-symbol'>=</span> 1`);
// simulation.makeTextLog(`input.key.field<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.field}</span>", "<span class='color-text'>MouseRight</span>"]`); // simulation.makeTextLog(`input.key.field<span class='color-symbol'>:</span> ["<span class='color-text'>${input.key.field}</span>", "<span class='color-text'>MouseRight</span>"]`);

View File

@@ -3067,15 +3067,13 @@ const tech = {
}, },
{ {
name: "particle collider", name: "particle collider",
description: `<strong>clicking</strong> <strong class='color-m'>tech</strong> while <strong>paused</strong> <strong>ejects</strong> them<br><em><strong>3%</strong> chance to convert that tech into <strong class='color-f'>energy</strong></em>`, description: `<strong>clicking</strong> <strong class='color-m'>tech</strong> while <strong>paused</strong> <strong>ejects</strong> them<br><em><strong>4%</strong> chance to convert that tech into <strong class='color-f'>energy</strong></em>`,
maxCount: 1, maxCount: 1,
count: 0, count: 0,
frequency: 1, frequency: 1,
frequencyDefault: 1, frequencyDefault: 1,
allowed() { allowed() { return true },
return tech.isPauseSwitchField requires: "",
},
requires: "unified field theory",
effect() { effect() {
tech.isPauseEjectTech = true; tech.isPauseEjectTech = true;
}, },

View File

@@ -1,32 +1,33 @@
******************************************************** NEXT PATCH ************************************************** ******************************************************** NEXT PATCH **************************************************
all runs are now seeded seeds are displayed in pause menu and intro map
seed defaults to the last 8 digits of UTC time in milliseconds seeds from your previous run is displayed in settings after you die
set a custom randomization seed in settings fixed some minor seed inconsistency
seed controls:
at start - boss list, mob type list, level list, horizontal flip
during run - tech, gun, field choices, some custom level randomization
doesn't control: mob spawns, mob size, some minor level differences, specific level boss choices, ammo reward values, specific tech effects
bug fix with ground state
******************************************************** TODO ******************************************************** ******************************************************** TODO ********************************************************
make railgun default fire mode for crouch harpoon?
buff perfect diamagnetism
make a seed/hash system that controls only the tech/guns/fields shown make a seed/hash system that controls only the tech/guns/fields shown
URL sharing could include a seed
seed will control: seed will control:
seeded random at start done - random level boss, mob types list, level order, horizontal flip seeded random at start - random level boss, mob types list, level order, horizontal flip
seeded random during run - tech, gun, field choices seeded random during run - tech, gun, field choices
not seeded random - mob spawns, mob size, minor level differences, custom level boss choices, ammo rewards, tech effect randomness not seeded random - mob spawns, mob size, minor level differences, custom level boss choices, ammo rewards, tech effect randomness
better to only seed things at the start of the run so it doesn't mess with power up choices better to only seed things at the start of the run so it doesn't mess with power up choices
put a seed display in top right corner of splash menu, or settings? make option for a daily seed: seed = day+year
normal seed = full UTC time give 1 extra tech for doing the daily seeded run
make option for a daily seed: seed = day+year make the option for the daily run, a secret exit in the intro level?
give 1 extra tech for doing the daily seeded run when you die
make the option for the daily run, a secret exit in the intro level? randomize seed
figure out how to convert text into seed display new seed
display seed in pause menu show previous run seed
edit div in settings
tech upgrade to anthropic to make it trigger at 50% life and 0% tech upgrade to anthropic principle to make it trigger at 50% life and 0% once per map
JUNK tech: https://bindingofisaacrebirth.fandom.com/wiki/Damocles JUNK tech: https://bindingofisaacrebirth.fandom.com/wiki/Damocles