File Exchange

image thumbnail

Magic 8 Ball

version 1.0.0.0 (796 Bytes) by Scott Copeland
70's novelty

1 Download

Updated 04 Mar 2002

No License

Editor's Note: This file was a File Exchange Pick of the Week

An implementation of the 70's novelty prognosticator. Based on "why.m".

Cite As

Scott Copeland (2020). Magic 8 Ball (https://www.mathworks.com/matlabcentral/fileexchange/1452-magic-8-ball), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

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.

Connor Young

thank you it is cool

elgorani naoufal

Roman Akulov

Just take a look at the code.
Outstanding game... ;)

Kerby Chan

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?

Liz George

I would be gald to your client

MATLAB Release Compatibility
Created with R12.1
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories