2 * Copyright Droids, Microb Technology (2010)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: strat.c,v 1.6 2009-11-08 17:24:33 zer0 Exp $
20 * Olivier MATZ <zer0@droids-corp.org>
30 #include <aversive/pgmspace.h>
31 #include <aversive/error.h>
36 #include <clock_time.h>
41 #include <control_system_manager.h>
42 #include <trajectory_manager.h>
43 #include <trajectory_manager_utils.h>
44 #include <trajectory_manager_core.h>
45 #include <vect_base.h>
48 #include <obstacle_avoidance.h>
49 #include <blocking_detection_manager.h>
50 #include <robot_system.h>
51 #include <position_manager.h>
53 #include <diagnostic.h>
58 #include "../common/i2c_commands.h"
59 #include "i2c_protocol.h"
63 #include "strat_base.h"
64 #include "strat_corn.h"
65 #include "strat_avoid.h"
66 #include "strat_utils.h"
73 #define DPR(fmt, ...) printf_P(PSTR(fmt), ##__VA_ARGS__)
75 #define DPR(args...) do {} while (0)
81 const struct wp_coord *path;
84 const struct wp_coord butterfly_tab[] = {
109 { .i = 10, .j = 2, },
110 { .i = 11, .j = 1, },
111 { .i = 11, .j = 2, },
112 { .i = 11, .j = 3, },
113 { .i = 11, .j = 4, },
114 { .i = 11, .j = 5, },
115 { .i = 11, .j = 6, },
118 const struct circuit butterfly_circuit = {
120 .len = sizeof(butterfly_tab)/sizeof(struct wp_coord),
121 .path = butterfly_tab,
124 const struct wp_coord losange_tab[] = {
125 { .i = 11, .j = 6, },
126 { .i = 10, .j = 6, },
130 { .i = 10, .j = 4, },
131 { .i = 11, .j = 4, },
132 { .i = 11, .j = 5, },
133 { .i = 11, .j = 6, },
136 const struct circuit losange_circuit = {
138 .len = sizeof(losange_tab)/sizeof(struct wp_coord),
142 const struct wp_coord triangle_tab[] = {
143 { .i = 11, .j = 6, },
144 { .i = 10, .j = 6, },
152 { .i = 10, .j = 2, },
153 { .i = 11, .j = 1, },
154 { .i = 11, .j = 2, },
155 { .i = 11, .j = 3, },
156 { .i = 11, .j = 4, },
157 { .i = 11, .j = 5, },
158 { .i = 11, .j = 6, },
161 const struct circuit triangle_circuit = {
163 .len = sizeof(triangle_tab)/sizeof(struct wp_coord),
164 .path = triangle_tab,
167 const struct wp_coord answer_d_tab[] = {
168 { .i = 11, .j = 6, },
169 { .i = 11, .j = 5, },
170 { .i = 11, .j = 4, },
171 { .i = 11, .j = 3, },
172 { .i = 11, .j = 2, },
173 { .i = 11, .j = 1, },
174 { .i = 10, .j = 2, },
178 { .i = 10, .j = 4, },
179 { .i = 11, .j = 4, },
180 { .i = 11, .j = 5, },
181 { .i = 11, .j = 6, },
184 const struct circuit answer_d_circuit = {
186 .len = sizeof(answer_d_tab)/sizeof(struct wp_coord),
187 .path = answer_d_tab,
190 const struct wp_coord h_lambda_tab[] = {
191 { .i = 11, .j = 6, },
192 { .i = 10, .j = 6, },
205 { .i = 10, .j = 6, },
206 { .i = 11, .j = 6, },
209 const struct circuit h_lambda_circuit = {
211 .len = sizeof(h_lambda_tab)/sizeof(struct wp_coord),
212 .path = h_lambda_tab,
215 const struct wp_coord asym_butterfly_tab[] = {
216 { .i = 11, .j = 6, },
217 { .i = 10, .j = 6, },
234 { .i = 10, .j = 2, },
235 { .i = 11, .j = 1, },
236 { .i = 11, .j = 2, },
237 { .i = 11, .j = 3, },
238 { .i = 11, .j = 4, },
239 { .i = 11, .j = 5, },
240 { .i = 11, .j = 6, },
243 const struct circuit asym_butterfly_circuit = {
244 .name = "asym_butterfly",
245 .len = sizeof(asym_butterfly_tab)/sizeof(struct wp_coord),
246 .path = asym_butterfly_tab,
249 const struct wp_coord big_h_lambda_tab[] = {
250 { .i = 11, .j = 6, },
251 { .i = 10, .j = 6, },
274 { .i = 10, .j = 6, },
275 { .i = 11, .j = 6, },
278 const struct circuit big_h_lambda_circuit = {
279 .name = "big_h_lambda",
280 .len = sizeof(big_h_lambda_tab)/sizeof(struct wp_coord),
281 .path = big_h_lambda_tab,
284 const struct wp_coord letter_v_tab[] = {
285 { .i = 11, .j = 6, },
286 { .i = 10, .j = 6, },
306 { .i = 10, .j = 4, },
307 { .i = 11, .j = 4, },
308 { .i = 11, .j = 5, },
309 { .i = 11, .j = 6, },
312 const struct circuit letter_v_circuit = {
314 .len = sizeof(letter_v_tab)/sizeof(struct wp_coord),
315 .path = letter_v_tab,
318 /* list of all possible circuits */
319 const struct circuit *circuits[] = {
325 &asym_butterfly_circuit,
326 &big_h_lambda_circuit,
331 /* symetric neighbor position */
332 static inline uint8_t opposite_position(uint8_t pos)
341 //#define TEST_STRAT_AVOID
344 #ifdef TEST_STRAT_AVOID
346 uint8_t xget_cob_count(void)
352 uint8_t xget_ball_count(void)
358 uint8_t xtime_get_s(void)
363 #define xget_cob_count() get_cob_count()
364 #define xget_ball_count() get_ball_count()
365 #define xtime_get_s() time_get_s()
368 /* return true if turn is at 60 deg */
369 uint8_t is_60deg(uint8_t dir1, uint8_t dir2)
383 /* return true if turn is at 60 deg */
384 uint8_t is_120deg(uint8_t dir1, uint8_t dir2)
398 /* get the neighbour of the point at specified dir, return -1 if
399 * there is no neighbor */
400 int8_t wp_get_neigh(uint8_t i, uint8_t j, uint8_t *ni, uint8_t *nj,
429 if (i >= WAYPOINTS_NBX || j >= WAYPOINTS_NBY)
437 static uint8_t get_line_num(int8_t i, int8_t j, uint8_t dir)
458 static uint8_t get_dir(uint8_t prev_i, uint8_t prev_j,
459 uint8_t i, uint8_t j)
461 int8_t diff_i, diff_j;
466 if (diff_i == 0 && diff_j == 1)
468 if (diff_i == 0 && diff_j == -1)
471 if ((prev_i & 1) == 0) {
472 if (diff_i == 1 && diff_j == 0)
474 if (diff_i == 1 && diff_j == -1)
476 if (diff_i == -1 && diff_j == 0)
478 if (diff_i == -1 && diff_j == -1)
482 if (diff_i == 1 && diff_j == 1)
484 if (diff_i == 1 && diff_j == 0)
486 if (diff_i == -1 && diff_j == 1)
488 if (diff_i == -1 && diff_j == 0)
496 /* return true if a waypoint belongs to a line */
497 uint8_t wp_belongs_to_line(uint8_t i, uint8_t j, uint8_t linenum, uint8_t dir)
500 ln = get_line_num(i, j, dir);
506 /* count the number of non-black corns which are neighbors of
508 uint8_t corn_count_neigh(uint8_t i, uint8_t j)
513 for (dir = LINE_UP; dir <= LINE_R_UP; dir++) {
514 if (wp_get_neigh(i, j, &ni, &nj, dir) < 0)
517 /* is there a corn cob ? */
518 if (strat_db.wp_table[ni][nj].type == WP_TYPE_CORN &&
519 strat_db.wp_table[ni][nj].present &&
520 strat_db.wp_table[ni][nj].corn.color != I2C_COB_BLACK)
528 /* fill circuit_wpline table with waypoints from circuit starting at
529 * i,j and using selected face */
530 static int8_t get_path(const struct circuit *circuit,
531 uint8_t starti, uint8_t startj, uint8_t faceA,
532 struct wp_line *circuit_wpline)
534 const struct wp_coord *curcircuit;
535 const struct wp_coord *start;
536 const struct wp_coord *end;
537 uint8_t prev_i, prev_j;
538 uint8_t dir, prev_dir = 0xFF;
539 uint8_t found = 0, i = 0, j = 0;
541 int8_t step = faceA ? 1 : -1;
544 /* start and end of circuit */
546 start = &circuit->path[0];
547 end = start + circuit->len - 1;
550 end = &circuit->path[0];
551 start = end + circuit->len - 1;
554 DPR("%s(): %s face=%d\r\n", __FUNCTION__, circuit->name, faceA);
556 /* check that the point is present in the circuit */
557 for (curcircuit = start; curcircuit != end; curcircuit += step) {
558 if (curcircuit->i == starti && curcircuit->j == startj) {
567 /* browse the circuit from starti, startj in the specified
568 * direction, and fill the table when direction changes */
571 for ( ; curcircuit != end;
572 curcircuit += step, prev_dir = dir, prev_i = i, prev_j = j) {
577 dir = get_dir(prev_i, prev_j, i, j);
579 if (prev_dir != dir) {
580 linenum = get_line_num(prev_i, prev_j, dir);
581 circuit_wpline[path_len].line_num = linenum;
582 circuit_wpline[path_len].dir = dir;
583 DPR("%s(): %d %d -> %d %d / len=%d num=%d dir=%d\r\n",
584 __FUNCTION__, prev_i, prev_j, i, j, path_len, linenum, dir);
592 /* process score from retrieved objects number, and circuit len */
593 static int16_t get_score(uint32_t wcorn_retrieved,
594 uint32_t ucorn_retrieved,
595 uint16_t tomato_retrieved,
596 uint8_t len, uint8_t opp_on_path)
603 /* score with corn */
604 n = xget_cob_count() * 2;
605 for (i = 0; i<CORN_NB; i++) {
608 if (wcorn_retrieved & mask) {
614 if (ucorn_retrieved & mask) {
621 DPR("get score: cob %d (->%d)\r\n", n, n/2);
623 /* score with tomato */
624 n = xget_ball_count();
626 for (i = 0; i<TOMATO_NB; i++) {
629 if (tomato_retrieved & mask) {
636 DPR("get score: ball %d\r\n", n);
638 /* malus for long circuits */
640 DPR("malus for length: %d\r\n", len * 20);
642 /* double malus for long circuits if we don't have much
645 if (len * WP_SPEED > (MATCH_TIME - xtime_get_s())) {
647 extra = (len * WP_SPEED) - (MATCH_TIME - xtime_get_s());
648 extra = (200 * extra);
649 if (extra < 0) /* should not happen */
654 DPR("malus for length + time: %d\r\n", extra);
657 /* malus if there is opponent on the path */
659 DPR("malus for opponent: 1000\r\n");
666 /* return the corn type of specified coords: I2C_COB_WHITE,
667 * I2C_COB_UNKNOWN, or I2C_COB_NONE if it is black or not present */
668 static uint8_t get_corn_type(uint8_t i, uint8_t j)
671 /* is there a corn cob ? */
672 if (strat_db.wp_table[i][j].type == WP_TYPE_CORN &&
673 strat_db.wp_table[i][j].present) {
674 color = strat_db.wp_table[i][j].corn.color;
675 if (color == I2C_COB_WHITE)
676 return I2C_COB_WHITE;
677 else if (color == I2C_COB_UNKNOWN)
678 return I2C_COB_UNKNOWN;
683 /* i,j: starting position */
684 static int8_t evaluate_one_face(const struct circuit *circuit,
685 uint8_t starti, uint8_t startj,
686 uint8_t faceA, int16_t *score)
688 const struct wp_coord *curcircuit;
689 const struct wp_coord *start;
690 const struct wp_coord *end;
691 uint32_t wcorn_retrieved = 0; /* bit mask */
692 uint32_t ucorn_retrieved = 0; /* bit mask */
693 uint16_t tomato_retrieved = 0; /* bit mask */
694 uint8_t opponent_on_path = 0;
695 uint8_t len = 0, found = 0;
696 uint8_t i, j, prev_i, prev_j;
697 uint8_t ni = 0, nj = 0;
698 uint8_t dir, color, idx;
699 int8_t step = faceA ? 1 : -1;
700 int16_t x, y, d, prev_d = 0;
703 *score = 0x8000; /* -int_max */
705 /* start and end of circuit */
707 start = &circuit->path[0];
708 end = start + circuit->len - 1;
711 end = &circuit->path[0];
712 start = end + circuit->len - 1;
715 DPR("%s() face: %s %d\r\n", __FUNCTION__, circuit->name, faceA);
717 /* check that the point is present in the circuit */
718 for (curcircuit = start; curcircuit != end; curcircuit += step) {
719 if (curcircuit->i == starti && curcircuit->j == startj) {
727 /* get opponent coords */
728 if (get_opponent_xy(&oppx, &oppy) < 0)
729 oppx = I2C_OPPONENT_NOT_THERE;
731 DPR("%s() opponent: %d, %d\r\n", __FUNCTION__, oppx, oppy);
733 /* silent the compiler */
737 /* browse all points and calculate the score */
738 for (; /* start at starti,startj */
740 curcircuit += step, len ++, prev_i = i, prev_j = j) {
744 /* is opponent near the point ? */
745 ijcoord_to_xycoord(i, j, &x, &y);
746 if (oppx != I2C_OPPONENT_NOT_THERE) {
747 d = distance_between(oppx, oppy, x, y);
748 DPR("%s(): opp at %d mm (ij=%d,%d opp=%d,%d pos=%d,%d)\r\n",
749 __FUNCTION__, d, i, j, oppx, oppy, x, y);
750 if (d < 600 && d < prev_d)
751 opponent_on_path = 1;
755 /* don't try to look cobs/tomato for first point */
756 if (curcircuit == start)
759 /* get current direction, we wil check cobs behind us
760 * on left and right */
761 dir = get_dir(prev_i, prev_j, i, j);
763 DPR("%d %d -> %d %d (%d)\n", prev_i, prev_j, i, j, dir);
765 /* is there a tomato ? */
766 if (strat_db.wp_table[i][j].type == WP_TYPE_TOMATO &&
767 strat_db.wp_table[i][j].present) {
769 tomato_retrieved |= (1UL << strat_db.wp_table[i][j].tomato.idx);
773 if (wp_get_neigh(i, j, &ni, &nj, (dir + 2) % 6) == 0) {
774 color = get_corn_type(ni, nj);
775 idx = strat_db.wp_table[ni][nj].corn.idx;
776 if (color == I2C_COB_WHITE) {
777 DPR(" LEFT WCORN (%d)\n", idx);
778 wcorn_retrieved |= (1UL << idx);
780 else if (color == I2C_COB_UNKNOWN) {
781 DPR(" LEFT UCORN (%d)\n", idx);
782 ucorn_retrieved |= (1UL << idx);
787 if (wp_get_neigh(i, j, &ni, &nj, (dir + 4) % 6) == 0) {
788 color = get_corn_type(ni, nj);
789 idx = strat_db.wp_table[ni][nj].corn.idx;
790 if (color == I2C_COB_WHITE) {
791 DPR(" RIGHT WCORN (%d)\n", idx);
792 wcorn_retrieved |= (1UL << idx);
794 else if (color == I2C_COB_UNKNOWN) {
795 DPR(" RIGHT UCORN (%d)\n", idx);
796 ucorn_retrieved |= (1UL << idx);
800 /* prev_i, prev_j, len and curcircuit are updated in
804 /* write score and exit */
805 *score = get_score(wcorn_retrieved, ucorn_retrieved,
806 tomato_retrieved, len, opponent_on_path);
810 /* i,j: starting position */
811 static int8_t evaluate_one_circuit(const struct circuit *circuit,
812 uint8_t starti, uint8_t startj,
813 int16_t *scoreA, int16_t *scoreB)
815 if (evaluate_one_face(circuit, starti, startj, 1, scoreA) < 0)
818 /* we are on eject point, scoreB is the same */
819 if (starti == 11 && startj == 6) {
824 if (evaluate_one_face(circuit, starti, startj, 0, scoreB) < 0)
829 /* i,j starting position */
830 static int8_t find_best_circuit(uint8_t i, uint8_t j,
831 const struct circuit **selected_circuit,
832 int8_t *selected_face)
834 const struct circuit **circuit;
835 int16_t scoreA, scoreB;
836 int16_t selected_score = 0x8000; /* ~-int_max */
840 *selected_circuit = circuits[0] ;
841 for (circuit = &circuits[0]; *circuit; circuit++) {
842 if (evaluate_one_circuit(*circuit, i, j, &scoreA, &scoreB) < 0)
845 DEBUG(E_USER_STRAT, "Scores for %s are: faceA=%d, faceB=%d",
846 (*circuit)->name, scoreA, scoreB);
847 if (scoreA > selected_score) {
848 *selected_circuit = *circuit;
849 selected_score = scoreA;
852 if (scoreB > selected_score) {
853 *selected_circuit = *circuit;
854 selected_score = scoreB;
860 DEBUG(E_USER_STRAT, "no circuit found");
862 DEBUG(E_USER_STRAT, "circuit found: %s, %s",
863 (*selected_circuit)->name,
864 (*selected_face) ? "faceA":"faceB");
868 static void test_all_circuits(void)
870 const struct circuit **circuit;
871 const struct wp_coord *cur;
872 const struct wp_coord *start;
873 const struct wp_coord *end;
874 uint8_t prev_i, prev_j, i, j, dir;
876 for (circuit = &circuits[0]; *circuit; circuit++) {
877 start = &(*circuit)->path[0];
878 end = start + (*circuit)->len - 1;
884 for (cur = start; cur != end;
885 cur ++, prev_i = i, prev_j = j) {
890 dir = get_dir(prev_i, prev_j, i, j);
892 printf_P("Bad circuit %s %d %d\r\n", (*circuit)->name, i, j);
898 static void dump_circuit_wp(struct wp_line *circuit_wpline, int8_t len)
903 for (i = 0; i < len; i ++) {
904 DEBUG(E_USER_STRAT, "linenum %d dir %d",
905 circuit_wpline[i].line_num,
906 circuit_wpline[i].dir);
911 /* choose a circuit, then harvest on this circuit */
912 uint8_t strat_harvest_circuit(void)
914 const struct circuit *selected_circuit;
915 int8_t selected_face;
916 struct wp_line circuit_wpline[MAX_CIRCUIT_WPLINE];
920 uint8_t linenum, prev_linenum;
921 uint8_t dir, prev_dir;
924 strat_set_speed(SPEED_CLITOID_SLOW, SPEED_ANGLE_SLOW);
926 x = position_get_x_s16(&mainboard.pos);
927 y = position_get_y_s16(&mainboard.pos);
929 if (xycoord_to_ijcoord(&x, &y, &i, &j) < 0) {
930 DEBUG(E_USER_STRAT, "%s(): cannot find waypoint at %d,%d",
935 if (find_best_circuit(i, j, &selected_circuit, &selected_face) < 0) {
936 DEBUG(E_USER_STRAT, "%s(): cannot find a good circuit",
941 len = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
943 DEBUG(E_USER_STRAT, "%s(): cannot find a path",
948 dump_circuit_wp(circuit_wpline, len);
950 prev_linenum = circuit_wpline[0].line_num;
951 prev_dir = circuit_wpline[0].dir;
953 /* do all lines of circuit */
954 for (idx = 1; idx < len; idx ++) {
955 linenum = circuit_wpline[idx].line_num;
956 dir = circuit_wpline[idx].dir;
958 DEBUG(E_USER_STRAT, "%s(): line %d dir %d -> line %d dir %d",
959 __FUNCTION__, prev_linenum, prev_dir, linenum, dir);
960 err = line2line(prev_linenum, prev_dir, linenum, dir,
962 if (!TRAJ_SUCCESS(err))
965 prev_linenum = linenum;
972 /* try to unblock in any situation */
973 uint8_t strat_unblock(void)
977 uint16_t old_dspeed, old_aspeed;
980 DEBUG(E_USER_STRAT, "%s()", __FUNCTION__);
983 strat_get_speed(&old_dspeed, &old_aspeed);
986 strat_set_speed(SPEED_DIST_SLOW, SPEED_ANGLE_SLOW);
987 x = position_get_x_s16(&mainboard.pos);
988 y = position_get_y_s16(&mainboard.pos);
989 if (xycoord_to_ijcoord(&x, &y, &i, &j) < 0) {
990 /* aie... go to center... but it's really a bad
996 /* XXX if opponent is too close, go back, or wait ? */
998 /* go to nearest waypoint */
999 trajectory_goto_xy_abs(&mainboard.traj, x, y);
1000 err = wait_traj_end(TRAJ_FLAGS_NO_NEAR);
1001 if (err == END_TIMER)
1004 if (!TRAJ_SUCCESS(err))
1007 strat_set_speed(old_dspeed, old_aspeed);
1008 strat_want_pack = 0;
1012 void test_strat_avoid(void)
1014 test_all_circuits();
1016 #ifdef TEST_STRAT_AVOID
1018 const struct circuit *selected_circuit;
1019 int8_t selected_face;
1020 struct wp_line circuit_wpline[MAX_CIRCUIT_WPLINE];
1024 printf_P(PSTR("========= i=%d, j=%d\r\n"), i, j);
1026 ts = 0; bc = 0; cc = 0;
1027 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1028 find_best_circuit(i, j, &selected_circuit, &selected_face);
1029 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1030 dump_circuit_wp(circuit_wpline, ret);
1032 ts = 0; bc = 3; cc = 0;
1033 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1034 find_best_circuit(i, j, &selected_circuit, &selected_face);
1035 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1036 dump_circuit_wp(circuit_wpline, ret);
1038 ts = 0; bc = 4; cc = 0;
1039 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1040 find_best_circuit(i, j, &selected_circuit, &selected_face);
1041 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1042 dump_circuit_wp(circuit_wpline, ret);
1044 ts = 0; bc = 3; cc = 5;
1045 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1046 find_best_circuit(i, j, &selected_circuit, &selected_face);
1047 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1048 dump_circuit_wp(circuit_wpline, ret);
1050 ts = 0; bc = 4; cc = 5;
1051 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1052 find_best_circuit(i, j, &selected_circuit, &selected_face);
1053 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1054 dump_circuit_wp(circuit_wpline, ret);
1056 ts = 80; bc = 0; cc = 0;
1057 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1058 find_best_circuit(i, j, &selected_circuit, &selected_face);
1059 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1060 dump_circuit_wp(circuit_wpline, ret);
1063 printf_P(PSTR("========= i=%d, j=%d\r\n"), i, j);
1065 ts = 0; bc = 0; cc = 0;
1066 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1067 find_best_circuit(i, j, &selected_circuit, &selected_face);
1068 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1069 dump_circuit_wp(circuit_wpline, ret);
1071 ts = 0; bc = 3; cc = 0;
1072 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1073 find_best_circuit(i, j, &selected_circuit, &selected_face);
1074 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1075 dump_circuit_wp(circuit_wpline, ret);
1077 ts = 80; bc = 0; cc = 0;
1078 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1079 find_best_circuit(i, j, &selected_circuit, &selected_face);
1080 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1081 dump_circuit_wp(circuit_wpline, ret);
1084 printf_P(PSTR("========= i=%d, j=%d\r\n"), i, j);
1086 ts = 0; bc = 0; cc = 0;
1087 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1088 find_best_circuit(i, j, &selected_circuit, &selected_face);
1089 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1090 dump_circuit_wp(circuit_wpline, ret);
1092 ts = 0; bc = 3; cc = 0;
1093 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1094 find_best_circuit(i, j, &selected_circuit, &selected_face);
1095 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1096 dump_circuit_wp(circuit_wpline, ret);
1098 ts = 80; bc = 0; cc = 0;
1099 printf_P(PSTR("=== time=%"PRIu32", ball=%d, corn=%d\r\n"), ts, bc, cc);
1100 find_best_circuit(i, j, &selected_circuit, &selected_face);
1101 ret = get_path(selected_circuit, i, j, selected_face, circuit_wpline);
1102 dump_circuit_wp(circuit_wpline, ret);