fork download
  1. #include <stdio.h>
  2.  
  3. #define BALL_DETECT 450
  4. #define WHITE_LINE 800
  5.  
  6. // ダミー関数
  7. void move(int left, int right)
  8. {
  9. printf("move(%d, %d)\n", left, right);
  10. }
  11.  
  12. void kick()
  13. {
  14. printf("kick!\n");
  15. }
  16.  
  17. int main()
  18. {
  19. int ball_right = 500;
  20. int ball_center = 300;
  21. int ball_left = 700;
  22. int range = 460;
  23.  
  24. int floor_left = 200;
  25. int floor_right = 300;
  26.  
  27. // 白線回避
  28. if (floor_left > WHITE_LINE || floor_right > WHITE_LINE)
  29. {
  30. move(-50, -50);
  31. move(-50, 50);
  32. return 0;
  33. }
  34.  
  35. // 左
  36. if (ball_left > ball_center &&
  37. ball_left > ball_right &&
  38. ball_left > BALL_DETECT)
  39. {
  40. move(-30, 30);
  41. }
  42.  
  43. // 右
  44. else if (ball_right > ball_center &&
  45. ball_right > ball_left &&
  46. ball_right > BALL_DETECT)
  47. {
  48. move(30, -30);
  49. }
  50.  
  51. // 正面
  52. else if (ball_center > BALL_DETECT)
  53. {
  54. move(50, 50);
  55.  
  56. if (range > 450)
  57. {
  58. kick();
  59. }
  60. }
  61.  
  62. // 見失い
  63. else
  64. {
  65. move(30, -30);
  66. }
  67.  
  68. return 0;
  69. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
move(-30, 30)