- 追加された行はこの色です。
- 削除された行はこの色です。
[[2011a]]
#define R OUT_A
#define L OUT_C
#define SLIDE OUT_B
#define RL SENSOR_1
#define LL SENSOR_3
#define NINETY 10
#define isWhite <40
#define isBlack >40
#define ANGLE 10
#define GOAL 500
void go_straight(){
OnFwd (R+L);
}
void go_straight_s(){
OnFwd (R+L);
Off (R+L);
Wait (1);
}
void go_back(){
OnRev (R+L);
}
void go_back_s(){
OnRev (R+L);
Off(R+L);
Wait(1);
}
void tr(){
OnFwd (L);
OnRev (R);
Off (R+L);
Wait (1);
}
void tl(){
OnFwd (R);
OnRev (L);
Off (R+L);
Wait (1);
}
void stop_moving(){
Off (R+L);
Wait (100);
}
void out(){
OnFwd (SLIDE);
Wait (50);
Off (SLIDE);
}
void set_in(){
OnRev (SLIDE);
Wait (50);
Off (SLIDE);
}
task main (){
SetSensor (RL, SENSOR_LIGHT);
SetSensor (LL, SENSOR_LIGHT);
int blackline = 0;
while (1){
go_straight_s();
if (blackline >= 2) break;
if (RL isBlack && LL isBlack){
PlaySound (SOUND_CLICK);
blackline++;
while (RL isBlack || LL isBlack) go_straight_s();
}
}
stop_moving();
PlaySound (SOUND_CLICK);
OnRev(R+L);
Wait(5);
Off (R+L);
OnFwd(R);
OnRev(L);
Wait(20);
Off (R+L);
while (1){
if (RL isBlack && LL isBlack) break;
if (RL isWhite && LL isWhite) {
go_back_s();
} else if (RL isBlack && LL isWhite) {
tr();
} else if (RL isWhite && LL isBlack) {
tl();
}
}
PlaySound(SOUND_UP);
while (1){
stop_moving();
SendMessage (1);
tl();
Wait (NINETY);
stop_moving();
Wait (300);
tr();
Wait (70);
go_straight_s();
Wait (GOAL);
stop_moving();
out();
set_in();
go_back();
Wait (GOAL);
tl();
Wait (ANGLE);
Wait (ANGLE);
stop_moving();
}
}