SlideShare a Scribd company logo
z-Treeの基礎その5
結果画面をつくる
if~elsif文を用いた様々なプログラム
結果画面をつくる①
•
をクリックして青くハイライ
トされたら,“Treatment”タ
ブから“New Stage...”をク
リックして新しいステージを
つくる.
結果画面をつくる②
• “Stage” 画面が出てきたら
“Name”の“Stage”を“Result
Stage”に変える.
• 他の箇所は変更せずにOKを
クリック.
利得のプログラムをつくる①
•
をクリックして青くハイライ
トされたら,“Treatment”タ
ブから“New Program...”をク
リック.
利得のプログラムをつくる②
• 右図のような画面がでてきた
ら,画面を消さずに次のスラ
イドにすすむ.
利得のプログラムをつくる③
• さて,ここでようやくプログラミング(みたいなこと)をする
必要がでてくる.
• なぜなら,自分の選択と相手の選択によって利得が変動するか
らである.
• なお,あらかじめ断っておきたいのは,ここで紹介するプログ
ラムはあくまで一例に過ぎない.
他にも同様の結果を導くプログラムを書くことはできるので,
慣れてきたら是非一度どのようなプログラムで書けるか考えて
ほしい.
利得のプログラムをつくる④
• ここで書きたいプログラムを日本語で説明すると以下の通り.
(1)自分がCを選択かつ相手もCを選択
→自分の利得は21,(相手の利得も21)
(2)自分がCを選択かつ相手がDを選択
→自分の利得は11,(相手の利得は25)
(3)自分がDを選択かつ相手がCを選択
→自分の利得は25,(相手の利得は11)
(4)自分がDを選択かつ相手もDを選択
→自分の利得は15,(相手の利得も15の)
利得のプログラムをつくる⑤
• ところで,前回のスライドで次のような意思決定ラジオボタン
を作成したことを思いだしてほしい.
!radio:
1 =“C ”;
0 =“D ”;
これは,被験者がCを選ぶとChoice=1,Dを選ぶとChoice=0と
してコンピュータが認識するという意味であった.
• これを用いて利得のプログラムを作成する.
• また,このプログラムにはif~elsif文を用いる.
利得のプログラムをつくる⑥
if~elsif文とは?
• if~elsif文とは,下記のような文で,
if( 状態A ){
説明a;
}
elsif( 状態B ){
説明b;
}
『状態Aのとき説明a,状態Bのとき説明b』となることを表す.
利得のプログラムをつくる⑦
• まず,このプログラムで非常に重要な役割を果たす変数をひと
つを自分で定義する.それは,自分と相手の変数Choiceの和を
表す変数である.
この変数を以下のプログラムのように定義しよう.
TCV = sum (same (Group),Choice);
// Total of ChoiceVariable in same group
このプログラムの意味は,『同じグループ(つまりこのゲーム
では自分と相手)の変数Choiceの和』を求める変数をTCVとす
る,ということである.
↑『//』から始まる文はコメントと呼ばれるものであり,
プログラムの文には含まれない,いわばメモのようなもの.
利得のプログラムをつくる⑨
自分\相手 C D
C 21\21 11\25
D 25\11 15\15
自分\相手 Choice=1 Choice=0
Choice=1 TCV=2 TCV=1
Profit=21 Profit=11
Choice=0 TCV=1 TCV=0
Profit=25 Profit=15
与えられた利得表をChoice(自分の意思決定変数)とTCV(自分と相手のChoiceの和)と
Profit(自分の利得)についての表に書き換えると右図のようになる.
利得のプログラムをつくる⑧
• TCVを用いてif~elsif文に当てはめられるように先述の(1)~(4)
を日本語で書きかえると次のようになる.
(1)’ TCV(自分と相手のChoiceの和)が2かつChoice(自分の選
択)が1のとき,自分の利得は21
(2)’ TCVが1かつChoiceが1のとき,自分の利得は11
(3)’ TCVが1かつChoiceが0のとき,自分の利得は25
(4)’ TCVが0かつChoiceが0のとき,自分の利得は15
利得のプログラムをつくる⑩
• それでは,先述のプログラムをif~elsif文を用いて書いてみよう.
(1)’ TCV(自分と相手のChoiceの和)が2かつChoice(自分の選
択)が1のとき,自分の利得は21
これは次のように書くことができる.
if (TCV == 2 & Choice == 1){
Profit = 21;
}
利得のプログラムをつくる⑪
• 同じように(2)’についてもif~elsif文で書いてみよう.ただし,
(2)’についてはifではなくelsifから始まることに注意したい.
(2)’ TCVが1かつChoiceが1のとき,自分の利得は11得
これは次のように書くことができる.
elsif (TCV == 1 & Choice == 1 ){
Profit = 11;
}
利得のプログラムをつくる⑫
• (3)’についても書いてみよう.これも(2)と同じようにelsifから
始めればよい.
(3)’ TCVが1かつChoiceが0のとき,自分の利得は25
これは以下のように書くことができる.
elsif (TCV == 1 & Choice == 0 ){
Profit = 25;
}
利得のプログラムをつくる⑬
• (4)’についても同様で,
(4)’ TCVが0かつChoiceが0のとき,自分の利得は15
これは以下のように書くことができる.
elsif (TCV == 0 & Choice ==0 ){
Profit = 15;
}
利得のプログラムをつくる⑭
• z-Treeに戻って,“Program”
画面の“Program”に以上の
TCVに関する定義式と4つの
if~elsif文を書く.
• それができたらOKをボタン
をクリック.
• これで結果画面で利得を表示
する準備ができた.
自分の利得を表示する①
• それでは,実際に自分の利得
を結果画面に表示させよう.
•
の下にある
をクリックして青くハイライ
トされたら,“Treatment”タ
ブから“New Box”を選んで
“Standard Box...”をクリック.
自分の利得を表示する②
• “Standard Box”画面が表示れ
たら,“Name”をResultに変
更する.
• それができたらOKボタンを
クリック.
自分の利得を表示する③
• 先程作成した
をクリックして青くハイライ
トされたら,“Treatment”タ
ブから“New Item...”をクリッ
ク.
自分の利得を表示する④
• “Item”画面が表示されたら,
“Label”に“今回の利得”と書く.
(文字化けするかもしれない
が気にしない.)
“Variable”には“Profit”と書く.
“Layout”には“1”と記入する.
• ここまでできればOKボタン
をクリック.
自分の選択を表示する①
• 次に自分の選択を結果画面に
表示する準備をする.
• 先程作成したプログラムの
をクリックして青くハイライ
トされたら, “Treatment”タ
ブから“New Program...”をク
リック.
自分の選択を表示する
• ここで作りたいのは,自分が何を選択したかを表示するプログ
ラムである.
• ここでもif~elsif文を用いて書いてみる.
• 自分の選択を表す変数をMyChoiceとして,次のようなプログ
ラムを書くとif=elsif文で書くことができる.
Choice=1のときMyChoiceはC,
Choice=0のときMyChoiceはD.
自分の選択を表示する
• これを実際にif~elsif文で書くと次のように書くことができる.
if (Choice == 1 ) {
MyChoice = “C”;
}
elsif(Choice == 0) {
MyChoice = “1”;
}
自分の選択を表示する
• z-Treeに戻って,“Program”
画面の“Program”にこのプロ
グラムを書く.
• それができたらOKをボタン
をクリック.
• これで結果画面で自分の選択
を表示する準備ができた.
自分の選択を表示する
•
の下にある
をクリックして青くハイライ
トされたら,“Treatment”タ
ブから“New Item...”をクリッ
ク.
自分の選択を表示する
• “Item”画面が表示されたら,
“Label”に“自分の選択”と書く.
(文字化けするかもしれない
が気にしない.)
“Variable”には“MyChoice”と
書く.
“Layout”には“1”と記入する.
• ここまでできればOKボタン
をクリック.
相手の選択を表示する①
• 最後に,相手の選択を表示す
るプログラムを作成する.
•
をクリックして青くハイライ
トされたら, “Treatment”タ
ブから“New Program...”をク
リック.
相手の選択を表示する②
• ここで作りたいのは,相手が何を選択したかを表示するプログ
ラムである.
• これも変数TCVとif~elsif文を用いて書くことができる.
• 相手の選択を表す変数をPertnerChoiceとして,次のようなプ
ログラムを書くとif=elsif文で書くことができる.
TCV=2かつChoice=1のとき(相手の意思決定変数は1であると
わかるので)PartnerChoiceはC.
TCV=1かつChoice=1のときPartnerChoiceはD.
TCV=1かつChoice=0のときPartnerChoiceはC.
TCV=0かつChoice=0のときPartnerChoiceはD.
相手の選択を表示する③
• これをTCVとif~elsif文で書くと次のように書くことができる.
if ( TCV == 2 & Choice == 1 ) {
PartnerChoice = ”C";
}
elsif ( TCV == 1 & Choice == 1 ) {
PartnerChoice = ”D";
}
elsif ( TCV == 1 & Choice == 0 ) {
PartnerChoice = ”C";
}
elsif ( TCV == 0 & Choice == 0 ) {
PartnerChoice = ”D";
}
相手の選択を表示する④
• z-Treeに戻って,“Program”
画面の“Program”に先述のプ
ログラムを書く.
• それができたらOKをボタン
をクリック.
• これで結果画面で相手の選択
を表示する準備ができた.
相手の選択を表示する⑤
•
の下にある
をクリックして青くハイライ
トされたら,“Treatment”タ
ブから“New Item...”をクリッ
ク.
相手の選択を表示する⑥
• “Item”画面が表示されたら,
“Label”に“相手の選択”と書く.
(文字化けするかもしれない
が気にしない.)
“Variable”には
“PertnerChoice”と書く.
“Layout”には“1”と記入する.
• ここまでできればOKボタン
をクリック.
『次へ』ボタンをつくる①
•
をクリックして青くハイライ
トされたら,“Treatment”タ
ブから“New Button...”をク
リック
『次へ』ボタンをつくる②
• “Button”画面が表示されたら
“Name”を“次へ”に書き換える.
• これができたらOKボタンを
クリック.

More Related Content

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

z-Tree manual #5