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@5:210cd333f770, 2014-04-30 (annotated)
- Committer:
- Strikewolf
- Date:
- Wed Apr 30 05:53:51 2014 +0000
- Revision:
- 5:210cd333f770
- Child:
- 6:3fb9f96765f6
works without any motors
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Strikewolf | 5:210cd333f770 | 1 | #define THRESHOLD 500 |
Strikewolf | 5:210cd333f770 | 2 | |
Strikewolf | 5:210cd333f770 | 3 | Serial pc(USBTX, USBRX); |
Strikewolf | 5:210cd333f770 | 4 | |
Strikewolf | 5:210cd333f770 | 5 | bool gameOver = false; |
Strikewolf | 5:210cd333f770 | 6 | |
Strikewolf | 5:210cd333f770 | 7 | bool isGameOver(double x_hum, double y_hum, double x_cpu, double y_cpu) |
Strikewolf | 5:210cd333f770 | 8 | { |
Strikewolf | 5:210cd333f770 | 9 | pc.printf("AI:(%f, %f), HUM: (%f, %f)\n\r", x_cpu, y_cpu, x_hum, y_hum); |
Strikewolf | 5:210cd333f770 | 10 | if(abs(x_hum - x_cpu) < THRESHOLD && abs(y_hum - y_cpu) < THRESHOLD) { |
Strikewolf | 5:210cd333f770 | 11 | return true; |
Strikewolf | 5:210cd333f770 | 12 | } else { |
Strikewolf | 5:210cd333f770 | 13 | return false; |
Strikewolf | 5:210cd333f770 | 14 | } |
Strikewolf | 5:210cd333f770 | 15 | } |
Strikewolf | 5:210cd333f770 | 16 | |
Strikewolf | 5:210cd333f770 | 17 | void endGame() |
Strikewolf | 5:210cd333f770 | 18 | { |
Strikewolf | 5:210cd333f770 | 19 | pc.printf("GAME OVER\n\r"); |
Strikewolf | 5:210cd333f770 | 20 | exit(1); |
Strikewolf | 5:210cd333f770 | 21 | } |