I came across this post that discusses ways to write FizzBuzz in Clojure without using conditionals. However, most if not all of the solutions still do a lot of branching behind the scenes. Think of hash lookups for example.
So I asked to myself, how can I write a FizzBuzz solution with no branches at all?
Probably not in Clojure; you can’t easily tell where it is branching or not.
The only way to be absolutely sure is to write it in assembly. So I did.
I never did assembly before, so it might be terrible code.
I used an array of 15 pointers to either “fizz”, “buzz”, “fizzbuzz”, or a number buffer.
I then filled the number buffer with the current number in ascii and printed whatever I get from the array.
One thing I struggeled with is how to stop.
At first I had one condition to see if I reached 100.
Now I use a lookup table that calls sys_time 99 times and then sys_exit.
I know this is a rather silly robot. It does nothing at all, and it’s not very beautiful either. I guess I just want to remind you that it’s important to just play without expectations or goals.
According to John Cleese, it is very useful to attempt something impossible sometimes. This often puts your mind in a new perspective, leading to new ideas.
Reading a CD with a light sensor is obviously not going to work, but maybe there are other ways to read data with the EV3?
After a long period of silence, I finally made some things with my EV3. Last time the tools where not really ready, but now everything works great.
I used ev3dev and python-ev3 to build this bulldozer. Watching sumo matches at LEGO World, I saw a few things that do and don’t work.
A lot of people seem to go for blades and hammers, but unless you actually want to destroy the robot, they are useless. Treads sound like a good idea, but wheels have more grip in practice. Make sure the wheels don’t fall off. Encased wheels are the best.
The goal is to push the other robot off the table, so the more powered rubber the better. Four wheel drive is better than rear wheel drive, but rear wheel drive is still much better than front wheel drive.
It’s all about pushing. The only useful thing besides pushing forward is pushing up or sideways. Pushing up is the easiest, because you have the floor to back you up. It also pushes the opponent’s wheels off the ground. This lead me to the following design.
[gallery columns=”2” ids=”534,532,533,535”]
I used two pairs of driven rear wheels on a pivot, so even if I’m lifted, all four remain in contact with the ground. They are geared down, which means I’m slow, but powerful. All the weight of the motors and EV3 is directly above the wheel, for maximum grip.
On the front there is a lift arm, using a worm wheel and a very solid construction. I went through several iterations, improving the strength each time. On the first iteration, it was to weak, but its wedge shape still lifted my opponent a little.
The code is quite simple. Push forward. When you reach the edge, turn around. When something hits the bumper, raise the arm.