Gaming

GenCar.co: Multiplayer Genetic Algorithm 2D Cars

2 min read Michael Carroll on Jun 29, 2013

Warning

We’ve updated our SDKs, and this code is now deprecated.

Good news is we’ve written a comprehensive guide to building a multiplayer game. Check it out!

Around the PubNub office, we’re always sharing our gaming high scores with each other, whether it’s TrackPad Destroyer, Lightweight Multiplayer Games with melonJS, or Real-Time Stats for Candy Box. So when our CTO Stephen Blum stumbled upon Rafael Matsunaga‘s Genetic Cars, naturally another competition was born.

The game uses genetic algorithms to test and improve simple racing cars on a randomly generated track. Similar to the Darwinian concept of Evolution, the most superior cars continue to combine and mutate while the weak cars are thrown out. The winning car is  added to your gene pool and is then genetically spliced and paired with your other cars. As more mutations are made, the cars become more efficient and travel farther.

However, our CTO Stephen Blum decided to take the game to the next level from single player to multiplayer by harnessing the PubNub Data Stream Network. The result was Gencar.co.

multiplayer

Because of PubNub’ Gencar.co multiplayer capabilities, it involves thousands of players at a time, which in turn has significantly accelerated the mutation rate. As a result, thousands of users at a time can watch as their cars increase in efficiency. In addition, we added a chat feature using PubNub Channel Presence to see how many people are in the app.

The open source code is all available on our GitHub Repository: Multiplayer Genetic Cars.

multiplayer

0