An implementation of the 70's novelty prognosticator. Based on "why.m".
Scott Copeland (2021). Magic 8 Ball (https://www.mathworks.com/matlabcentral/fileexchange/1452-magic-8-ball), MATLAB Central File Exchange. Retrieved .
This implementation cannot generate the final state, "Very doubtful." . rand() can never exactly equal 0 or 1, so 20*rand() can never exactly equal 0 or 20. fix() rounds towards 0, breaking up into (0, 1-eps], [1, 2*(1-eps)], [2, 3*(1-eps)], [3, 4*(1-eps)] and so on up to [19, 20*(1-eps)] with that [19, 20*(1-eps)] mapping to 19. There is no possibility of fix(20*rand) mapping to 20 because 20*rand can never be greater than 20 and rand cannot exactly equal 1 so 20*rand < 20 always. Therefore the otherwise case can never be encountered and so "Very doubtful" cannot be generated.
That said, there are 20 states 0 to 19 that can be generated, and the official Magic 8 Ball only has 20 responses, so it is more an issue that the reader might be misled into thinking "Very doubtful" could potentially be generated rather than there being a malfunction in the code.
thank you it is cool
Just take a look at the code.
Outstanding game... ;)
It works great, till you open the source code. Breaking up the "Magic 8 Ball" to see how it works is not quite a turn-on. Agree?
I would be gald to your client
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!