フィルターのクリア

Monte Carlo Simulation (chutes and ladders)

1 回表示 (過去 30 日間)
E
E 2013 年 10 月 25 日
I'm trying to work a monte carlo simulation for a chutes and ladders game. The board is nine squares. You can only roll a 1 or a 2. If you land on square 3, you are laddered to square 6. if you land on square 8, you chute down to square 2. If you land on square 9, you win the game. I'm trying to determine the average number of rolls it takes to win the game. We are required to run this simulation several times to see if the average changes based on how many times you run the simulation. This is what I have so far. Any help is appreciated.
n=5;
for t=1:n
pos=0;
move=0;
while pos(t)<9
roll(t)=round(a+(b-a).*rand(1));
pos(t)=pos(t)+roll(t);
if pos(t)=3
then pos(t)=6
end
if pos(t)=8
then pos(t)=2
end
move(t)=move(t)+1;
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeBoard games についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by