yei

Dependencies:   interface mbed enc_1multi calPID motorout KondoServoLibrary

Fork of cat18_operate by Catch the GIANT Caplico!

Committer:
yuto17320508
Date:
Sun Sep 09 00:18:39 2018 +0000
Revision:
45:51ab3ca47228
Parent:
23:f45eb02433a5
a;

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 23:f45eb02433a5 15 if(shootingbox[kFirstPutPlace].is_exist == 1 || work[i].areaname == WORKAREA) {
shimizuta 23:f45eb02433a5 16 best=i;
shimizuta 23:f45eb02433a5 17 }
shimizuta 20:13934809e117 18 }
shimizuta 20:13934809e117 19 }
shimizuta 20:13934809e117 20 }
shimizuta 23:f45eb02433a5 21 DEBUG("CalPickPlace() return worknum %d\r\n", best);
shimizuta 20:13934809e117 22 return best;
shimizuta 20:13934809e117 23 }
shimizuta 20:13934809e117 24 //3つ同じ色が揃うよう置く場所を計算。
shimizuta 20:13934809e117 25 int CalPutPlace(Color workcolor)
shimizuta 20:13934809e117 26 {
shimizuta 20:13934809e117 27 DEBUG("CalPutPlace() start\r\n");
shimizuta 20:13934809e117 28 int is_finish = 0;
shimizuta 20:13934809e117 29 int num =kFirstPutPlace;
shimizuta 20:13934809e117 30 for(int j=0; j<4 && is_finish == 0; j++) {
shimizuta 20:13934809e117 31 for(int i=0; i<3 && is_finish == 0; i++) {
shimizuta 20:13934809e117 32 num = kFirstPutPlace - j * 3 +i;
shimizuta 20:13934809e117 33 if(!shootingbox[num].is_exist) is_finish = 1;
shimizuta 20:13934809e117 34 if(workcolor != shootingbox[num].color) break;
shimizuta 20:13934809e117 35 }
shimizuta 20:13934809e117 36 }
shimizuta 23:f45eb02433a5 37 DEBUG("CalPutPlace() return return %d\r\n", num);
shimizuta 20:13934809e117 38 return num;
shimizuta 20:13934809e117 39 }