void turn_left(int degree){
	pen_up();
	_delay_ms(100);
	move_straight(245,1);
	left_degrees(degree);
	move_straight(245,0);
	_delay_ms(100);
	pen_down();
}
//Main function
int main(void)
{
	//Initialize value array with 0
	int i;
	for(i=0;i<1000;i++){
		val_array[i] = 0;
	}
	
	data_pos = 0;
	bot_pos = 0;
	
	init_devices();

	//LCD_Reset_4bit();
	lcd_cursor(2,1);
	lcd_string("DRAWOID");
	
	while(1){
		if (bot_pos < data_pos){
			lcd_print(1,9,val_array[bot_pos],3);
			lcd_cursor(1,1);
			if (mov_array[bot_pos] == 'F'){
				lcd_string("F");
				move_straight(val_array[bot_pos],1);
			}
			else if (mov_array[bot_pos] == 'B'){
				lcd_string("B");
				move_straight(val_array[bot_pos],0);
			}
			else if (mov_array[bot_pos] == 'R'){
				lcd_string("R");
				turn_right(val_array[bot_pos]);
			}
			else if (mov_array[bot_pos] == 'L'){
				lcd_string("L");
				turn_left(val_array[bot_pos]);
			}
			else if (mov_array[bot_pos] == 'U'){
				lcd_string("U");
				pen_up();
			}
			else if (mov_array[bot_pos] == 'D'){
				lcd_string("D");
				pen_down();
			}
			bot_pos++;
			_delay_ms(1000);
		}
	}

	return 0;
}
Exemplo n.º 3
0
void Rook::next_step(CM::Board<short int> *chess_board,
		int x,int y,Tim::vector<CM::Step> &next_step,int player){
	if(!bound_check(x,y)){
		CM::Step cur_step;
		cur_step.add_move(x,y,0,-1);
		cur_step.add_move(0,0,player*type,1);
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				if(chess_board->get(i,j)==0){
					cur_step.moves[1].x=i;
					cur_step.moves[1].y=j;
					next_step.push_back(cur_step);
				}
			}
		}
		return;
	}

	move_straight(chess_board,x,y,1,0,player,next_step);
	move_straight(chess_board,x,y,-1,0,player,next_step);
	move_straight(chess_board,x,y,0,1,player,next_step);
	move_straight(chess_board,x,y,0,-1,player,next_step);
}