diff --git a/examples/battleship/run.sh b/examples/battleship/run.sh new file mode 100755 index 0000000000..dd9411b677 --- /dev/null +++ b/examples/battleship/run.sh @@ -0,0 +1,216 @@ +#!/bin/bash +# First check that Leo is installed. +if ! command -v leo &> /dev/null +then + echo "leo is not installed." + exit +fi + +# Follow along in the README.md for a detailed explanation of each step. + +# 1. Setup +echo "{ + \"program\": \"battleship.aleo\", + \"version\": \"0.0.0\", + \"description\": \"\", + \"development\": { + \"private_key\": \"APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm\", + \"view_key\": \"AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6\", + \"address\": \"aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy\" + }, + \"license\": \"MIT\" +}" > program.json + +# 2. Select Player 1's Board +leo run initialize_board 34084860461056u64 551911718912u64 7u64 1157425104234217472u64 aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry + +# 3. Pass to Player 2 +leo run offer_battleship '{ + owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + gates: 0u64.private, + hits_and_misses: 0u64.private, + played_tiles: 0u64.private, + ships: 1157459741006397447u64.private, + player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + game_started: false.private, + _nonce: 3887646704618532506963887075433683846689834495661101507703164090915348189037group.public +}' + +# 4. Select Player 2's Board +( + echo "{ + \"program\": \"battleship.aleo\", + \"version\": \"0.0.0\", + \"description\": \"\", + \"development\": { + \"private_key\": \"APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH\", + \"view_key\": \"AViewKey1hh6dvSEgeMdfseP4hfdbNYjX4grETwCuTbKnCftkpMwE\", + \"address\": \"aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry\" + }, + \"license\": \"MIT\" + }" > program.json + + leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy +) + +# 5. Pass to Player 1 +leo run start_battleship '{ + owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + gates: 0u64.private, + hits_and_misses: 0u64.private, + played_tiles: 0u64.private, + ships: 9044591273705727u64.private, + player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + game_started: false.private, + _nonce: 1549419609469324182591325047490602235361156298832591378925133482196483208807group.public +}' '{ + owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + gates: 0u64.private, + incoming_fire_coordinate: 0u64.private, + player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + prev_hit_or_miss: 0u64.private, + _nonce: 4374626042494973146987320062571809401151262172766172816829659487584978644457group.public +}' + +# 6. Player 1 Shoots First +( + echo "{ + \"program\": \"battleship.aleo\", + \"version\": \"0.0.0\", + \"description\": \"\", + \"development\": { + \"private_key\": \"APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm\", + \"view_key\": \"AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6\", + \"address\": \"aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy\" + }, + \"license\": \"MIT\" + }" > program.json + + leo run play '{ + owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + gates: 0u64.private, + hits_and_misses: 0u64.private, + played_tiles: 0u64.private, + ships: 1157459741006397447u64.private, + player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + game_started: true.private, + _nonce: 6563064852163330630334088854834332804417910882908622526775624018226782316843group.public + }' '{ + owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + gates: 0u64.private, + incoming_fire_coordinate: 0u64.private, + player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + prev_hit_or_miss: 0u64.private, + _nonce: 3742551407126138397717446975757978589064777004441277005584760115236217735495group.public + }' 1u64 +) + +# 7. Player 2 Shoots Second +( + echo "{ + \"program\": \"battleship.aleo\", + \"version\": \"0.0.0\", + \"description\": \"\", + \"development\": { + \"private_key\": \"APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH\", + \"view_key\": \"AViewKey1hh6dvSEgeMdfseP4hfdbNYjX4grETwCuTbKnCftkpMwE\", + \"address\": \"aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry\" + }, + \"license\": \"MIT\" + }" > program.json + + leo run play '{ + owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + gates: 0u64.private, + hits_and_misses: 0u64.private, + played_tiles: 0u64.private, + ships: 9044591273705727u64.private, + player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + game_started: true.private, + _nonce: 6222383571142756260765569201308836492199048237638652378826141459336360362251group.public + }' '{ + owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + gates: 0u64.private, + incoming_fire_coordinate: 1u64.private, + player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + prev_hit_or_miss: 0u64.private, + _nonce: 5481529266389297320813092061136936339861329677911328036818179854958874588416group.public + }' 2048u64 +) + +# 8. Player 1 Shoots Third +( + echo "{ + \"program\": \"battleship.aleo\", + \"version\": \"0.0.0\", + \"description\": \"\", + \"development\": { + \"private_key\": \"APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm\", + \"view_key\": \"AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6\", + \"address\": \"aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy\" + }, + \"license\": \"MIT\" + }" > program.json + + leo run play '{ + owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + gates: 0u64.private, + hits_and_misses: 0u64.private, + played_tiles: 1u64.private, + ships: 1157459741006397447u64.private, + player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + game_started: true.private, + _nonce: 1474170213684980843727833284550698461565286563122422722760769547002894080093group.public + }' '{ + owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + gates: 0u64.private, + incoming_fire_coordinate: 2048u64.private, + player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + prev_hit_or_miss: 1u64.private, + _nonce: 5851606198769770675504009323414373017067582072428989801313256693053765675198group.public + }' 2u64 +) + +# 9. Player 2 Shoots Fourth +( + echo "{ + \"program\": \"battleship.aleo\", + \"version\": \"0.0.0\", + \"description\": \"\", + \"development\": { + \"private_key\": \"APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH\", + \"view_key\": \"AViewKey1hh6dvSEgeMdfseP4hfdbNYjX4grETwCuTbKnCftkpMwE\", + \"address\": \"aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry\" + }, + \"license\": \"MIT\" + }" > program.json + + leo run play '{ + owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + gates: 0u64.private, + hits_and_misses: 0u64.private, + played_tiles: 2048u64.private, + ships: 9044591273705727u64.private, + player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + game_started: true.private, + _nonce: 5254963165391133332409074172682159033621708071536429341861038147524454777097group.public + }' '{ + owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + gates: 0u64.private, + incoming_fire_coordinate: 2u64.private, + player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, + player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, + prev_hit_or_miss: 0u64.private, + _nonce: 710336412388939616658264778971886770861024495941253598683184288448156545822group.public + }' 4u64 +)