Game in MATLAB?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nick Haufler
am 25 Jan. 2016
Kommentiert: Walter Roberson
am 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!