images.pixels.ovh
Rendering images on-demand consumes significant resources and adds waiting time.
Uploading a link to a prerendered image, rather than rendering it on-the-fly, can save up to 1 second per image. Under heavy load, this time savings can be even greater. For a game with 4 images per round, prerendering can save as much as 4 seconds in loading time.
Therefore, a simple and effective solution is to prerender images in advance, ensuring faster load times and a smoother experience for players.
Hashing location on bot side
Nodejsconst crypto = require("crypto");
function hashWithSalt(input, salt) {
const salted = input + salt; // Combine input with salt
const hash = crypto.createHash("md5").update(salted).digest("hex");
return hash;
}
const location = "/game/1.jpg";
const salt = "MySuperSecretSalt";
const hash = hashWithSalt(location, salt);
console.log(hash); // Output: 9e15b15ae872f4a61b4d54c11c338344
Assume the file is located at /game/2.jpg
. When hashed with MD5, this path results in the hash 587d7ab468f0b8360dcc10b82035cdf6.
Page Logic
How bot knows locations?
PHP and Nodejs During bot startup an API provides the bot with the complete site structure, allowing it to replicate this structure locally with placeholder files, saving space and bandwidth.
Pros and cons of that approach
Pros:
- Eliminates additional loading times, providing a smoother user experience.
- Hashing helps obfuscate URLs, making it harder for users to access images directly.
- Adding a salt to the hash provides an extra layer of security against URL manipulation.
Cons:
- Hash collisions, although rare, could occur, potentially leading to duplicate URLs for different images.
- Images remain accessible via URL, which might allow determined users to bypass game mechanics.
- Some users may save URLs to predict game answers, which could affect the guessing challenge.
Rendering Images
To optimize storage, I compress all images and convert them to .jpg format, reducing file size without significant loss of quality. For image editing, I use imageMagick alongside the npm package seedrandom. to randomize image variations.
Reducing Image Repetition for Each Game
To keep gameplay fresh and minimize repetition, I create multiple image variations per game. I use 5 unique random strings as seeds (e.g., 93JlS
) to generate variations. With 5 base images for each game, this approach results in a total of 25 possible starting images, giving players a more varied experience.
Classic mode




"Classic": {
"MaxLives": 4,
"ImageVariables": 5,
"BlurInRounds":{
"1":98,
"2":80,
"3":60,
"4":20
}
},
Nodejs
Puzzle mode




Zoom mode



