Transaction #168

Hash 771d78fe1dd605e67e022b4cf6277b0d08f8ef81db8283f2c63d6a88215156bf
Status Success
Timestamp 452 days ago - 2/1/2023, 4:09:35 AM UTC+0
Block 168
Stamps Used 188
Burned Fee 0.01112426 TAU
From a02dde674a13d6fb71ac08f79b5ae1e23e4c43af4d8fbd05c7b2db6f167d7adc 
Contract Name submission
Function Name submit_contract

Additional Info
Nonce 2
Processor 9d2dbfcc8cd20c8e41b24db367f215e4ac527dc6a2a0acdb4b6008d13d043ef8
Signature c565870a6da0c62db1ebb0954b073612f21c778472f75f2f2678134c0ec7172d4401bac0e8f92af03989726e8c3c2c438b0f02185a46f46165da8678e25b1d00
Stamps Supplied 300
Stamps per TAU 169

Kwargs

code ### # This is a simple smart contract # All Lamden smart contracts are programmed in Python # For complete contracting documentation please visit https://contracting.lamden.io/ ### random.seed() games = Hash(default_value=False) metadata = Hash() @construct def seed(): metadata['operator'] = ctx.caller @export def create_game(): #ctx.caller is a global variable and is the public key of the person who sent the transaction sender = ctx.caller assert(games[sender] != False, 'Game already in progress') first = random.randint(0, 99) # 0 = not set, 1 = O, 2 = X if(first <50): first = 1 # Player goes first else: first = 2 # Computer goes first games[sender] = {'first': first, 'state': [0, 0, 0, 0, 0, 0, 0, 0, 0], 'turn': 0} return games[sender] @export def end_game(): games[ctx.caller] = False @export def player_selection(i: int): sender = ctx.caller assert(games[sender] == False, 'No game already in progress') games[sender]['state'][i] = 1 games[sender]['turn'] = game[sender]['turn'] + 1 win = False if(turns >= 9): return {'winner': 'none', 'state': games[sender]['state']} if(turn >= 5): win = checkWin(games[sender]['state'], 1) elif(win == 1): games[sender] = False return {'winner': sender, 'state': games[sender]['state'] } else: computerSelects = random.random(9) while(games[sender]['state'][computerSelects] != 0): computerSelects = random.random(9) games[sender]['state'][computerSelects] = 1 games[sender]['turn'] = game['turn'] + 1 if(turns >= 9): games[sender] = False return {'winner': 'none', 'state': games[sender]['state']} if(turn >= 5): win = checkWin(games[sender]['state'], 2) elif(win == 2): games[sender] = False return "{'winner': 'computer', 'state': " + f"{games[sender]['state']}" + "}" return f'{games[sender]}' def checkWin(state, x): if(state[0] == x): # top left if(state[1] == x and state[1] == x): #top row return x if(state[3] == x and state[6] == x): #left column return X if(state[4] == x and state[8] == x): # diagnal top left to bottom right return X if(state[1] == x): # top middle if(state[4] == x and state[7] == x): # middle column return x if(state[2] == x): # top right if(state[5] == x and state[8] == x): #right column return x if(state[4] == x and state[6] == x): # diagnal top right to bottom left return X if(state[3] == x): # top middle if(state[4] == x and state[5] == x): # middle row return x if(state[6] == x): # top middle if(state[7] == x and state[8] == x): # bottom row return x
name con_tictactoe_v3

State Changes

Contract con_tictactoe_v3
Variable metadata
Key operator
New Value a02dde674a13d6fb71ac08f79b5ae1e23e4c43af4d8fbd05c7b2db6f167d7adc
 
Contract con_tictactoe_v3
Variable __code__
New Value random.seed() __games = Hash(default_value=False, contract='con_tictactoe_v3', name='games') __metadata = Hash(contract='con_tictactoe_v3', name='metadata') def ____(): __metadata['operator'] = ctx.caller @__export('con_tictactoe_v3') def create_game(): sender = ctx.caller assert (__games[sender] != False, 'Game already in progress') first = random.randint(0, 99) if first < 50: first = 1 else: first = 2 __games[sender] = {'first': first, 'state': [0, 0, 0, 0, 0, 0, 0, 0, 0], 'turn': 0} return __games[sender] @__export('con_tictactoe_v3') def end_game(): __games[ctx.caller] = False @__export('con_tictactoe_v3') def player_selection(i: int): sender = ctx.caller assert (__games[sender] == False, 'No game already in progress') __games[sender]['state'][i] = 1 __games[sender]['turn'] = game[sender]['turn'] + 1 win = False if turns >= 9: return {'winner': 'none', 'state': __games[sender]['state']} if turn >= 5: win = __checkWin(__games[sender]['state'], 1) elif win == 1: __games[sender] = False return {'winner': sender, 'state': __games[sender]['state']} else: computerSelects = random.random(9) while __games[sender]['state'][computerSelects] != 0: computerSelects = random.random(9) __games[sender]['state'][computerSelects] = 1 __games[sender]['turn'] = game['turn'] + 1 if turns >= 9: __games[sender] = False return {'winner': 'none', 'state': __games[sender]['state']} if turn >= 5: win = __checkWin(__games[sender]['state'], 2) elif win == 2: __games[sender] = False return ("{'winner': 'computer', 'state': " + f"{__games[sender]['state']}" + '}') return f'{__games[sender]}' def __checkWin(state, x): if state[0] == x: if state[1] == x and state[1] == x: return x if state[3] == x and state[6] == x: return X if state[4] == x and state[8] == x: return X if state[1] == x: if state[4] == x and state[7] == x: return x if state[2] == x: if state[5] == x and state[8] == x: return x if state[4] == x and state[6] == x: return X if state[3] == x: if state[4] == x and state[5] == x: return x if state[6] == x: if state[7] == x and state[8] == x: return x
 
Contract con_tictactoe_v3
Variable __compiled__
New Value e30000000000000000000000000500000040000000736c00000065006a0183000100650264006401640264038d035a0365026401640464058d025a046406640784005a0565066401830164086409840083015a07650664018301640a640b840083015a086506640183016509640c9c01640d640e840483015a0a640f641084005a0b64115300291246da10636f6e5f746963746163746f655f7633da0567616d65732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272040000007205000000630000000000000000000000000300000043000000730e00000074006a01740264013c006400530029024eda086f70657261746f722903da03637478da0663616c6c6572da0a5f5f6d65746164617461a900720b000000720b000000da00da045f5f5f5f0600000073020000000001720d000000630000000000000000020000000a00000043000000736200000074006a017d0074027c00190064016b0364026602731a7403820174046a056403640483027d017c0164056b00723464067d016e0464077d017c016403640364036403640364036403640364036709640364089c0374027c003c0074027c001900530029094e467a1847616d6520616c726561647920696e2070726f6772657373e900000000e963000000e932000000e901000000e9020000002903da056669727374da057374617465da047475726e290672080000007209000000da075f5f67616d6573da0e417373657274696f6e4572726f72da0672616e646f6dda0772616e64696e742902da0673656e6465727213000000720b000000720b000000720c000000da0b6372656174655f67616d650a00000073120000000002060114010c0108010602040116010c01721b000000630000000000000000000000000300000043000000730e0000006401740074016a023c006400530029024e462903721600000072080000007209000000720b000000720b000000720b000000720c000000da08656e645f67616d651800000073020000000002721c0000002901da0169630100000000000000040000000300000043000000736401000074006a017d0174027c01190064016b0264026602731a74038201640374027c011900640419007c003c0074047c011900640519006403170074027c01190064053c0064017d02740564066b057260640774027c0119006404190064089c025300740664096b05727c740774027c01190064041900640383027d026ede7c0264036b02729e640174027c013c007c0174027c0119006404190064089c02530074086a08640683017d03782274027c011900640419007c031900640a6b0372ca74086a08640683017d0371aa5700640374027c011900640419007c033c007404640519006403170074027c01190064053c00740564066b0590017214640174027c013c00640774027c0119006404190064089c025300740664096b0590017232740774027c01190064041900640b83027d026e287c02640b6b029001725a640174027c013c00640c74027c011900640419009b001700640d1700530074027c0119009b005300290e4e467a1b4e6f2067616d6520616c726561647920696e2070726f6772657373721100000072140000007215000000e909000000da046e6f6e652902da0677696e6e65727214000000e905000000720e00000072120000007a207b2777696e6e6572273a2027636f6d7075746572272c20277374617465273a20da017d29097208000000720900000072160000007217000000da0467616d65da057475726e737215000000da0a5f5f636865636b57696e72180000002904721d000000721a000000da0377696eda0f636f6d707574657253656c65637473720b000000720b000000720c000000da10706c617965725f73656c656374696f6e1d000000733400000000020601140110011801040108011201080114010801080112020a0116010e01100114010a01080112010a0114010a0108021601722800000063020000000000000002000000020000004300000073260100007c00640119007c016b0272607c00640219007c016b0272287c00640219007c016b0272287c0153007c00640319007c016b0272447c00640419007c016b027244740053007c00640519007c016b0272607c00640619007c016b027260740053007c00640219007c016b0272887c00640519007c016b0272887c00640719007c016b0272887c0153007c00640819007c016b0272cc7c00640919007c016b0272b07c00640619007c016b0272b07c0153007c00640519007c016b0272cc7c00640419007c016b0272cc740053007c00640319007c016b0272f47c00640519007c016b0272f47c00640919007c016b0272f47c0153007c00640419007c016b02900172227c00640719007c016b02900172227c00640619007c016b02900172227c01530064005300290a4e720e0000007211000000e903000000e906000000e904000000e908000000e907000000721200000072210000002901da015829027214000000da0178720b000000720b000000720c00000072250000003d000000732a00000000010c011801040118010401180104010c01180104010c0118010401180104010c01180104010e011c0172250000004e290c7218000000da0473656564da04486173687216000000720a000000720d000000da085f5f6578706f7274721b000000721c000000da03696e7472280000007225000000720b000000720b000000720b000000720c000000da083c6d6f64756c653e01000000731000000008010e010c030804100e10050601101f
 
Contract con_tictactoe_v3
Variable __owner__
New Value null
 
Contract con_tictactoe_v3
Variable __submitted__
New Value 2023,2,1,4,9,36,0
 
Contract con_tictactoe_v3
Variable __developer__
New Value a02dde674a13d6fb71ac08f79b5ae1e23e4c43af4d8fbd05c7b2db6f167d7adc
 
Contract currency
Variable balances
Key a02dde674a13d6fb71ac08f79b5ae1e23e4c43af4d8fbd05c7b2db6f167d7adc
New Value 1705.82461516076922957