This is the Mexican Standoff prototype made by Francisco Martin and Andrew Smith. Please refer to the following link for instructions on hardware hookup: https://developer.mbed.org/users/fomartin/notebook/mexican-standoff-reaction-game/
Dependencies: SDFileSystem mbed-rtos mbed wave_player 4DGL-uLCD-SE PinDetect
CPU.cpp
- Committer:
- fomartin
- Date:
- 2016-03-14
- Revision:
- 2:3c1a5079243d
- Parent:
- 0:75716bd37804
File content as of revision 2:3c1a5079243d:
#include "States.h" #include <stdlib.h> #include <time.h> #include <float.h> CPU::CPU() { difficulty = 1; srand(time(NULL)); } CPU::CPU(int cpu_difficulty) { difficulty = cpu_difficulty; srand(time(NULL)); } float CPU::shootTime() { int randNumber = rand() % 10; float answer = (rand() % 10 + 1) / 10.0f; return answer / (float) difficulty; } bool CPU::shootAnswer(Prompt correctAnswer) { if(correctAnswer == Down || correctAnswer == Up) { int randNumber = rand() % 10; if(randNumber == 9) return false; } return true; }