Skip to content

Commit

Permalink
update hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
stutxo committed Apr 5, 2024
1 parent 8a31618 commit d6769a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h1 style="text-align: center; color: #333;">blockwars.gg</h1>
<script>
//This is a base64 encoded WebAssembly binary, it is 33% bigger than the original .wasm binary, im just testing it out.
// Base64WasmStart
const base64Wasm = 'AGFzbQEAAAABBAFgAAADAgEABQMBABQGOQd/AUGAgMAAC38AQcGBwAALfwBBwIHAAAt/AEHI8c8AC38AQcSBwAALfwBByPnPAAt/AEHQ+c8ACwdPCAZtZW1vcnkCAAlibG9ja3dhcnMAAAVSRVNFVAMBBUlOUFVUAwIEU0VFRAMDBERSQVcDBApfX2RhdGFfZW5kAwULX19oZWFwX2Jhc2UDBgqiDAGfDAINfwp9IwBBgAhrIgokAAJAQcGBwAAtAABBAUYEQEHAgcAAQQA6AABBwYHAAEEAOgAAQQAgCiIBa0EDcSICIAFqIQcgAgRAIAEhBUHI8c8AIQgDQCAFIAgtAAA6AAAgCEEBaiEIIAVBAWoiBSAHSQ0ACwsgB0GACCACayILQXxxIglqIQUCQCACQcjxzwBqIgJBA3EEQCAJQQBMDQEgAkEDdCIEQRhxIQwgAkF8cSIIQQRqIQNBACAEa0EYcSEEIAgoAgAhCANAIAcgCCAMdiADKAIAIgggBHRyNgIAIANBBGohAyAHQQRqIgcgBUkNAAsMAQsgCUEATA0AIAIhAwNAIAcgAygCADYCACADQQRqIQMgB0EEaiIHIAVJDQALCyACIAlqIQMgC0EDcSICBEAgAiAFaiECA0AgBSADLQAAOgAAIANBAWohAyAFQQFqIgUgAkkNAAsLA0AgACABaigCACAGcyEGIABBBGoiAEGACEcNAAtBACEAIAZBDXQgBnMiAUERdiABcyIBQQV0IAFzIgJBCnBBAmoiBiEEIAIhAQNAIARFBEAgAkEEd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RBgIBAayIAKAIABEAgAEGAgICABDYCDCAAQQE2AgALQcCBwABBADoAAAtBBCEFQQEhAQNAIAFBAXFFDQEgBbMhD0EAIQIDQCACIgBBwAFHBEAgAEEQaiECIABBgIBAaygCAEUNASAAQYyAwABqKgIAIA9cDQEgAEGIgMAAaioCACENIABBhIDAAGoqAgAhDkEAIQQDQCAEQf8BcSIAQQlLDQIgDSAAs5IiDEMAAAAAYCEAQQAhAUF/An8gDEMAAIBPXSAMQwAAAABgcQRAIAypDAELQQALQQAgABsgDEP//39PXhtB/wFsIQMDQCABQf8BcSIAQQlNBEAgDiAAs5IiDEMAAAAAYCEAIAFBAWohAUF/An8gDEMAAIBPXSAMQwAAAABgcQRAIAypDAELQQALQQAgABsgDEP//39PXhsgA2oiAEGA/ANLDQEgAEECdEHEgcAAaiAFNgIADAELCyAEQQFqIQQMAAsACwsgBUEARyEBIAVBAWsiAEEAIAAgBU0bIQUMAAsACyAIQYAIaiQACw==';
// Base64WasmEnd
const canvas = document.getElementById('canvas');

Expand All @@ -128,10 +128,8 @@ <h1 style="text-align: center; color: #333;">blockwars.gg</h1>
};
const blockHeightInput = document.getElementById('block-input');


let blockHeight = 0;
let lastWorkingBlockHeight = 0;

let seedData = [];

async function loadWasm() {
Expand Down Expand Up @@ -232,6 +230,7 @@ <h1 style="text-align: center; color: #333;">blockwars.gg</h1>
if (blockHeight < 0) {
blockHeight = 0;
}

blockHeightInput.value = blockHeight;


Expand Down Expand Up @@ -338,6 +337,7 @@ <h1 style="text-align: center; color: #333;">blockwars.gg</h1>
for (var i = 0; i < hexString.length; i += 2) {
byteArray.push(parseInt(hexString.slice(i, i + 2), 16));
}
console.log(byteArray);
return byteArray;
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ const GRID_HEIGHT: usize = (HEIGHT as usize) / TELEPORT_SIZE as usize;
#[inline]
fn rng(seed: [u32; 256]) -> impl Iterator<Item = u32> {
let seed_slice = &seed[..];
let mut random = seed_slice.iter().fold(0, |acc, &x| acc ^ x);
let mut random = seed_init(&seed_slice);
repeat_with(move || {
random ^= random << 13;
random ^= random >> 17;
random ^= random << 5;
random
})
}
fn seed_init(seed: &[u32]) -> u32 {
seed.iter().enumerate().fold(0u32, |acc, (i, &x)| {
acc.wrapping_add(x.rotate_left(i as u32 % 32)) ^ 0x9E3779B9
})
}

#[no_mangle]
static mut INPUT: [u8; 1] = [0; 1];

Expand Down Expand Up @@ -76,12 +82,7 @@ fn spawn_tele(
let max_index_x = GRID_WIDTH - 1;
let max_index_y = GRID_HEIGHT - 1;

let num_teleporters = match rng.next() {
Some(random_value) => {
((random_value % (MAX_TELEPORT as u32 - 2)) as usize + 2).min(teleporters.len())
}
None => 2,
};
let num_teleporters = 4 + rng.next().unwrap_or(0) as usize % (MAX_TELEPORT - 4);

for i in 0..num_teleporters {
let x = match rng.next() {
Expand Down

0 comments on commit d6769a3

Please sign in to comment.