2011-English Auction Experiment

我終於把 english auction 的寫好了, 要同時使用 english.htm

這次的2個遊戲寫的還滿複雜的, 大概有 100 行之多,  去掉程式註解也約還有 50 行, 其中大半應該都是使用者介面的控制…
有點擔心程式會跑不動, 下星期再找時間來測試

我也把程式要進行的每一輪所需 step 寫成自動計算 (如下), 其它的不用再改了, 將要改的放在同一區塊, 更改 game 設定會更加方便。

2011-English Auction Experiment 程式:


#=============================================================================
# 2011-English auction experiment for 6 persons by yinung
#-----------------------------------------------------------------------------
#    * 假設若干人為一組 (3個人似乎比較OK), 每個人每一回合皆隨機取得自身 IPV.
#    * 價格由 0 開始往上增加, 每 5 - 8 秒增加 0.25 元, 增加到 10 元為止. 因此, 每一回合會有 40 期.
#    * 受測者每一期皆看到 目前價格, 並作出決策. 決策有二: 繼續等待 or 離開拍賣.
#    * 若於 40 期前, 拍賣已經結束, 則必須等待所有期數後, 始能進入下一回合.
#    * 預計進行 6 至 7 回合.
#-----------------------------------------------------------------------------
# 2011.05.07
#      從 2011-Dutch Auction Experiment 修改而來:
#         使用 english.htm 來當做 textinfo
#=============================================================================
M TimeToStart = 2011-05-11 01:04:20
M InitialSteps=0

M ENDTIME = 300
M TERMINATE = if(simStep>=NR*NOTP,1,0)
M NumberFormat = "#,##0.##"
M ROLEASSIGN = "random"
M showidentity=0

# --------- 以下是可能會改的 參數 -----model setting ------------------------------------
# --- 控制每一期幾秒
M TimeSpan = 8
# 啟始價格
V InitialPrice=0
V UpperPrice=3
# 每次降價幅度
V increment=1
# --- NR = number of rounds 要玩幾輪
V NR=4
# 分組指令: 6 人一組; 要更多人或更少人應該都可以 ...
G person = {"bidder1", "bidder2", "bidder3", "bidder4", "bidder5", "bidder6"}
# 願付價格的上、下界
V upper = 11
V lower = 0

#=============================================================================
# ------------------------------以下程式碼應該不會動到 -----------------------------
# --- NOTP = number of total period, 每一 輪 (round) 所含的期數
V NOTP=round(UpperPrice/increment)+1
#  V mySimStep=SimStep + 1  ### 在 Dutch game 中的設定
V mySimStep=SimStep + 1
V TimeLeft=NOTP-mod(mySimStep-1,NOTP)
P TimeLeft.label="還有幾期"
# ---目前遊戲是第幾輪
v myRound = int(SimStep/NOTP)+1
P myRound.label="第幾輪"

# ---- V pv = int(randbetween(lower,upper))+(100/4*int(randbetween(1,4.99)))/100
# --- pv 取小數兩位
#   V pv = int(randbetween(lower,upper)*100)/100
V pv = randbetween(lower,upper)
#   V myPV = if(OR(mod(mySimStep,NOTP)=1,mySimStep=1),previous(pv),previous(myPV,0))
V myPV = if(mod(mySimStep,NOTP)=1,previous(pv),previous(myPV,0))
P myPV.label="我的願付價格"

D Accept = if(mod(SimStep,NOTP)=0,{1,0},if(OR(SimStep=0,flag=1,winner=1),NA,{1,0}))
#####D Accept = if(OR(SimStep=0,flag=1,winner=1),NA,{1,0})
#D Accept = if(OR(SimStep=0,flag=1,Accept=0,winner=1),NA,{1,0})
### ---> this time ---> D Accept = if(OR(mySimStep=0,flag=0,Accept=0,winner=1),NA,{1,0})
# D Accept = if(OR(mySimStep<=0,flag=0,Accept=0,NumberofAccept<=1),NA,{1,0})
P Accept.label = "我的決策"
###   P Accept.desc = if(mod(SimStep,NOTP)=0,{"請選擇 ...","繼續等待", "離開拍賣"},{"繼續等待", "離開拍賣"})
P Accept.desc = {"繼續等待", "離開拍賣"}

V Price=if(mod(mySimStep,NOTP)=1,InitialPrice,Previous(Price,InitialPrice)+ increment)
## V Price=if(mod(mySimStep,NOTP)=1,InitialPrice,Previous(Price,InitialPrice)+ increment)
P Price.label="本期價格"

V prePrice=Previous(Price,0)
P prePrice.label="上一期價格"

# 用小數點的 decimal 用來決定同時按接受時, 誰得標
V decimal = randbetween(0,0.99)
V Accept0=Accept+decimal

#### 使用 G_sum 來抓群組中, 有誰按「離開拍賣」
V flag_accept=if(Accept=1,1,0)
v NumberofAccept=G_sum("flag_Accept")
# --- 2011.05.01: 檢查是否只有 (含) 1 人以下還是在「繼續等待」;若只剩1人,則該員得標; 若只有 0 , 則以上一回合 Accept0 最大者得標
###   v winner=if(NumberofAccept<=1,if(Accept0=G_max("Accept0"),1,0),Accept)
v winner=if(NumberofAccept=1,Accept,if(AND(OR(NumberofAccept=0,AND(NumberofAccept>=2,mod(SimStep,NOTP)=0)),previous(G_sum("winner")=0,0)),if(Accept0=G_max("Accept0"),1,0),0))
###   v winner=if(NumberofAccept=1,Accept,if(AND(NumberofAccept=0,previous(G_sum("winner")=0,0)),if(Accept0=G_max("Accept0"),1,0),0))
# -- this time---->   v winner=if(NumberofAccept=1,Accept,if(NumberofAccept=0,if(Accept0=G_max("Accept0"),1,0),0))
# --- 記住得標價 (只要 winner =0, 表示沒人得標; 若 winner = 1, 則表示有人得標)
v winPrice = Previous(Price)*winner
V g_winPrice=G_sum("winPrice")
P g_winPrice.label = "得標價格"
# --- flag = 1 表示此輪中已有 "某1人" 得標, mod(mySimSetp,NTOP) =1 時則重新設 =0
V flag=if(mod(SimStep,NOTP)=1,0,if(previous(G_sum("winner"),0)=1,1,Previous(flag,0)))
#   V flag=if(mod(SimStep,NOTP)=0,0,if(previous(G_sum("winner"),0)=1,1,Previous(flag,0)))

### 以下計算 payoff 的方式為, 在第一回合加入 initial cash balance $5
v payoff= winner*(Previous(myPV,0)-winPrice)
P payoff.label="回合獲利"

v acc_payoff=ACCUM(payoff,0)
P acc_payoff.label="累計獲利"

T table 1={"myRound","TimeLeft","Price","myPV","Accept","payoff","acc_payoff","g_winPrice"}
#T table 1={"TimeLeft","Price","myPV","Accept","payoff","acc_payoff","winner","winPrice"}
T table 2={"pv","myPV","Accept","Accept0","flag","winner","winPrice","NumberofAccept","winPrice"}
#T table 2={"pv","myPV","Accept","Accept0","winner","winPrice","NumberofAccept","flag","winPrice"}
M TextInformation = "english.htm"

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: