In the last couple of weeks I spent a fair amount of time partially rewriting the Mars Rovers (source is here). I added a Swing UI so the rovers can be visually tracked.
Run it from command line
You can run it from the command line with
$ lein run
You can also overwrite the default number of rovers and the number of actions each can take before "freezing".
$ lein run ":rover-number 1000 :action-number 9999999"
It's a bit inelegant to use quotes, but I haven't had time yet to implement a proper command line interface.
UI
As you can see, the rovers seem to move in discrete steps instead of a continuous flow. This is partly due to the fact that the Swing panel is to refresh every time a Rover sends a position changed message to the Plateau, which triggers a message sent to the displaying component. We are talking about ~10,000 messages per second, so I had to introduce some sampling. You can read about it in one of the previous posts.
Performance
The number of moves taken by the Rovers is printed out to the console at every 10,000th move. With the default 100 Rovers on my MacBook Pro (16 GB 1600 MHz DDR3, 2.3 GHz Intel Core i7) this number is 740,000 in 20 seconds, so 37,000 moves per second. This many messages are running through the core.async channels. I don't know how the Scala actors perform, but seems to be pretty impressive. Once I tried with 10,000 Rovers, but all the cores jumped up to 100% and the cooling system started up so vigorously that I saw it better to kill the process. The max it seems to be able to take is 1,000 Rovers, but the number of moves per second is much lower in that case then the one with a 100.
Tests
Painfully lacking...
Next steps...
will be some better documentation, marking dead Rovers with different colours, tests, etc...
Pretty impressive Mate!! You have been very active recently :)
ReplyDelete