Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
refactor(arbitration): split player state from player strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenctw committed Sep 6, 2023
1 parent eeb6f4f commit 6f5c759
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 309 deletions.
7 changes: 5 additions & 2 deletions onchain/permissionless-arbitration/offchain/entrypoint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ while true do
end

-- if all players are idle for 10 consecutive iterations, advance blockchain
if all_idle == 10 then
if all_idle == 5 then
print("all players idle, fastforward blockchain for 30 seconds...")
client:advance_time(30)
all_idle = 0
Expand All @@ -85,7 +85,10 @@ while true do
end

-- if no active player processes for 10 consecutive iterations, break loop
if no_active_players == 10 then break end
if no_active_players == 10 then
print("no active players, end program...")
break
end
end

print "Good-bye, world!"
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package.path = package.path .. ";/opt/cartesi/lib/lua/5.4/?.lua"
package.path = package.path .. ";./offchain/?.lua"
package.cpath = package.cpath .. ";/opt/cartesi/lib/lua/5.4/?.so"

local Player = require "player.honest_strategy"
local Player = require "player.state"
local Client = require "blockchain.client"
local Hash = require "cryptography.hash"

local time = require "utils.time"
local strategy = require "player.strategy"

local player_index = tonumber(arg[1])
local tournament = arg[2]
Expand All @@ -21,6 +22,7 @@ do
end

while true do
if p:react() then break end
p:fetch()
if strategy.react_honestly(p) then break end
time.sleep(1)
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package.path = package.path .. ";/opt/cartesi/lib/lua/5.4/?.lua"
package.path = package.path .. ";./offchain/?.lua"
package.cpath = package.cpath .. ";/opt/cartesi/lib/lua/5.4/?.so"

local Player = require "player.honest_strategy"
local Player = require "player.state"
local Client = require "blockchain.client"
local Hash = require "cryptography.hash"

local time = require "utils.time"
local strategy = require "player.strategy"

local player_index = tonumber(arg[1])
local tournament = arg[2]
Expand All @@ -18,6 +21,7 @@ do
end

while true do
if p:react() then break end
p:fetch()
if strategy.react_honestly(p) then break end
time.sleep(1)
end
303 changes: 0 additions & 303 deletions onchain/permissionless-arbitration/offchain/player/honest_strategy.lua

This file was deleted.

Loading

0 comments on commit 6f5c759

Please sign in to comment.