yei

Dependencies:   interface mbed enc_1multi calPID motorout KondoServoLibrary

Fork of cat18_operate by Catch the GIANT Caplico!

Committer:
shimizuta
Date:
Mon Aug 27 03:47:21 2018 +0000
Revision:
20:13934809e117
Child:
23:f45eb02433a5
There are a lot of change

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimizuta 20:13934809e117 1 #include "calplace.h"
shimizuta 20:13934809e117 2 #include "mbed.h"
shimizuta 20:13934809e117 3 #include "debug.h"
shimizuta 20:13934809e117 4 #include "workinfo.h"
shimizuta 20:13934809e117 5 const int kFirstPutPlace = 9;//シューティングボックスで最初に置く場所
shimizuta 20:13934809e117 6 int CalPickPlace() //どれを取るのがいいか検索する
shimizuta 20:13934809e117 7 {
shimizuta 20:13934809e117 8 DEBUG("CalPickPlace() start\r\n");
shimizuta 20:13934809e117 9 int i;
shimizuta 20:13934809e117 10 int best=23;
shimizuta 20:13934809e117 11 //priorityの値を入れる
shimizuta 20:13934809e117 12 for(i=0; i<=22; i++) {
shimizuta 20:13934809e117 13 if(work[i].is_exist) {
shimizuta 20:13934809e117 14 if(work[i].priority<work[best].priority) {
shimizuta 20:13934809e117 15 best=i;
shimizuta 20:13934809e117 16 }
shimizuta 20:13934809e117 17 }
shimizuta 20:13934809e117 18 }
shimizuta 20:13934809e117 19 DEBUG("CalPickPlace() finish worknum %d\r\n", best);
shimizuta 20:13934809e117 20 return best;
shimizuta 20:13934809e117 21 }
shimizuta 20:13934809e117 22 //3つ同じ色が揃うよう置く場所を計算。
shimizuta 20:13934809e117 23 int CalPutPlace(Color workcolor)
shimizuta 20:13934809e117 24 {
shimizuta 20:13934809e117 25 DEBUG("CalPutPlace() start\r\n");
shimizuta 20:13934809e117 26 int is_finish = 0;
shimizuta 20:13934809e117 27 int num =kFirstPutPlace;
shimizuta 20:13934809e117 28 for(int j=0; j<4 && is_finish == 0; j++) {
shimizuta 20:13934809e117 29 for(int i=0; i<3 && is_finish == 0; i++) {
shimizuta 20:13934809e117 30 num = kFirstPutPlace - j * 3 +i;
shimizuta 20:13934809e117 31 if(!shootingbox[num].is_exist) is_finish = 1;
shimizuta 20:13934809e117 32 if(workcolor != shootingbox[num].color) break;
shimizuta 20:13934809e117 33 }
shimizuta 20:13934809e117 34 }
shimizuta 20:13934809e117 35 DEBUG("CalPutPlace() finish return %d\r\n", num);
shimizuta 20:13934809e117 36 return num;
shimizuta 20:13934809e117 37 }