Bot editor
I integrated the QuickJS driver code that I made last devlog into the rest of the site. Things I did:
- I made the QuickJS VM override the default
Math.randomfunction and replace it with a mulberry32 prng seeded by stringifying the game state and hashing it through djbs2. So now drivers can still useMath.randomwithout making the rng predictable or sacrificing perfect determinism. - I gave the drivers names and descriptions. The prng driver is named “Bogo” (after Bogosort) and the expected value driver is named “EVan” (because it’s a normal name that starts with the abbreviation of “Expected Value”).
- I moved the code for the existing drivers into a centralized array, rather than in multiple different files that had to be imported individually. I’m calling this array the “stock drivers”.
- I added a bot editor page. You can check it out at https://ethmarks.github.io/hadronize/bots. I used
contenteditableand Svelte’sbind:textContentto let users edit the title, ID, and description. I used Prism code editor as the embedded IDE for editing the actual driver code. - I made the play page fetch the list of drivers from
localstorageon page load, defaulting to the stock drivers. I also made the bot editor automatically sync the drivers tolocalstorage. - I added a new driver strategy: tit for tat. As expected, it plays pretty terribly because that strategy just isn’t very good in Hadronize. I mostly made it so that users looking at the stock drivers can learn how to reference the timeline from the state.
I think that next I’ll work on a driver ranking system so that when I make more drivers, I’ll know whether they’re better or worse than the others. I might research how chess ranking systems work and copy concepts from those.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.