% March 20th 2008 % Written by PRBaldwin %% % Part 1. Set up the Payout Matrix % Part 2. Play the Finger Game % Part 3. Assess Results %% % Part 1. % Payout2A= [1 -1; -1 1]; % symmetrical, Nash Payout2A = [2 -3; -3 4]; % Nash Payout2A = [0 -2; 2 0] ; % antisymmetric, dominant Payout2A = [1 -2; 2 0] ; % Bluefin in peril Payout2B = [1 2; -2 0] ; % Bluefin in peril % Payout2B=- Payout2A; PayoutTables{1}= Payout2A; PayoutTables{2}= Payout2B NumPlayers=length(PayoutTables); %% Part 2 % % Play The Game NumRounds2Play=40000; clear Qas for jSubj=1:2 Qas{jSubj} =2*( rand(2,1)-.5); % Between -1 and 1 % Has as many entries as there are possible % moves Qas{jSubj} =[Qas{jSubj},ones(2,1)]; % Keep track of the number of updates end % for NumRound=1:NumRounds2Play if round(NumRound/1000)*1000==NumRound, NumRound, end % just print [Play Payouts tau] = PlayFingers(PayoutTables,Qas); NewQas=UpdateQFinger(Play,Payouts,Qas); Qas=NewQas; end %% Part 3 % Summarize results for jSubj=1:NumPlayers % % prob1(jSubj)= Qas{jSubj}(1,2)/ sum(Qas{jSubj}(:,2)) ; % prob1(jSubj) = round(1000*prob1(jSubj))/1000; % display(strcat('prob of playing 1 by Player', num2str(jSubj),'=',num2str(prob1(jSubj)))) % % % display(' ') % prob2(jSubj)= Qas{jSubj}(2,2)/ sum(Qas{jSubj}(:,2)) ; % prob2(jSubj) = round(1000*prob2(jSubj))/1000; % display(strcat('prob of playing 2 by Player', num2str(jSubj),'=',num2str(prob2(jSubj)))) display(' ') prob1tau(jSubj)= exp(Qas{jSubj}(1,1)/tau)/ sum(exp(Qas{jSubj}(:,1)/tau)) ; prob1tau(jSubj) = round(1000*prob1tau(jSubj))/1000; display(strcat('prob (based on tau) of playing 1 by Player', ... num2str(jSubj),'=',num2str(prob1tau(jSubj)))) display(' ') prob2tau(jSubj)= exp(Qas{jSubj}(2,1)/tau)/ sum(exp(Qas{jSubj}(:,1)/tau)) ; prob2tau(jSubj) = round(1000*prob2tau(jSubj))/1000; display(strcat('prob (based on tau) of playing 2 by Player', ... num2str(jSubj),'=',num2str(prob2tau(jSubj)))) display(' ') end % tau*log(prob1./(1-prob1)) % tau*log(prob2./(1-prob2)) % % Qas{1}(1,1)-Qas{1}(2,1) % % mean(jSubj) % 7/12