After seeing this reddit post relating to a buttload being an actual medieval unit of measurement, I decided that I would update the units database on my machine. Here is the simple command that I came up with:
LOC=$(units -V | grep -o "[/a-z/]*\.dat"); echo "buttload winebutt" | sudo tee -a $LOC
It's simple enough, we get the location of the flat file database from the command's version output flag -v, then grep it to contain only the file name. Then, enter the new unit followed by a reference to an old unit. My up to date units database already had a winebutt defined, so I added the reference.
To add another unit, such as Schrute Bucks to Stanley Nickels we would say:
LOC=$(units -V | grep -o "[/a-z/]*\.dat"); echo "schrutebuck 50 stanleynickels" | sudo tee -a $LOC
Burke9077
Friday, January 17, 2014
Sunday, January 12, 2014
Conway's Game of Life in Java
Conway's Game of Life was devised by the mathematician John Horton Conway in 1970 as a cellular automaton. Conway created the rules of the game to offer a simplified answer to John von Neumann's question of a self replicating machine.
The rules of the game of life are simple. An infinite plane is populated with cells. These cells have only two possible states, alive or dead. Cells surrounded with 0-2 neighbors will die of loneliness.
Likewise, alive cells surrounded with 4-8 neighbors will die of overcrowding.
However, a dead cell surrounded with exactly 3 neighboring alive cells will be born.
Through these simple rules, we can create complex and interesting structures and "lifeforms".
I developed a Java, Swing based implementation of Conway's Game of Life that is available on GitHub.
https://github.com/Burke9077/Conway-s-Game-of-Life
Jar download:
http://mattburke.me/programs/Conway_s_Game_of_Life.jar
The one issue with this implementation is that it is not an infinite plane; the array is defined based on the size of the window. The edges of the window are considered to be permanently dead cells, but it still shows some of the interesting patterns and is a good starting point for anyone looking for an example.
Below is the executable .jar available in the /dist/ folder in the GitHub link above. First we need to fill in some spaces. This can be done by clicking and/or dragging the mouse in the game board or by navigating to Game > Autofill in the menu.
Then, observe the results by navigating in the menu to Game > Play.
The results can be interesting to watch! You can also interact with the board while the game is running, by drawing new points or lines.
The rules of the game of life are simple. An infinite plane is populated with cells. These cells have only two possible states, alive or dead. Cells surrounded with 0-2 neighbors will die of loneliness.
Likewise, alive cells surrounded with 4-8 neighbors will die of overcrowding.
However, a dead cell surrounded with exactly 3 neighboring alive cells will be born.
Through these simple rules, we can create complex and interesting structures and "lifeforms".
I developed a Java, Swing based implementation of Conway's Game of Life that is available on GitHub.
https://github.com/Burke9077/Conway-s-Game-of-Life
Jar download:
http://mattburke.me/programs/Conway_s_Game_of_Life.jar
The one issue with this implementation is that it is not an infinite plane; the array is defined based on the size of the window. The edges of the window are considered to be permanently dead cells, but it still shows some of the interesting patterns and is a good starting point for anyone looking for an example.
Below is the executable .jar available in the /dist/ folder in the GitHub link above. First we need to fill in some spaces. This can be done by clicking and/or dragging the mouse in the game board or by navigating to Game > Autofill in the menu.
User defined points using the mouse |
Randomly defined points via Game > Autofill |
The results can be interesting to watch! You can also interact with the board while the game is running, by drawing new points or lines.
Labels:
automaton,
conway,
game of life,
graphics,
graphics2d,
java,
math,
swing
Subscribe to:
Posts (Atom)