yei
Dependencies: interface mbed enc_1multi calPID motorout KondoServoLibrary
Fork of cat18_operate by
Diff: calplace/calplace.cpp
- Revision:
- 20:13934809e117
- Child:
- 23:f45eb02433a5
diff -r 48c3af917932 -r 13934809e117 calplace/calplace.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/calplace/calplace.cpp Mon Aug 27 03:47:21 2018 +0000 @@ -0,0 +1,37 @@ +#include "calplace.h" +#include "mbed.h" +#include "debug.h" +#include "workinfo.h" +const int kFirstPutPlace = 9;//シューティングボックスで最初に置く場所 +int CalPickPlace() //どれを取るのがいいか検索する +{ + DEBUG("CalPickPlace() start\r\n"); + int i; + int best=23; + //priorityの値を入れる + for(i=0; i<=22; i++) { + if(work[i].is_exist) { + if(work[i].priority<work[best].priority) { + best=i; + } + } + } + DEBUG("CalPickPlace() finish worknum %d\r\n", best); + return best; +} +//3つ同じ色が揃うよう置く場所を計算。 +int CalPutPlace(Color workcolor) +{ + DEBUG("CalPutPlace() start\r\n"); + int is_finish = 0; + int num =kFirstPutPlace; + for(int j=0; j<4 && is_finish == 0; j++) { + for(int i=0; i<3 && is_finish == 0; i++) { + num = kFirstPutPlace - j * 3 +i; + if(!shootingbox[num].is_exist) is_finish = 1; + if(workcolor != shootingbox[num].color) break; + } + } + DEBUG("CalPutPlace() finish return %d\r\n", num); + return num; +} \ No newline at end of file