Hello,
My rover is supposed to explore the entire field independently and circle the hills in the process. The area to be explored is with border hills. My problem is that when the rover hits the boundary hill when it comes back from the right side it turns left even though the code says it should turn right.
The code of the rover is right below. I hope you can help me.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | public void act() { var fahrtrichtung = "links" ; if (!huegelVorhanden( "vorne" ) && !grenzHuegelVorhanden( "vorne" )) { fahre(); } else if (huegelVorhanden( "vorne" )) { if (fahrtrichtung == "rechts" ) { drehe( "links" ); fahre(); drehe( "rechts" ); fahre(); fahre(); drehe( "rechts" ); fahre(); drehe( "links" ); } else if (fahrtrichtung == "links" ) { drehe( "rechts" ); fahre(); drehe( "links" ); fahre(); fahre(); drehe( "links" ); fahre(); drehe( "rechts" ); } } else if (grenzHuegelVorhanden( "vorne" ) && fahrtrichtung == "rechts" ) { drehe( "links" ); fahre(); drehe( "links" ); fahrtrichtung = "links" ; } else if (grenzHuegelVorhanden( "vorne" ) && fahrtrichtung == "links" ) { drehe( "rechts" ); fahre(); drehe( "rechts" ); fahrtrichtung = "rechts" ; } |