Problem with odds and even simulation code
이전 댓글 표시
Hello. I'm trying to simulate an even and odds game that scores 100 games. The problem is that when I get the results Player B seems to always win. Can anybody see whats wrong?
ScoreA=0;
ScoreB=0;
for z= 2:100
PlayerA= randi(2,[100,1]);
PlayerB= randi(2,[100,1]);
n= PlayerA+PlayerB;
if n==3
ScoreA(z)=ScoreA(z-1)+1;
ScoreB(z)=ScoreB(z-1);
else
ScoreB(z)=ScoreB(z-1)+1;
ScoreA(z)=ScoreA(z-1);
end
end
댓글 수: 1
Erivelton Gualter
2018년 10월 22일
I did not understand very well what you are looking forward. However, I just note your if statement is weird.
For example, for PlayerA = [2 2 1 1 1] and PlayerB = [2 1 1 2 1]; We have ScoreA = [0 0 0 0 0] and ScoreB = [0 1 2 3 4];
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Number games에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!