Smart Contracts and Thinking Machines
Let’s start with some context.
CypherPoker’s cryptography does two things:
- It enables you to deal cards without relying on any trusted third party.
- It allows you to detect cheating without relying on any trusted third party.
These are great features but there are a couple of things that are missing:
- If you do detect cheating what can you do about it?
- Who holds the money during a game and disperses correctly it when done?
For these characteristics we need a trusted third party such as smart contracts.
Despite their name, smart contracts aren’t inherently “smart” and aside from an allusion to futures they don’t really resemble any sort of legal “contract”.
Simply put, smart contracts are just programs that are executed and verified by peers participating in a blockchain such as Ethereum.
There are a lot of misconceptions floating around out in the world about smart contracts.
There are many other rubbish views out there too ludicrous to warrant a response so I’m going to stop there. Suffice it to say, smart contracts in CypherPoker are simply the trusted third party, or TTP, that holds the money and ultimately enforces the rules of the game. They play the same role as traditional TPPs, or existing online poker services.
Unlike traditional, centralized TTPs however, smart contracts distribute the trust among thousands of participating nodes so that anyone wishing to cheat or rip you off would need to overwhelm the computing power that the current network represents.
So this makes a nice alternative to the “just trust me” approach, but it comes with a couple of caveats.
Smart contracts are slow and cost money
First, smart contracts are currently joined at the hip to their operational cryptocurrency. In the case of Ethereum, that would be Ether.
Technically, Ethereum smart contracts require something called gas but that’s converted directly from Ether and as the price of Ether goes up, so does the cost of publishing and operating smart contracts.
In addition to this, as a child of the blockchain the smart contract is limited by the block time. When you want the smart contract to do something you need to wait for the next block before your instructions can be added to it and executed. And there’s no guarantee that your instructions will make it into the next block.
When I was developing the ActionScript version of CypherPoker the price of Ether was fairly reasonable and block times were about 20 seconds so I made the smart contracts the primary TPP solution. Those contracts are usable pretty much as-is with CypherPoker.JS but as I watched the price of Ether slowly creep upwards I realized that I would probably need to look at some alternatives.
Some of those promising alternatives include lightning networks and something called Plasma which are, in simple terms, add-ons to the blockchain intended to reduce contract execution (block) times and costs. However, they’re still quite young and require some additional work.
Browsers are (necessarily) limited
Second, connecting directly to the Ethereum network requires that you download additional desktop software, whether it’s a full-fledged client that allows you to manage smart contracts or a simpler wallet that allows you to send and receive transactions.
The browser, due to a variety of historic security and technical restrictions, can’t play this role. Instead, if you want to use just a browser you need to go through an online intermediary that can manage smart contracts and transactions on your behalf.
This is quite common with Bitcoin, Ether, and other cryptocurrencies, but it reduces some of that distributed trust that makes the blockchain such an attractive proposition.
Unfortunately, there doesn’t currently seem to be much in the way of alternatives in this area but, fortunately, the solution doesn’t have to work in exactly the way I’ve just described.
The middle way
CypherPoker.JS comes in two major flavours: web (browser) and desktop.
For the desktop version the browser limitations don’t apply. Non-existent problem solved!
For the more limited web version, however, the CypherPoker.JS service will have the characteristics of both a lightning network and a full, stand-alone TPP.
Instead of relying on the blockchain to process each and every transaction and/or smart contract instruction, the service holds them so that the game can progress at a nice pace.
When players have provided proof of a successfully completed game, the on-blockchain smart contracts are mostly bypassed, thereby greatly reducing operational costs. Players that fail to follow protocol are dinged using the held information, maybe even losing their entire buy-in, so that there’s always an incentive to play fairly.
I’m oversimplifying things here but essentially the service will minimize interactions with the blockchain in order to keep costs down and game speeds up.
With this approach the service can also support cryptocurrencies that don’t come with smart contract functionality, such as Bitcoin.
Much of this work has already been done for a related project (hence my absence from this project), and although I can’t copy it outright, the experience is not going to go unused!
The other problem
To (very) loosely paraphrase an old saying, CypherPoker without players is much like a fish out of water: pointless.
The solution is fairly obvious — introduce bots!
While traditional online poker services seek to minimize the use of bots and assistants, to me this is the wrong way to go.
On top of constantly scanning your device for an ever-growing list of banned software, these services are putting ever-increasing limits on how games can be played. In short, there are fewer options and more restrictions, and doing so as part of an effort to increase profits doesn’t exactly leave me with warm fuzzies.
Besides, resourceful players will always stay one step ahead of the establishment. Offhand I can think of many ways to defeat the various bans and requirements imposed by existing online poker services, and I expect that my ideas would seem trivial to more determined players.
Upping the surveillance ante, as it were, is a losing game. What’s next, some company goon physically watching over your shoulder to make sure you play as they want you to?
So that being said, the challenge comes not from banning bots and automated assistants but from not building good ones.
When anyone can play a technically sound hand of poker, thanks to their bot, it turns the game from an unbalanced pros-versus-fish one to one of (near) equals reading human intuition.
During my time away from CypherPoker I also studied and tested neural networks as a basis for poker bots, which so far appear to be an effective foundation.
I still have a lot to learn about these probabilistic systems but so far I’m excited about what I’ve seen.
Of course there will always be those who prefer the exclusively human approach and there are some realizable solutions, such as live webcam chat, that can help to reduce automation, but in the end it’d be like trying to hold a flood back with a wad of gum.
Besides, CypherPoker.JS is open-source and my solutions needn’t be yours.
I firmly believe that, ultimately, openness will be a far better approach than centralized bans and limits; but, hey, you don’t have to take my word for it!
Next time: A timeline for the schedule-impaired