Turn for a random duration. When you hit the wall, turn away from it a little. Then start over with the forward arc. Write a line-following program. This behavior causes the robot to move along a path marked on the floor.
Line following is surprisingly hard.
For two different approaches, see Chapter 3 of my book and Chapter 8 of Dave Baum's book . Add sound to your program. It's a great way to get involved with robot programming. Tell us what you're up to in our Mindstorms forums . His books include The Unofficial Guide to Lego MindStorms Robots , Java 2D Graphics , and Java Cryptography .