MatLab Code, requires more arguments to run

1 vue (au cours des 30 derniers jours)
Nick Olibrice
Nick Olibrice le 19 Déc 2020
Commenté : Nick Olibrice le 19 Déc 2020
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 commentaires
Nick Olibrice
Nick Olibrice le 19 Déc 2020
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 le 19 Déc 2020
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Board games dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by