//Role=1: BLUE; Role=0: GREEN
// we use the modulus function
//even Subjects are BLUE, odd Subjects are GREEN
Role=mod(Subject,2);
//Role=1: BLUE; Role=0: GREEN
// we use the modulus function
//first half is BLUE, other half GREEN
Role=if(Subject<=(maximum(Subject)/2),1,0);
//Role=1: BLUE; Role=0: GREEN
rank_rdm=random();
Next portion of code should go in a different Program!
// we assign a random number between 1 and N to each
rank = subjects.count( rank_rdm<= :rank_rdm);
//Role=1: BLUE; Role=0: GREEN
//even Subjects are BLUE, odd Subjects are GREEN
Role=mod(rank,2);
//we assign to those with Role==1 (BLUE) 100 Endowment and to the others 0
Endowment=if(Role==1,100,0);
common_value=round(random()*100,1);
common_value=globals.find(common_value);
group_rdm=random();
Endowment=if(Role==1,100,0);
Then, assign them a Group code
rank = subjects.count(Role==:Role & rank_rdm<= :rank_rdm);
Group = mod(rank,maximum(Subject)/4);
if (Period>1){
Group=OLDsubjects.find(same(Subject),Group);
}else{
Group=Group;
}
A course in zTree
Matteo Ploner