Game in MATLAB?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nick Haufler
le 25 Jan 2016
Commenté : Walter Roberson
le 27 Jan 2016
I'm making Yahtzee in Matlab, and I'm focusing on getting the scoring set up. I get scores to come back in an array, but they don't seem to be correct. I've looked over my code several times, but just cant seem to figure out what went wrong. I'm desperate at this point, and need help. I attached my code along with this post. Any help is appreciated. Thanks! You guys are awesome.
2 commentaires
Réponse acceptée
Walter Roberson
le 25 Jan 2016
Hint: instead of using size(something==value) you can use sum(something==value)
Your code is counting some things multiple times. For example, a full house is counted but so is its value as 3 of a kind. Likewise, Chance should only apply if nothing else matched.
For 3 of a kind or 4 of a kind, you are using a score of sum(diceValues), which is not correct: you should be counting only the dice that match.
Your points array could be numeric instead of a cell array.
8 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!