Spring 2014, ECE 4180 project, Georgia Institute of Technolgoy. This is the human driver (RF controller) program for the Robotics Cat and Mouse program.
Dependencies: ADXL345_I2C_NEST HMC6352 IMUfilter ITG3200_NEST USBHost mbed-rtos mbed
Fork of Project by
GameCode.h@6:3fb9f96765f6, 2014-04-30 (annotated)
- Committer:
- Strikewolf
- Date:
- Wed Apr 30 12:23:04 2014 +0000
- Revision:
- 6:3fb9f96765f6
- Parent:
- 5:210cd333f770
Final product before demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Strikewolf | 6:3fb9f96765f6 | 1 | #define THRESHOLD 1000 |
Strikewolf | 5:210cd333f770 | 2 | |
Strikewolf | 5:210cd333f770 | 3 | Serial pc(USBTX, USBRX); |
Strikewolf | 6:3fb9f96765f6 | 4 | void stop(); |
Strikewolf | 5:210cd333f770 | 5 | |
Strikewolf | 5:210cd333f770 | 6 | bool gameOver = false; |
Strikewolf | 5:210cd333f770 | 7 | |
Strikewolf | 5:210cd333f770 | 8 | bool isGameOver(double x_hum, double y_hum, double x_cpu, double y_cpu) |
Strikewolf | 5:210cd333f770 | 9 | { |
Strikewolf | 5:210cd333f770 | 10 | pc.printf("AI:(%f, %f), HUM: (%f, %f)\n\r", x_cpu, y_cpu, x_hum, y_hum); |
Strikewolf | 5:210cd333f770 | 11 | if(abs(x_hum - x_cpu) < THRESHOLD && abs(y_hum - y_cpu) < THRESHOLD) { |
Strikewolf | 5:210cd333f770 | 12 | return true; |
Strikewolf | 5:210cd333f770 | 13 | } else { |
Strikewolf | 5:210cd333f770 | 14 | return false; |
Strikewolf | 5:210cd333f770 | 15 | } |
Strikewolf | 5:210cd333f770 | 16 | } |
Strikewolf | 5:210cd333f770 | 17 | |
Strikewolf | 5:210cd333f770 | 18 | void endGame() |
Strikewolf | 5:210cd333f770 | 19 | { |
Strikewolf | 5:210cd333f770 | 20 | pc.printf("GAME OVER\n\r"); |
Strikewolf | 6:3fb9f96765f6 | 21 | stop(); |
Strikewolf | 5:210cd333f770 | 22 | exit(1); |
Strikewolf | 5:210cd333f770 | 23 | } |