Before I give my students this final project. I need help with the solution. note: in vex vr threads python rather than block code. I have coded it in around 8 lines, but I can’t seem to shorten it. I have heard it is possible to do it in under 6 not including VR threads if anyone could help me out I would appreciate it.
Can you post your code here, and elaborate on the project that you need help with? Make sure to format your code by enclosing it in 3 diacritics (`) for readability, like
Sure thing the project is called Dynamic Wall Maze on vex.vr.
Here is what I have so far:
def main():
while not down_eye.detect(RED):
if right_bumper.pressed():
drivetrain.turn_for(RIGHT, 90, DEGREES)
drivetrain.drive_for(FORWARD, 200, MM)
else:
drivetrain.drive_for(FORWARD, 200, MM)
Could have sworn it was working before seems I may have broken it.
in this project the robot needs to travel through a “randomly generated maze” with both a starting and a end. the ending square contains red and should stop on the ending location.
Generally, the simplest algorithm is the one above. Have a sonar on the right side of the robot so it tracks the wall on the right of it, and a front bumper to detect collision with the wall.
I think something like this should work
Pseudocode:
While true{
If front bumper is pressed -> back up a bit, turn left 90 degrees
Else If sonar does not detect a wall -> turn right, drive forward, then turn right again
Else -> drive forward
}
Hugging the wall is pretty meta in minecraft mazes, so I am betting that some students may be able to solve the maze pretty easily, assuming an ideal world where the robot drives straight
That’s the only way I’ve found to do it. It’s super slow unfortunately, but I haven’t seen a better way. Just stopping at every square and turning to check if there is a wall, and if there isn’t going forward. And then of course stopping when you get to the end.
Was involved in micromouse competitions many many years ago.
in fact, when I was in university, this was the only robotics competition available for students.
Anyway, what @holbrook mentioned is the wall-following algorithm. It is easy to implement and widely used.
For micromouse, the end goal is not just solving the maze, but also using the shortest time.
We normally used more complicated algorithms such as Lee’s algorithms.