MatLab Code, requires more arguments to run

조회 수: 2 (최근 30일)
Nick Olibrice
Nick Olibrice 2020년 12월 19일
댓글: Nick Olibrice 2020년 12월 19일
why wont this code run?
function [winner,playerscore] = goFish2(h1,h2,deck)
playerscore(1)=0;
playerscore(2)=0;
for i = 1:(length(h1)-1)
if(h1(i)==h1(i+1))
playerscore(1) = playerscore(1)+1;
h1(i)=[];
h1(i)=[];
if(i+2>length(h1))
break;
end
end
end
for i = 1:length(h2)-1
if(h2(i)==h2(i+1))
playerscore(2) = playerscore(2)+1;
h2(i)=[];
h2(i)=[];
if(i+2>length(h2))
break;
end
end
while(isempty(h1) && ~isempty(h2))
if(h1(1)==h2(1))
h1 = h1(2:end);
h2 = h2(2:end);
score(1) = score(1) + 1;
else
if(~isempty(deck) && h1(1)==deck(1))
h1 = h1(2:end);
deck = deck(2:end);
score(1) = score(1) + 1;
else
if(~isempty(deck))
temp = h1(1);
h1.append(deck(1));
h1 = h1(2:end);
h1.append(temp);
deck = deck(2:end);
end
end
end
end
if(isempty(h1) || isempty(h2))
break;
end
if(h1(1)==h2(1))
h1 = h1(2:end);
h2 = h2(2:end);
playerscore(2) = playerscore(2) + 1;
else
if(~isempty(deck) && h2(1)==deck(1))
h2 = h2(2:end);
deck = deck(2:end);
playerscore(2) = playerscore(2) + 1;
else
if(~isempty(deck))
temp = h2(1);
h2.append(deck(1));
h2 = h2(2:end);
h2.append(temp);
deck = deck(2:end);
end
end
end
if(playerscore(1)>playerscore(2))
winner = 'PLAYER 1 WON!';
elseif(playerscore(2)>playerscore(1))
winner = 'PLAYER 2 WON!';
else
winner = 'TIE GAME!';
end
end
end
  댓글 수: 3
Nick Olibrice
Nick Olibrice 2020년 12월 19일
I wasnt using the correct input for the command window so it was not working, I think I got it now. I have been trying to make a functional game of goFish in MatLab.
Nick Olibrice
Nick Olibrice 2020년 12월 19일
Nevermind, I am unaware how to run this script, it does not work. I am trying to do what I said in my previous comment.
Thank you.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Conway's Game of Life에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by