网上有python版的,给师妹写了个精简matlab版的。
直接输出生存率,可修改加入遗忘概率曲线。

%setting

num_of_gamers=uint8(16);

num_of_glasses=uint8(18);

num_of_rounds=uint32(1000000);

%count

total=uint32(zeros(num_of_gamers,1));

for rounds=1:num_of_rounds

%initialization

bridge=logical(round(rand(num_of_glasses,1)));

step_continue=1;

%game start

for gamer=1:num_of_gamers

for step=step_continue:num_of_glasses

if step_continue<=num_of_glasses

step_continue=step_continue 1;

elseif step_continue==num_of_glasses 1

break

end

if logical(round(rand()))~=bridge(step) %choice

break

end

end

if step_continue==num_of_glasses 1

total(gamer)=total(gamer) 1;

end

end

end

%save("total.mat","total");

bar(double(total)/double(num_of_rounds)*100);

鱿鱼游戏玻璃桥MATLAB脚本