Quick simple way. In the code where enemy AI reacts to user’s punch; generate a random number, and if the number is < then a certain value, then dodge the punch, otherwise tell the AI to take the punch.
local reactFlag = (math.random(10) < 8)
if reactFlag == true then
– dodge the punch
else
– take the hit
end
Once the AI unit is tired or injured you can reduce the number 8 down to maybe 5, then the AI is at a 50/50 chance to wether it will dodge the punch. These are very arbitrary numbers. Use whatever range you want.
Of course to make it more human you can adjust for wether the punch is a left or right and change the 8 up or down, where AI may be more likely to block the right handed punches, or maybe more likely to dodge a certain type of punch. I like adjusting for fatigue or injury. That will give it more human feel.
Clearly AI, is a lot more complex then this. But this should get you going down the right path.
Good luck.