Top

CryptoKitties: The Tech behind the Craze

Since the game launched, more than 200,000 players have already signed up and the overall value of the kitties is more than $20 million in ether.

A team out of Vancouver launched their colourful virtual game called CryptoKitties on the Ethereum Blockchain introduced in November of 2017. Branded as “Collectable. Breedable. Adorable.” these felines look vibrant, playful, cute – and valuable. In fact, the most expensive cats in the game have been sold for a whopping 100,000 ETH per cat which is about $95 million currently (some are now worth $290,000).

Created by blockchain company Axiom Zen based in Vancouver, CryptoKitties look colourful and cute, and they serve a value-driven purpose – but how exactly does this system function? Here’s an in-depth look into what makes CryptoKitties tick.

Coded Genetic Algorithms

When it comes to solving non-linear optimisation issues, a genetic algorithm is a good bet. The basic functioning of genetic algorithms is the same as biological genetics.

The process of selection ensures that only the parents best suited for survival are selected for reproduction so as to pass on their well-performing genes.

The second step is a crossover or siring wherein the common qualities or genetic similarities between two parents are retained and passed on to the child. In the world of CryptoKitties, this means that the GA (Genetic Algorithm) to create a new cat comes from a ‘child genome’ that is created by crossing over two parent kitties.

The last step is that of mutation – wherein some of the variable from the parents are randomly mutated. This is necessary in the virtual world as it allows the system to adequately explore all of the possibilities to arrive at new effective solutions.

Kitty Codes

The code required for a game like CryptoKitties is extensive. For better management, it is broken down into individual contracts that follow a simplified and rigid inheritance system. According to the solidity guide, “When a contract inherits from multiple contracts, only a single contract is created on the blockchain, and the code from all the base contracts is copied into the created contract.” For CryptoKitties, the main contract is KittyCore. Each of the base contracts has a very specific function to follow, and the hierarchy is as follows: KittyAccessControl -> KittyBase -> KittyOwnership -> KittyBreeding -> KittyAuction -> KittyMinting -> KittyCore.

  • KittyAccessControl manages the privilege of specialised access by playing the roles of CEO (can reassign roles and change addresses of contracts), CFO (can auction contracts and withdraw from KittyCore), and COO (can mint cats for promos and release auction kitties). Though this contract has nothing to do with how the game works, it does have the ability to pause game play.
  • KittyBase is the contract that keeps record of ownership and sets down the primary rules for creating kitties based on variables like genes (genetic code), birthTime (timestamp of birth), cooldownEndBlock (cool down time before the kitty can breed once more), matronID and sireID (IDs of kitty’s parents), siringWithId (kitty’s pregnancy status), generation (starting from 0), etc.
  • KittyOwnership contract specifies the ERC721 formula that tokens follow – while 10ETH is 10ETH irrespective of how many times it is moved in and out of the system, the individual Cryptokitties cannot be exchanged with each other as they are all created differently, i.e. they are non-fungible.
  • KittyBreeding contracts sets the functions for breeding a new kitty. This complex system first creates child genomes based on geneScience.mixGenes() function and then a close-source breeding algorithm is used to implement GeneScienceInterface. Once the birthing process is completed, the ownership of the new kitty is passed to the one who owned the mother kitty and KittyBase is called upon to run the “createKitty()” function.
  • KittyAuctions is the contract that handles the creating and bidding of auctions. It is made of two sister contracts used for sales - setSaleAuctionAddress(), and siring – setSiringAuctionAddress() which can be called only by the CEO.
  • KittyMinting contract runs by a pre-set limit in the code which specifies that only 5000 promo and 45000 Gen 0 kitties can be created. While the COO has full control over the promo and Gen 0 kitties created, a promo kitty can be sent anywhere by the COO while a Gen 0 kitty is moved straight to auction.
  • KittyCore is the proverbial ‘one contract to rule them all’ as it inherits all of the functions from the contracts before and has the power to define a new method encoding all the functions used for creating specific kitties.

Since the game launched, more than 200,000 players have already signed up and the overall value of the kitties is more than $20 million in ether. Heavy duty dApps like Cryptokitties need to be regulated to avoid negative impact and clogging up of the blockchain. The game is set to be mobile-friendly (only iOS for now) – Axiom Zen has partnered with Animoca Brands, a games developer from Hong Kong. Scaling the system so Ethereum can handle the traffic is the pressure-point.

—by Kartik Mandaville, Founder & CEO, SpringRole.

( Source : deccan chronicle )
Next Story