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
function, and then add in a few dice throws:
function ComputerTakeATurn() { var square:GameObject = null; if(Random.value > 0.5f) square = WinOrBlock(); if(square == null && Random.value > 0.5f) square = PreventOrCreateTrap(); if(square == null && Random.value > 0.5f) square = GetCentre(); if(square == null ...