void moveTower (int num_of_disc, char start_axis, char end_axis, char tmp_axis) { if (1 == num_of_disc) { moveDisc(start_axis, end_axis); } else { moveTower (num_of_disc-1, start_axis, tmp_axis, end_axis); moveDisc (start_axis, end_axis); moveTower (num_of_disc-1, tmp_axis, end_axis, start_axis); } }
/**@brief Application main function. */ int main(void) { uint32_t err_code; bool erase_bonds; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); buttons_leds_init(&erase_bonds); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); gpio_init(); timer_init(); //timer task to refresh RGB LED Board game_init(); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { power_manage(); moveDisc(getInput()); } }
void poleTest() { pole pole1(7); pole pole2(0); pole pole3(0); poleDisplay(pole1, pole2, pole3); int move = 0; //1 move++; cout << "move " << move << endl; moveDisc(pole1, pole3); poleDisplay(pole1, pole2, pole3); //2 move++; cout << "move " << move << endl; moveDisc(pole1, pole2); poleDisplay(pole1, pole2, pole3); //3 move++; cout << "move " << move << endl; moveDisc(pole3, pole2); poleDisplay(pole1, pole2, pole3); //4 move++; cout << "move " << move << endl; moveDisc(pole1, pole3); poleDisplay(pole1, pole2, pole3); //5 move++; cout << "move " << move << endl; moveDisc(pole2, pole1); poleDisplay(pole1, pole2, pole3); //6 move++; cout << "move " << move << endl; moveDisc(pole2, pole3); poleDisplay(pole1, pole2, pole3); //7 move++; cout << "move " << move << endl; moveDisc(pole1, pole3); poleDisplay(pole1, pole2, pole3); }