I'm making a simple dice-game with matlab and I(adsbygoogle = window.adsbygoogle || []).push({});

want to extend the functions of it. What I have now is

that I throw 5 dices (each dice gives a value of 1 to

6), and I make matlab display the value of each dice,

e.g [1 3 5 2 1] and count how many of each value are

represented e.g in my case we have 2 ones, 1 twos, 1

threes, 0 fours, 1 fives, 0 sixes, that outputs the

vector [2 1 1 0 1 0]. The script-code used for the

above function is:

dices= ceil(6*rand(5,1));

disp(dices); % displaying dices

count = hist(dices, [1,2,3,4,5,6]); % calculating

counts

disp(count); % displaying counts

OK, here are some functions I want add to the program:

#1) I want display through one digit the value that is

most represented. e.g from the dice-throw [4 5 4 4 1]

the output should be 4.

#2) According to the game strategy you should save the

identical dices and throw the rest over again.OK,

that means that I need code that outputs, in my case

above, the vector [2 5], i.e dice number 2 and 5. If

we have a more complex situation [4 4 2 2 5], then we

an output: [1 2 5] or [3 4 5]; or according to an

other fashion: [* * 2 2 *] or [4 4 * * *].

#3) OK, I want to repeat this procedure until all

dices are of the same value, e.g all 4:s. And I want

as a final output the number of throws that were

needed to get five dices of the same value.

/Thomas

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Simple help with matlab-dice game needed

Loading...

Similar Threads for Simple help matlab | Date |
---|---|

Help needed in MATLAB , Please ( Simple question ) | Sep 19, 2012 |

Matrix help in MatLab, Not the simple matrix I have searched, found nothing! | Feb 23, 2012 |

Simple matlab interpolation help | Dec 26, 2011 |

MATLAB: Embarrassingly Simple Help Needed | Jul 7, 2011 |

Simple MATLAB help | Jun 5, 2011 |

**Physics Forums - The Fusion of Science and Community**