Inspiration

Games like Minecraft and Roblox stand as great examples of large multiplayer spaces where users can express their creativity with complex creations. However, some of the problems with these projects come from their inherit centralization. Ephemeral and permanent game-state relies on a single server, and transactions and product decisions are controlled entirely by the parent corporation.

What it does

Inf-p2p (aka Infinite Peer-to-peer) solves these problems through decentralization. This is a proof-of-concept game where players can explore a procedurally generated, infinite world; interact with an unlimited number of players; and create permanent modifications to the world -- all without relying on a centralized server model. Inf-p2p relies entirely on peer-to-peer networking and blockchain technology, so there is no single point of failure; whether is be a server, database, or corporate entity.

Features:

  • connect immediately through the website
  • all terrain is unique and dynamically generated. all players see the same world. the world has a theoretically unlimited size (until you hit JavaScript's float64 limit...)
  • interact with other players in the world by viewing their movements in real-time
  • build anywhere in the world with voxels. Your additions and deletions to the world are permanent, even after disconnecting.

How we built it

Before this hackathon, I started experimenting with terrain generation with infinitely scalable chunks, learning from game developers like Sebastian Lague. I used some of this terrain generation code in this project.

As a web developer, I chose to build the graphics, gameplay, and networking using browser technologies:

  • hosting: just a static HTML page on Vercel
  • 3D graphics: three.js
  • physics engine: rapier.rs
  • user-interface: next.js & react.js
  • peer-to-peer ephemeral-data sending (e.g. player position data): WebRTC, with fallbacks on public STUN/TURN servers
  • peer-to-peer announcements (i.e. how to give other peers your WebRTC connection "instructions"): public torrent trackers
  • permanent-game-data storage: TRON blockchain, connected through the tronweb browser library

Challenges we ran into

  • WebRTC support: some network firewalls block WebRTC connections, which means some users cannot take full advantage of peer-to-peer networking. The workaround was adding public relay servers (STUN/TURN servers) as fallbacks for these users.
  • blockchain: there was a steep learning curve to figure out if blockchain technology is even a viable solution for a browser game's state. I couldn't find any examples of similar projects, so I had to figure out how to write smart-contracts for adding/removing 3D voxel data in a performant way.
  • chunked terrain generation: this is a very deep rabbit hole, and I barely scratched the surface. I had trouble getting terrain chunks to seamlessly connect, render with different level-of-detail based on player distance, and generate unique and interesting features with pleasant colors.
  • peer-to-peer connection limits: a client can only connect to 256 other peers at a time, so my current naive networking implementation would likely cause your webpage to crash once a certain number of people connect to the server. I did not have to time to implement a more scalable solution.
  • making a fun game: it is a stretch to call this project a "game", I had very little time to add any game mechanics

TLDR: steep learning curves for new technologies, and I didn't allocate enough time before the deadline.

Accomplishments that we're proud of

Along with overcoming some of the challenges above, I am proud that the final product is:

  • relatively performant, despite being run in a web browser
  • mostly achieves my end-goal of: decentralized networking & state, and infinite scalability
  • was really fun to learn and build!

What we learned

See Challenges we ran into section

What's next for Infinite P2P

There's some obvious scalability bottlenecks to fix, mainly querying the blockchain and p2p networking limits. However, my real priority is to polish the gameplay, add user communication (e.g. spacially limited text/voice chat), add more variety to terrain, and add better building mechanics to incentivize people to actually play. I hope to collect user feedback and see if there's demand for other GameFi mechanics e.g. buying land or buying user creations.

Built With

Share this project:

Updates