Game in MATLAB?
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nick Haufler
il 25 Gen 2016
Commentato: Walter Roberson
il 27 Gen 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 Commenti
Risposta accettata
Walter Roberson
il 25 Gen 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 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!