%% function [Play Payouts tau] =PlayFingers(PayoutTables,Qas) % % This function is called by FingerScript.m % % It uses a soft max policy to decide on the next board position % % Input: % PayoutTables: This is a cell. The jth entry of the cell is a matrix which gives % the payout to the jth player, given the play of the % participants. % % Qas: This is a cell. The jth entry corresponds to the jth player % and is comprised of two rows. The kth row contains the current estimate of % the value of playing k and the number of times that k has already been chosen % by the jth player. % % Output: % % Play is a vector. The jth entry is the choice made by the jth player. % % Payouts is a vector. The jth entry contains the payout % to the jth player of the current game. This is actually implied % by the above variable Play (since PayoutTables is given). % % tau is the temperature that is calculated in the program %% % % % The algorithm is a softmax policy. % taumin=.3; % Change Me; use .3 for Nash game % use .1 for Dominant, Prisoner's Dilemma Game sPayoutTables = length(PayoutTables); sQas = length(Qas); if sQas~=sPayoutTables display('sizes of PayoutTables and Qas not compatible'); return end NumPlayers= sQas; for jSubj=1:NumPlayers QasNow= Qas{jSubj}; TotalPlayed1= QasNow(1,2 ); % Total Number of times 1 has been chosen TotalPlayed2= QasNow(2,2 ); % Total Number of times 2 has been chosen tau=3; %TotalPlayed= sum(Qas(indsPlayed,2 )); Q1= QasNow(1,1); % This is the value of the first state for jSubj Q2= QasNow(2,1); tau1= 3* min(1,500/TotalPlayed1); % temperature depends on tau1=max(tau1,taumin); tau2= 3* min(1,500/TotalPlayed2); % tau2=max(tau2,taumin); tau=2/(1/tau1+1/tau2); QtauDiff= Q1/tau1 - Q2/tau2; QtauDiff= (Q1 - Q2)/tau; choice1= 1/(1 + exp(-QtauDiff) ); % This is the relative probabilities % of the first choice if rand()