Skip to content

Instantly share code, notes, and snippets.

@axiand
axiand / about.md
Last active March 30, 2024 03:22
Tag snake!

A simple snake game in a little over 1000 characters. Made to be ran under the Assyst bot (https://github.com/Jacherr/Assyst2).

To add it to your server (assuming you use Assyst):

-tag create tagsnake {js:let arg0="{tryarg:0}"; let arg1="{tryarg:1}"; {download:https://gist.githubusercontent.com/axiand/295dd2b5a70601f2c1819274a599ed5b/raw/fc5bc3dcd57d79f0c6c5981b5f516e224705fa10/tagsnake.js} //* by https://github.com/axiand <3 *//}

Then run it using -tag tagsnake.

@axiand
axiand / snailrace.js
Last active June 18, 2023 18:44
snailrace.js
//ex. SnailRace("red")
var SnailRace = function (bet) {
let snails = {'red': 0, 'blue': 0, 'green': 0, 'yellow': 0};if(!Object.keys(snails).includes(bet)) {return this.SnailRaceResult = `Invalid input; must be one of: ${Object.keys(snails).join(", ")}`}; let winState = false;let winner = null;while(!winState) {for(let snail in snails) {snails[snail] += Math.round(Math.random()*3); if(snails[snail] >= 25) {winState = true; winner = snail}}}let print = '';for(let snail in snails) {print += `${winner==snail?'🎉':''}🐌 ${snail} ${snails[snail]}cm\n`;}print += `${winner} crossed the finish line first!! You bet for ${bet}. Was your bet correct? ${winner==bet&&'Yes!'}`; return print
};
@axiand
axiand / randomseedexample.js
Created June 18, 2023 18:33
Random Seed Usage Example
function cyrb128(str) {
let h1 = 1779033703, h2 = 3144134277,
h3 = 1013904242, h4 = 2773480762;
for (let i = 0, k; i < str.length; i++) {
k = str.charCodeAt(i);
h1 = h2 ^ Math.imul(h1 ^ k, 597399067);
h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);
h3 = h4 ^ Math.imul(h3 ^ k, 951274213);
h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);
}