Sudoku
The Sudoku Antara Module serves as a proof-of-concept to demonstrate Antara's capabilities as a blockchain-based gaming technology.
The Sudoku Module is based on the classic game, Sudoku. To learn more about how Sudoku is played, read the associated Wikipedia article:
Link to Sudoku Wikipedia article
The procedures to launch and finish a game require the execution of various Remote Procedure Calls (RPCs). By design, the Sudoku Module assumes the user relies on the associated Sudoku GUI software. The GUI is required because the UNIX timestamp for each gameplay event must pass trough the Sudoku RPC captcha protection, as this deters bots.
The following installation and walkthrough tutorials can assist the reader in setting up and playing the Sudoku game. For more information, please reach out to our community on Discord. The #cc-sudoku channel is available for questions and assistance.
- Create a puzzle using the gen method
- commit the amount of
SUDOKU
coins that will serve as a bounty for the first node to complete this puzzle
- commit the amount of
- Find a puzzle to solve using the pending method
- Gather additional information about any puzzle using the txidinfo method
- Propose a solution for a puzzle using the solution method
Sudoku is currently playable on Linux machines.
OSX and Windows compatible bundles will be ready as soon as possible. Please ask on our #cc-sudoku channel on Discord for updates.
The Komodo Sudoku software bundle (also called "Komodoku") for Ubunutu Linux comes complete with all necessary software. To download the bundle, please visit the link below:
Link to "Komodoku" Software Bundle
To manually compile the software, follow the instructions below.
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libgtest-dev libqt4-dev libqrencode-dev libdb++-dev ntp ntpdate software-properties-common curl libcurl4-gnutls-dev cmake clang libsodium-dev -y
cd ~
git clone https://github.com/jl777/komodo
cd komodo
git checkout FSM
make clean
./zcutil/fetch-params.sh
./zcutil/build.sh -j$(nproc)
Wait for the build process to finish, and then continue with the following commands:
cd src/cc
./makecclib
cp sudokucc.so ../libcc.so
cd ../..
make -j$(nproc)
cd ~/komodo
git checkout FSM
git pull
make clean
./zcutil/build.sh -j$(nproc)
Wait for the build process to finish, and then continue with the following commands:
cd src/cc
./makecclib
cd ../..
make -j$(nproc)
Ensure the working directory is correct:
cd ~/komodo/src
Start the SUDOKU chain with the following command in a terminal window and wait for the daemon to sync. Keep this terminal open and the daemon running for the duration of your Sudoku gameplay.
./komodod -ac_name=SUDOKU -ac_supply=1000000 -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc &
Open a new terminal. This terminal can be used to execute all remaining installation and gameplay commands.
./komodo-cli -ac_name=SUDOKU getnewaddress
The returned value is a SUDOKU address. We need to find the associated pubkey for this address.
Use the validateaddress
method with the address.
./komodo-cli -ac_name=SUDOKU validateaddress insert_address_here
The validateaddress
method will return information similar to the following:
{
"isvalid": true,
"address": "RPCeZmqW4Aam52DFLmMraWtu5CuXPxqk92",
"scriptPubKey": "76a91498b5caa42ffe9868844c51ba6e085e5e7e92fc2588ac",
"segid": 13,
"ismine": true,
"iswatchonly": false,
"isscript": false,
"pubkey": "02f183a71e93dfa7672ce7212187e45eabcf4077fed575348504b20295751ab1a2",
"iscompressed": true,
"account": ""
}
Look for the pubkey
value:
"pubkey": "02f183a71e93dfa7672ce7212187e45eabcf4077fed575348504b20295751ab1a2",
This is the pubkey
for our address.
Set the pubkey for the SUDOKU Smart Chain.
./komodo-cli -ac_name=SUDOKU setpubkey 02f183a71e93dfa7672ce7212187e45eabcf4077fed575348504b20295751ab1a2
The pubkey is now set.
To reuse this pubkey in the future, include the pubkey as a pubkey launch parameter.
For example:
./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey=02f183a71e93dfa7672ce7212187e45eabcf4077fed575348504b20295751ab1a2 -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc &
The Komodo team offers an unofficial graphical user interface (GUI) to assist the user with Sudoku-puzzle solving visualization. By design, the Sudoku module assumes the user relies on the associated Sudoku GUI software. The GUI is required because the UNIX timestamp for each gameplay event must pass trough the Sudoku RPC captcha protection, as this deters bots.
Download the portable GUI bundle from the following link:
To manually compile the GUI from source code, follow the steps below. Please note that the GUI is based on python2
.
sudo apt-get install python-pygame libgnutls28-dev
pip install requests wheel slick-bitcoinrpc pygame
git clone https://github.com/tonymorony/Komodoku
cd Komodoku
python Sudoku.py
cclib gen 17
The generate method creates a new Sudoku puzzle.
The method returns a hex value which must then be broadcast using the sendrawtransaction method.
Name | Type | Description |
---|---|---|
(none) |
Daemon stdout
:
Name | Type | Description |
---|---|---|
(solved Sudoku puzzle, visualized) | (string, multi-line) | an ASCII-character representation of the generated Sudoku puzzle, with all solutions in place |
(unsolved Sudoku puzzle, visualized) | (string, multi-line) | an ASCII-character representation of the generated Sudoku puzzle, with numbers removed for gameplay |
(numbers remaining) | (string) | a description of how many numbers are remaining to solve in the Sudoku puzzle |
(Sudoku Puzzle - integer) | (number, multi-line) | a multi-line number-based representation of the solved Sudoku puzzle; no visual embellishments |
solve | (number) | a number-based concatenated representation of the unsolved Sudoku puzzle; 0 's represent empty spaces in the puzzle |
score | (string) | score returns three values: the difficulty of the puzzle calculated by the generator, the solution in concatenated format, the number of numbers left to fill |
json output:
Name | Type | Description |
---|---|---|
result | (string) | whether the command executed successfully |
name | (string) | name of the module |
method | (string) | name of the method |
srand | (number) | the seed of the non-blockchain based puzzle that is creating RNG |
amount | (number) | the reward provided to the first node to submit the correct solution |
hex | (string) | a hex value representing the encoded data; this must be broadcast using sendrawtransaction |
txid | (string) | a transaction id representing the generation of this Sudoku puzzle, also called the puzzle_txid |
Command:
./komodo-cli -ac_name=SUDOKU cclib gen 17
cclib pending 17
The pending
method returns a complete list of all unsolved puzzles on the Smart Chain.
Name | Type | Description |
---|---|---|
(none) |
Name | Type | Description |
---|---|---|
result | (string) | whether the command executed successfully |
name | (string) | name of the module |
method | (string) | name of the method |
pending | (array of json objects) | an array of json objects, each containing information about an unsolved puzzle on the chain |
height | (number) | the block height at which the puzzle was generated |
amount | (number) | the reward provided to the first node to submit the correct solution |
txid | (string) | a transaction id representing the generation of this puzzle, also called the puzzle_txid |
numpending | (number) | the total number of on-chain unsolved puzzles |
total | (number) | the collective value of all outstanding bounties for unsolved puzzles |
Command:
./komodo-cli -ac_name=SUDOKU cclib pending 17
cclib solution 17 '["puzzle_txid","solution",t0,t1,t2,...]'
The solution
method submits the proposed solution
to the blockchain for the indicated puzzle_txid
puzzle.
The t0...
values represent the timestamp at which the solution was found for each number. Pre-filled cells have an automated timestamp of tX=0
, where X
is the index of the puzzle number.
The method returns a hex value which must then be broadcast using the sendrawtransaction method.
Name | Type | Description |
---|---|---|
txid | (string) | a transaction id representing the generation of this puzzle, also called the puzzle_txid |
solution | (numeric string) | the proposed solution, provided in a concatenated format |
tX... | (81 UNIX timestamps separated by comma) | there are 81 total t... arguments. X is the index of the indicated argument. The argument is a timestamp representing the time at which X number was input. Timestamp value should be 0 for numbers which were already known |
json output:
Name | Type | Description |
---|---|---|
name | (string) | name of the module |
hex | (string) | a hex value representing the encoded data; this must be broadcast using sendrawtransaction |
txid | (string) | a transaction id representing the generation of this Sudoku puzzle, also called the puzzle_txid |
amount | (number) | the reward provided to the first node to submit the correct solution |
result | (string) | whether the command executed successfully |
sudokuaddr | (string) | the Antara address that owns this puzzle reward and will distribute the reward |
method | (string) | name of the method |
Daemon stdout
:
Name | Type | Description |
---|---|---|
solved | (string) | this returns three values: the block height at which the puzzle was solved, the amount of coins rewarded, the solution txid |
solution | (number) | this contains three values: a number-based concatenated representation of the solved puzzle; a string representing the concatenated unsolved puzzle; the total score for solving this puzzle |
statistics | (string) | information which helps this module developer to detect was puzzle solved by robot or human |
Command:
./komodo-cli -ac_name=ROGUE cclib solution 17 [%22b5d7e2b50ace182e0ab7b5a18875818fa8e56b937689376bc5bdc8727b78ad52%22,%22157392864829461357436587129795634218381279645642815973978146532563728491214953786%22,1552297383,1552297384,1552297386,0,1552297387,0,0,1552297389,1552297389,1552297391,0,1552297392,1552297394,1552297396,1552297396,1552297397,1552297398,1552297399,1552297401,1552297402,1552297403,1552297404,1552297405,1552297407,1552297408,1552297409,1552297410,1552297412,1552297413,0,1552297415,1552297416,1552297417,0,0,1552297419,0,1552297422,1552297423,1552297424,1552297429,0,1552297431,0,1552297432,1552297435,1552297436,1552297437,1552297439,0,1552297440,1552297441,1552297443,0,1552297445,0,0,1552297446,1552297447,0,1552297449,0,1552297451,0,1552297453,0,1552297455,0,0,0,1552297457,0,1552297458,1552297459,0,0,1552297460,0,1552297462,1552297462,0]
cclib txidinfo 17 '["puzzle_txid"]'
The txidinfo
method returns information about the indicated puzzle_txid
puzzle.
Name | Type | Description |
---|---|---|
puzzle_txid | (string) | the unique transaction id of the requested puzzle, as returned from the broadcast hex of the gen method |
Name | Type | Description |
---|---|---|
result | (string) | whether the command executed successfully |
txid | (string) | a transaction id representing the generation of this Sudoku puzzle, also called the puzzle_txid |
result | (string) | whether the command executed successfully |
height | (number) | the block height at which the puzzle was generated |
sudokuaddr | (string) | the Antara address that owns this puzzle funds and will distribute the reward |
amount | (number) | the reward provided to the first node to submit the correct solution |
unsolved | (string) | the unsolved puzzle, provided in concatenated form, filling playing field from left to right horizontally, and from top to bottom vertically |
name | (string) | name of the module |
method | (string) | name of the method |
Command:
./komodo-cli -ac_name=SUDOKU cclib txidinfo 17 \"%220aaa8fdc83aa9111b1f1d143ca7baf5730cd68c02f1422b3f8cf4186959db6ff%22\"