Sunken Temple

A hot-potato strategy game about exploration and treasure hunting played in a grid map.


This project is a board game idea and also my first solidity contract. The theme of the game is treasure hunting and exploration in a sunken city under the sea. I decided to design a game using unchecked math to emulate a map grid with infinite wrapping. Rules: The board consists of 256 different spaces. At the beginning of the game, the starting position is decided and four statues are spawned in pseudo-random positions. The first player deposits eth to claim the throne. Players can then bid 5% or more of the last price to dethrone the previous player. To do so, they need to "explore" a space adjacent to the current position or, if all the adjacent positions are taken (dead end), a position adjacent to any previously explored case. If a player finds a statue in the newly claimed space, they gain 25% of the current treasury. When a player is dethroned, they recover 90% of what they paid. The other 10% is sent to the treasury. When all 256 spaces are explored, the game ends and the last player to claim wins half the treasury. The other half is divided among all the other players proportional to the number of spaces claimed. The player holding the throne is also able to claim 1% of the treasury every 24 hours, but by doing so they also reduce the entry fee by 1%. The game is designed to use the quirks of solidity/blockchain as mechanics. Predictable randomness helps people strategize and even promotes teamwork to beat the game. Finding the statues early in the game is less profitable, so a strategy would be to trick someone else into triggering a dead end so that another player could more freely pick a space. Unlike other hot-potato games, claiming more spaces is rewarding and benefits everyone else.

Sunken Temple showcase

How it's made

I was planning on using Solidity + Unity + custom procedural materials made in Substance Designer. Unfortunately, I wasn't able to finish, but I did learn a lot! The chamber contract is an ERC-721 that gets minted in the player's name whenever they claim a space. When doing so, the player chooses a name for the chamber and this is turned into a seed. This seed will be placed into a formula inside substance designer to create unique patterns and textures. The whole map is stored inside a uint256 with bit-wise flags to represent whether a space is occupied or not. There is also custom math functions to make the map wrap around infinitely like a globe, allowing the exploration in any direction. I also used unchecked math to make uint256 arithmetic overflow and wrap around. The contract also keeps count of each player's balance throughout the whole game. Unfortunately, I wasn't able to create the front-end I had planned, but the code can be interacted with on remix and it's possible to play the whole game.

Technologies used