What is Artificial Intelligence ?
Artificial Intelligence is commonly understood as the capacity for a machine or a system to mimic a human-like intelligence through cognitive processes like “learning” and “problem solving”. In the field of computing, the technologies closest to this paradigm are machine learning and deep learning. However, more generally, AI represents the ability of a system to act with “intelligence”, that is to present a logic of resolution relatively complex and high-level to a problem in order to achieve a specific objective. Such a definition allows to integrate many other technologies that belong to the field of Artificial Intelligence, including voice recognition, natural language generation, virtual agents, biometrics and decision management. If you’re interested in AI, we recommend to read up the posts about demystifying AI by Ben Dickson.
Ethereum limitations for Artificial Intelligence
The blockchain responds efficiently to the problematics of “trusted third party” and transaction security but what about performance?
Ethereum through its smart contracts enables execution of programs on its blockchain. Solidity, the language to develop smart contracts is Turing-Complete, that is to say is able to describe any algorithm that would run on a computer. Knowing that, we may want to deploy any program or game on the blockchain. However, because the Ethereum virtual machine has limited computing capabilities, the execution of demanding processing cannot be accomplished.
Let’s take as an example a chess game. Among other things, the game needs some logic control to detect if a move is valid or not and whether a game is over or not. Even detecting the checkmate or stalemate for every move is very costly, and cannot be computed on chain. It requires too much processing to be provided by the blockchain. This blog post explains the problem very accurately.
The solution to benefit from the advantages of the blockchain while still using demanding programs is to use an hybrid solution by deporting the program execution, requiring processing power and memory the blockchain can’t provide, off-chain. In other words, the costly tasks would run on an infrastructure dissociated from the Ethereum blockchain but interacting with it and using it as the reliable canal of communication between a client and the program. That’s what iExec offers.
Stockfish is a chess engine based on Glaurung, another open source chess engine created by Tord Romstadis and released on 2004, and is considered to be one of the strongest free chess engines available today. We have deployed Stockfish on iExec infrastructure allowing interaction with it through a smart contract. The smart contract stores the game for each player but doesn’t achieve any chess processing. It simply allows communication between a client and the chess engine.
To play with Stockfish, you have two options :
- using the dedicated web front-end
- using Browser solidity
With the front-end
The dedicated front-end is available at http://184.108.40.206/stockfish/
It includes a text box where you can write your moves and three buttons from left to right allowing to perform respectively the submission of a move, canceling the last moves both of the player and Stockfish engine, and starting a new game. The format used to describe the moves is long algebraic (e.g. “a2a4” means move the piece from “a2” to “a4”). Moreover, the player can only move the whites because he’s the only one currently able to initiate a game. Don’t undo a move if the chess engine hasn’t played because it would corrupt the game. When a transaction is sent, all the buttons are grayed out but if, for a reason or another, you reload the page before Stockfish has played its move the buttons will be clickable again.
With Browser Solidity
Browser Solidity is available at https://ethereum.github.io/browser-solidity/
The first thing to do is writing the contract in the console. You just have to copy/paste the code of the smart contract available at https://github.com/iExecBlockchainComputing/bridge_stockfish/blob/master/stockfish.sol
Now you need to instantiate the contract. You can achieve it through the right panel clicking on the green button “At Address” underneath Stockfish. A popup should appear asking for an address and you must provide the address of the smart contract which is 0x91c545a43d09a8f6ea88320b13f26666f8109459
Be sure to choose ropsten when selecting the network.
Now you can play with Stockfish using the buttons getResult, undoMove, flushGame and setParam. They respectively allows you to get the result on the smart contract, undo your last move, start a new game and submit a new move. Be careful again not undoing your last move while Stockfish hasn’t played for the same reasons explained in the web front-end part. To use setParam, you should write between single quotes.
We would love to get your feedbacks and comments in our Slack #beta-testers channel.