Time for action – programming fallibility

Time for action – programming fallibility

As we've discovered in the other games we've built, if the human player ain't happy, ain't nobody happy. We need to tweak the code so that our hideously perfect computer intellect makes mistakes every so often. But how do you program fallibility, an excruciatingly human trait, into the cold, unerring calculations of an unfeeling computer?

Well, you just throw some dice around.

By grabbing a random number as a success condition at each step of the computer's "thinking", we can simulate an error in judgment where the computer makes a "mistake".

Set the square variable to null off the top of the ComputerTakeATurn ...

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.