Thursday, November 23, 2023

Cellular Automaton

 


Today I made a new cellular automaton. It can create similar patterns to an earlier cellular automaton I released here (a simulation of the Belousov-Zhabotinsky reaction). For the Belousov-Zhabotinsky reaction I used a pre-existing algorithm, but for this new cellular automaton I created the algorithm myself. I was trying to replicate some other interesting patterns I have seen:

Sunday, October 01, 2023

Bifurcation

 


I have made a two player strategy game called Bifurcation: link

How to play:

  • The goal is to eliminate all of the other player's units.
  • During your turn, you can move units from up to three locations. Click and drag to choose which locations to move. Use the slider on the right to select how many units to move.
  • You can move to a neighboring location or any location connected by your team's color.
  • At the start of your turn, you will gain units at any locations with a + symbol. The number of + symbols will be the number of units you gain.
  • You can attack enemy units by moving to enemy territory. Opposing units will destroy each other, so you need to attack with more units than the enemy to take over a location.

Monday, April 03, 2023

Stacking Things

 


Today I released a HTML5 game called Stacking Things. It is a physics-based puzzle game. It uses planck.js for the physics and Phaser for the graphics/sound. The images came from a combination of public domain photos and images generated by Stable Diffusion.

Saturday, December 17, 2022

Hexacrystal

I have designed and 3D printed my own board game. It is a two player strategy game called Hexacrystal. Each player controls one color. The game starts with two towers:

The rules are simple. Players take turns placing their pieces. Pieces can be placed anywhere on the board. The game ends when a player resigns, or no more pieces can be placed. The goal of the game is to create a connected path from your tower to the opponent's tower. Neighboring pieces of the same color form a path. The winner is the player whose path (connected to their own tower) gets closest to the opponent's tower. You simultaneously try to extend your path while blocking your opponent's path.


There are 2D and 3D versions of this game. In the 2D version, pieces occupy a single tile on the board. In the 3D version, the crystal pieces can extend beyond the edges of the tile so that they can block neighboring pieces. A valid move requires that the placed crystal doesn't touch any other pieces (verified with a "wiggle" test to make sure neighboring pieces don't move). This introduces more complex strategy: carefully selecting and rotating crystals. Each player gets the same set of crystals (21 unique shapes).

Monday, June 27, 2022

Water Computer

 Using a 3D printer I have built a water-powered computer. Here is a video:


Here is a diagram of the main component: 


The "inverted output" on the left will be ON when the input is OFF, and OFF when the input is ON. The "amplified output" on the right will be the same state as the input, but will have increased water flow. By redirecting the outputs with tubes, this single component is powerful enough to build any logic circuit or computer. This type of computation is known as fluidics.

Here is the binary half-adder circuit that I built (using five of the above components):


Here are the models for the different parts that I 3D printed:

  • transistor - the main logic component
  • nozzle - used for releasing water from the milk carton
  • connector - used to connect funnels to tubes
  • hook - used to provide extra magnet support
  • funnel - funnel with a single output
  • splitter funnel - funnel with two outputs - this can be used to split one larger stream into two smaller streams


Sunday, March 13, 2022

Bitlog

Similar to Turing Paint and Doodle Code, I have released another visual programming language called Bitlog. This is a simulator for electronic logic circuits, represented with bitmap images.

Monday, January 04, 2021

Doodle Code


 I have created a type of barcode called Doodle Code. Similar to QR codes, it can be used to store data.

Sunday, October 25, 2020

Turing Paint

 

I have created my own programming language called Turing Paint. It is a visual programming language: programs are represented using images.

Monday, July 20, 2020

tensorflow-compress

I just released a new open source compression program: tensorflow-compress. It performs lossless data compression using neural networks. Its compression rate is significantly worse than cmix, but it has some nice features:
  • It can run significantly faster using GPUs
  • It is written in Colab and designed to be run through a web browser
I am planning to continue working on it to improve performance and compression rate.

Tuesday, August 07, 2018

Android App

Today I published my first Android app: Squishy Earth

This was based on a HTML5 demo I made a few years ago.

Wednesday, March 07, 2018

cmix updates

There was recently a new winning entry (called phda) for the Hutter Prize. The Hutter Prize is a contest for compressing the first 100MB of Wikipedia (called enwik8). Here is how all of the previous versions of cmix performed on enwik8. phda is incredible - using far less CPU and memory than cmix while getting a similar compression rate. Unfortunately it is closed source, so many of its implementation details are hidden. phda has pushed cmix v14 into second place on the Large Text Compression Benchmark. cmix currently compresses enwik8 to 15113248 bytes, so I am guessing the next cmix release should make it back to first place. Unfortunately there is a bug which is preventing cmix from compressing enwik9 properly, so I need to fix that before the v15 release. This bug is difficult to fix because I have only seen it happen when compressing enwik9... which takes over one week of CPU time for each debugging pass.

Last year I got funding for cmix through the AI Grant. This helped speed up progress by giving me access to more computational resources. I bought a new desktop and can use many virtual machines simultaneously on Google Compute Engine. The new resources let me run cmix on the Lossless Photo Compression Benchmark, getting first place using over 6 months of CPU time!

Thursday, December 14, 2017

Dollar Cost Averaging

Dollar cost averaging (DCA) is an investment strategy where you invest a fixed amount of money on a regular schedule over time. If you have some money, let's say $100, which of these strategies is better?

Strategy #1: invest $100 on day 1
Strategy #2: invest $1 every day for 100 days (i.e. DCA)

You convert your investment back to dollars at some future date, say after 1000 days. As expected, there is a risk vs reward trade off. Both strategies are expected to have some positive interest. Many people I talk to claim that DCA is a valid strategy: although it has a lower expected reward than strategy #1, it also has lower risk. They argue that you should choose strategy #1 or #2 based on your risk vs reward preference.

I have always had an uneasy feeling about this argument. Intuitively I feel like DCA never is a good strategy. In the past I have had various arguments with people about why, but I have never been able to make a convincing argument. Out of the people I have talked to, it also feels like I am the only one who has this opinion.

I have never done any research into this topic or taken any relevant classes. Today I had another argument with some friends, and I finally decided to just run some computer simulations comparing various strategies under different conditions. Figuring out the math is hard, but running computer simulations and looking at the statistics is easy.

One insight with strategy #1 is that you can adjust your risk vs reward trade off by just investing less money. Less investment = lower reward and lower risk. We can introduce this as a new strategy:

Strategy #3: invest $X (e.g. $75) on day 1 and keep $(100-X) in your wallet.

With DCA you can adjust the risk vs reward trade off using different investment schedules. Investing $10 every day for 10 days will have higher risk and higher reward than investing $1 every day for 100 days.

For completeness, we can compare a few other strategies:

Strategy #4: invest $100 on day 50
Strategy #5: invest $100 on day 100

My simulation adds random fluctuations to the investment, so we can measure the expected return and variance of the different strategies using millions of simulated investments. I also experimented with various parameters of the simulations (e.g. how much the investment fluctuates, the duration of the investment, the growth rate of the investment, etc).

Under normal conditions:
- Strategy #1 has the highest expected return and highest variance.
- Strategy #4 and #5 never are useful. You can get the same expected return with lower variance using DCA or strategy #3.
- Strategy #3 is better than DCA. At any level of preferred variance, strategy #3 can get higher expected return. At any level of preferred expected return, strategy #3 can get lower variance.

Surprisingly, there actually are some scenarios where the situation reverses and DCA becomes superior to strategy #3. When the size of the random fluctuations becomes large enough, DCA becomes better. The size of the fluctuations has to become pretty huge - much larger variation than I would expect from normal stock index funds. It might make sense to use DCA for investing in something like bitcoin.

Friday, July 14, 2017

Rock Paper Scissors Using LSTM

Recently I have been doing a lot of research into using LSTM for data compression (in cmix, lstm-compress, and tensorflow-compress). In 2011 I made a website about Rock Paper Scissors AI. I realized that LSTM should be good at playing RPS, so today I made a small demo to do that: http://www.byronknoll.com/lstm.html

Saturday, May 20, 2017

Solar Panels

My wife and I recently bought a house in the San Francisco Bay Area. We are getting solar panels installed on the roof of the house. In this area it is a great financial investment - there is a lot of sun and the electricity rates are high. There is also a 30% federal tax credit for solar installations.

Determining the best size of the system to install depends on your electricity usage. Producing more power than you consume is less profitable.

We got quotes from three different companies. The quotes are surprisingly different:

SolarCity:
System size: 2.7 kW
Estimated annual production: 4,036 kWh
Cost before rebate: $11,394
Cost after rebate: $6,381
Price per watt: $2.36/W

Sunrun:
System size: 2.61 kW
Estimated annual production: 3,526 kWh
Cost before rebate: $10,559
Cost after rebate: $7,391
Price per watt: $2.83/W

SunWork:
System size: 2.61 kW
Estimated annual production: 5,050 kWh
Cost before rebate: $7,050
Cost after rebate: $4,950
Price per watt: $1.9/W

SunWork has by far the best price at $1.9/W. Not only that, but their system is estimated to produce far more kWh than the two other companies. Their system uses microinverters instead of a central inverter. Microinverters have a longer warranty: 25 years instead of 10 years. They are also more efficient than a central inverter. With a central inverter the system only produces as much as the least efficient panel. Microinverters allow each panel to independently perform the DC-AC conversion and also allow you to monitor the performance of each panel.

Another reason SunWork estimates a larger annual production is because they did a better job of optimizing the layout of the panels on our roof. Each company had a different layout:

SolarCity:


Sunrun:


SunWork:

SunWork managed to squeeze all nine panels onto southern facing parts of the roof. Sunrun had cool software which created a 3D model of our roof and automatically detected vents and surrounding trees (useful for modelling shadows). For all three companies the panel placement seemed to be done manually - combined with some software to estimate annual output.

Update: SunWork panels have been installed! Here is a dashboard to monitor our system output.

Update#2: The final price was lower than their initial quote: $6,565

Thursday, February 11, 2016

Trackball Mouse



A couple years ago I bought this neat mouse on Amazon. It is surprisingly useful. I can use it to remote control my computer from my bed. It is also useful for controlling my Avegant Glyph when not sitting at a desk.

Wednesday, February 10, 2016

Avegant Glyph Review



Two years ago I made a post about a device called Avegant Glyph. I ended up investing in the Kickstarter. The estimated delivery during the Kickstarter campaign was December 2014. I finally got the Glyph two days ago.

It is a very cool device, but fell short of my expectations. Initially I spent a lot of time trying to get the position of the display calibrated for my eyes. It was very difficult to calibrate - I couldn't get a clear view of the entire rectangular display. The nose pieces that came with the device keep the display too far from my eyes. I found that removing the nose piece helps me get closer to the display, getting a clearer picture. However, I still can't get a completely clear view of the corners of the display even with my eyelashes touching the lens. The device is also a bit uncomfortable without a nose piece.

Ignoring the calibration issues, the quality of the display is amazing. Colors are very pure and reading text is easy. The display quality looks much better than the Oculus Rift developer versions. However, the resolution of the display is not very high.

Originally I was hoping this could be used as a complete replacement for my desktop monitor. The calibration issues really prevent this from working well. It is annoying to not be able to see text in the corner of the display clearly with both eyes. I tried watching a movie with the device while lying down. This worked well. The weight of the device was supported by the bed, so it was not uncomfortable. The corner calibration issues were hardly noticeable while watching the movie (probably because focusing on the edges wasn't necessary).

Saturday, January 09, 2016

Raspberry Pi Thermostat Instructions

Here are some details on how I put together my Raspberry Pi thermostat.



My apartment's thermostat uses a very simple mechanism to control the heater:



Connecting the red wire to the white wire turns on the heater. Near the center of the thermostat is a glass vial containing some mercury. If the vial tilts to the right the mercury creates a connection between the wires. I attached the two black wires on the bottom and use the Raspberry Pi to control the connection between the wires. The original thermostat remains fully functional: the heater will turn on if either the Raspberry Pi or the original thermostat signal it to turn on.



Materials used: The relay module controls the connection between the two heater wires. GPIO output from the Raspberry Pi can turn the connection on/off. The connection is off by default - even when the Raspberry Pi is powered off. I SSH into the Raspberry Pi to control the GPIO pin over the Internet.

Friday, January 08, 2016

Raspberry Pi Thermostat



I connected a Raspberry Pi up to the heater in my apartment. Now I can control the heater over the Internet.

Update: more details posted here.

Tuesday, January 05, 2016

An Update on Baka


[previous post]

Although Baka Analytics has stopped updating, Baka is still alive. The occasional gaps in the data were due to Baka chewing through the wire which connects the magnetic sensor to the Raspberry Pi (which I had to fix several times). The outage since September 12 is a more serious issue: all of the USB ports on the Raspberry Pi stopped working. I think Baka caused this by urinating on the Raspberry Pi (which was stored next to his cage). I have ordered a replacement Raspberry Pi to use on another project, so it is unlikely I will restart Baka Analytics.

Baka's record was running 17.31 kilometers in a single night. In total Baka was recorded running 682.29 kilometers.

Monday, January 04, 2016