Finding the value of two functions simultaneously

1 回表示 (過去 30 日間)
Samson Leach
Samson Leach 2019 年 3 月 26 日
編集済み: madhan ravi 2019 年 3 月 26 日
Hi there, I'm currently trying to code the probabilities of a player winning at each given game state in the game piglet found here : https://pdfs.semanticscholar.org/50b2/d628c3a03cfe2594a052a99da627f875ee48.pdf
The issue with my code is that the probability in each state of a player winning depends on the probability of the other player winning in a given game state, so I need to work out the value of each function simultaneously, I have tried to use the syms command but I get an error-Error using sub2ind (line 43) Out of range subscript. Anyway, here is my code:
clear;
clc;
strategy1=2;
strategy2=2;
maxscore=2;
m=maxscore;
n=maxscore;
k=maxscore;
p=zeros(maxscore+1,maxscore+1,maxscore+1);
q=zeros(maxscore+1,maxscore+1,maxscore+1);
p(m,n,k)=1;
q(m,n,k)=1;
for m=maxscore:-1:1
for n=maxscore:-1:1
for k=maxscore:-1:1
if k<=strategy1+1 & m+k<=maxscore+1
p(m,n,k)= 0.5*((1-q(n,m,1))+p(m,n,k+1));
end
if k>=strategy1+1 & m+k<=maxscore+1
p(m,n,k)= 1-q(n,m+k-1,1);
end
if k>=strategy2+1 & n+k<=maxscore+1
syms
q(n,m,k)= 0.5*(1-p(m,n,1)+q(n,m,k+1));
end
if k>=strategy2+1 & n+k<=maxscore+1
q(n,m,k)= 1-p(m,n+k-1,1);
end
end
k=maxscore;
end
k=maxscore;
n=maxscore;
end
An example of the issue would be finding p(2,2,1)=0.5*(1-q(2,2,1)+p(2,2,2)) but q(2,2,1) is obviously an unknown value.
Any help would be much appreciated

回答 (0 件)

カテゴリ

Help Center および File ExchangeStrategy & Logic についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by