BlockSlide

BlockSlide

Interactive puzzle NFT game built on Flow with a unique music experience and full on chain logic

BlockSlide

BlockSlide

Interactive puzzle NFT game built on Flow with a unique music experience and full on chain logic

The problem BlockSlide solves

BlockSlide is 3x3 puzzle game and interactive NFT where players attempt to solve puzzle game driven by NFT contract itself. Quality of solution impacts the outcome NFT while providing a complete interactive music experience. Every combination of moves done results in a unique and pleasant music built from a initial set of 16 indivial music files with hundreds of thousands of combination possible. NFT itself is a replay of user's solution of puzzle with traits depending on quality of solution

Interactive NFT

  • Replay of moves user did to solve puzzle

  • Score assigned based on moves count compared to least possible moves

  • Different display traits assigned based on score

  • Unique music in each NFT generated based on solution

Interactive music

  • Combination of puzzle and solution results in a unique music associated with NFT

  • Every user will get unique music based on moves done to solve puzzle

  • Hundreds of thousands of unique music possible

Fully on chain logic

Contract code at https://github.com/naman14/BlockSlide/blob/main/cadence/FlowPuzzleNFT.cdc

  • Contract determines shuffling order for each tokenId

  • User solves the puzzle, user’s solution moves are packed in a format that is highly gas efficient

  • Mint function is called by user with packed moves

  • Contract verifies the moves with the original shuffle order determined by the contract itself.

  • Contract saves the packed moves of user for interactive NFT metadata and replay NFTBlock

Challenges we ran into

Keeping the full logic of 3v3 puzzle game on chain was challenging. There were multiple challenges.

Creating the puzzle shuffle order

First step was creating the shuffling order for the puzzle itself. Some shuffling orders are unsolvable puzzles and we had to verify in the contract itself if a puzzle is solvable or not. Contract code needs to do extra shuffling iterations for such cases.
https://github.com/naman14/BlockSlide/blob/0e0cdb8ae2ff4da9dee64fb0e366e20900da4fbd/cadence/FlowPuzzleNFT.cdc#L455

Verifying user supplied puzzle solution efficiently

To solve a puzzle, users might take upto 300 moves sometimes or even more. Sending such large move arrays in transaction and storing such large moves array is not feasible. We spent lot of time to efficiently pack user moves array into a highly gas efficient manner. Steps included, changing moves into base 5 (representing left, right up, down as 1,2,3,4) and then chaining them into an indivifual BigNumber of each max 76 digits. This way, we can store upto 76 moves in a single uint256.
https://github.com/naman14/BlockSlide/blob/main/src/onchainmoves.js

Other challenges included creating interactive music experience and the puzzle logic itself in UI, and finding the shortest puzzle solution to calculate relative scores for NFT interactivity

Tracks Applied (2)

Gaming

BlockSlide is an interactive NFT game which fits in gaming track

Everything else

BlockSlide is an extensive experiment in maintaining on chain logic for a complete puzzle game

Technologies used

Discussion