ideacrank.net http://writing.ideacrank.net Most recent posts at ideacrank.net posterous.com Wed, 16 Jun 2010 16:02:00 -0700 Using Back Propagation To Train A Neural Network http://writing.ideacrank.net/using-back-propagation-to-train-a-neural-netw http://writing.ideacrank.net/using-back-propagation-to-train-a-neural-netw

(download)

I made this very simple program to figure out how to implement "back propagation," a method of training a neural network.  In the previous program I published, I was using a genetic algorithm to adjust the weights of every network based on a fitness scale.  The method required a gene pool of a good size, made up of the weight information of each network, in order to successfully adapt.  Using a genetic algorithm this way made it impossible for a single network alone to improve.  Back propagation does not require more than one network, only one thing: a measurable goal.  Using back propagation, a network can hone in on the best values for each of weights it contains (which range from .0000 to .9999), adjusting them slightly every time the network runs a single generation.  The result is incredibly successful in this particular case. 

On the left is a set of color values you can modify for four squares in the middle.  You can type values in (0-255), use the slidebar, or choose to generate colors randomly.  Pressing the large "Start" button on the right will start up the networks (one for each square) and begin the back propagation.  While it is running, you can modify any color value or click to randomize the values and the networks will readjust every time. 

The key here is that there is a very easy goal for the networks to achieve.  Each square has only three inputs and three outputs: red, green and blue, each an integer between 0 and 255.  The program adjusts each weight by a ratio, so as an output value get closer to the goal, less is added to or subtracted from the weights.

This program is very simple and pointless in what it does, but the concept, even this particular application, can be used in other ways.  It would be possible to create, for instance, enemies in a game that can camouflage themselves based on whatever they're around (or above, if you're looking down on a two dimensional game).  I've drawn some sketches and mapped out the idea for making a cameleon like creature that, when approached by the mouse, would move away, taking the image of whatever it was on with it.  The trouble in this case is that, to make a good quality camouflage effect, each pixel would have to be modified as each would most likely require its own network.  A simpler use could be something such as light finding or light avoiding bots.  I'll post more details about how the propagation works once I've finished the next project.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Mon, 24 May 2010 20:00:00 -0700 Finally, A Completed Neural Network http://writing.ideacrank.net/finally-a-completed-neural-network http://writing.ideacrank.net/finally-a-completed-neural-network

(download)

For the browser sized program: http://www.ideacrank.net/projects/NeuralNetSeekers.swf
To read the full post: http://writing.ideacrank.net

In early April, I posted my genetic algorithm program, and when it was out, I moved on, taking what I learned about genetic selection based algorithms, and started working on a simple "food seeking" program based on neural networks.  The above program is the result. 

Each moving agent on the screen is an independent neural network, taking in information about its current position, where it is and where the goal is (on a Cartesian plane), running it through a series of "neural" layers, weighing the values of the inputs and producing new values, which in turn go through their own layers, until two values are put out: distances to travel on the x and y axes.  This output is fed to the movement control of the agent (the code representing the object on the screen) and the little seeking agent moves in that direction.  However, unchanged, the configuration of the network will send the agent in the same direction forever.

Things really get fascinating when the agents reproduce.  The agents that are heading to the goal at the fastest, most direct pace are given the highest fitness, but every agent is given some fitness value.  The higher an agent's fitness, the more likely it will pass on roughly half or more of its "genes".  In the last program the genetic information being passed on was binary strings, forty bits in length.  This time, actual values between 0 and 1 are used, but the splicing process is the same:

Mate One's weight at [layer2][neuron7][weight2]: .6730
Mate Two's weight at [layer2][neuron7][weight2]: .1094


A splice randomly chosen to occur after second digit yields: .6794.  The program randomly chooses who the first and second mate are, so if they were flipped, the new weight would be: .1030.  This weight, and all the other new weights (if the splice point is before the first number or after the last, the whole of one mate's old weight is passed on), are given to an offspring network.

Unlike natural selection, the weakest are replaced every time without room for the chance that their betters get destroyed first by unexpected accident (flood, virus, comet, etc..).  Based on fitness, the networks are sorted in descending order, and the least fit are replaced by the next generation of offspring.  There is still always a chance for these agents to be replaced by their own offspring.  On the screen no new objects are created by this process; the old vehicles for the weakest neural networks are taken over by their kin.  The one exception is when agents stray too far out of bounds.  If an agent wanders away (perhaps rejecting their goal seeking life), it is destroyed and an offspring is created somewhere on the board. 

The rate of replacement in this case is set to a tenth the size of the whole population, rounded up.  Before replacement, though, the offspring go through a mutation roll.  In binary, bits marked for mutation simply switched, 0 to 1, 1 to 0.  In the interest of keeping mutations from changing too much, mutated digits will only go up or down one integer.  This allows for a range of impacts from a single mutation: a mutation on the first digit after a decimal will greatly change the weight (especially if a 9 is increased to a 0) whereas one on the last digit will have nearly unseen change.

The selection process was mostly finished a few days ago and I've spent the last few days tweaking the parameters and making the program look a little nicer.  Lag from processing too much put a lot of constraints on what I could do, particularly in the process of mating/mutating networks.  Allowing the program to lag makes for a poor visual program, so I spent today trying to write more efficient code, but so far I haven't made significant progress.  Each network is built as a multidimensional array which, as far as I can figure out, requires an long, irreducible structure:

//for every network, a loop is run
for(a=0; a<amountOfNetworks; a++)
{
    //within every network, the user's desired amount of layers are looped
    for(b=0; b<amountOfLayers; b++)
    {
       //each layer has a desired amount of neurons which are looped
        for(c=0; c<amountOfNeurons; c++)
        {
            //and each neuron has the amount of weights equal to the amount of inputs it receives
            //neurons also have an additional weight that acts as an activation bias
            //the activation bias weight is subtracted from the combined value of all weights * inputs and the result is the output
            for(d=0;d<amountOfWeights
            {
                //network[a][b][c][d] is assigned or used for something here...
            }//d
        }//c
    }//b
}//a


Each amount, the number of networks, layers, and neurons per layer, can be adjusted, but again, lag set an upper limit in this case.  The above is actually a simplified version of the code.  The first and last layers have to specialized; the first must have an equal amount of weights as the amount of  initial inputs (plus one for the activation bias), whereas every middle layer has the same amount of weights: equal to the amount of neurons of the previous layer plus one.  The last layer has to have an amount of neurons equal to the amount of final outputs, as each neuron acts as a single output.  The result is three separate sets of the code above.

I found that the more layers and neurons I used, the better the program was at performing its task.  Few layers and neurons resulted in agents drifting much farther away from their goal before adjusting to a better direction.  Often, you'll see the agents headed slightly to one side of the goal, at some point passing it.  More layers correlated with a faster "turn around" time for the agents, though I'm still trying to figure out exactly why.  Anyway, lag limited my ability to see how far this trend went, and it also set the upper limit to just about four layers (five including output), with nine neurons each.  I set the maximum number of networks to 30 on the slider bar at the bottom of the program.  That is 9 neurons * 5 weights for the input layer, 9*10 for the next four layers, and 2*10 for the output layer - 425 weights per network time thirty networks. At the set maximum, 12750 weights are created at the start of the program; every twenty five milliseconds they are multiplied against their inputs and produce outputs; every fifty milliseconds (every other tick on the game "clock"), 1275 new weights are created, roughly ten percent of which mutate after they all run through the mutation dice roll.  After that, the sorting and replacement is fairly efficient.

I had the program running with two hundred networks, ignoring the amount of time the program hung, and saw enough to get the sense that too many networks actually hindered the selection process.  One result I've noticed from the way the selection is set up in this program is that a small handful agents making smart moves can alter the course of the whole crowd if the agents are mostly in a group together (something that occurs on its own from the seeking process).  If the goal is centered among distributed agents, the whole thing can go haywire.  It will always work out, but it is hard to say when this is just because some random mutant baby happens down the right trajectory or if it is truly the result of corrective selective pressure.

The pressure system seems to work pretty well though.  A good agent can quickly hem in strays or stop the whole crowd rapidly, the most fit sending the whole group careening toward the goal.  In this constrained environment, speed often results in slower goal achievement, as the whole group has to adjust for a longer period of time.  If the whole group is going in the same direction, their children are going to have approximate trajectories, showing the importance of mutation and the rapid spread of successful mutants.  A group, it seems, is best collected, but still spread out enough to allow for a greater cloud of fitness.

It may be that I am alone in my excitement about this, but the promise of this sort of program is mind boggling.  I do often have a mixed reaction to watching the program: I am amazed that a minimally complex program is able to perform such seemingly intelligent actions, its ability to "learn" built into its code.  I am amazed that this sort of thing can be built by a novice programmer (I'm really only five or six programs into using Flash and ActionScript), and that selective pressure and evolutionary concepts work so well in such a simple medium of abstract representation.  I am also amazed at how unintelligent the program can be.  Earlier in the spring, I made a program that shot homing missiles at wherever the mouse was.  With a tenth of the code that I used here, the missiles did a far better job at hitting their goal as fast as possible.  This program does things that look almost random.  Sometimes an agent, far ahead of the others, with no interference, will nearly reach its goal, only to abruptly backtrack, immediately becoming the least fit (as everyone else is catching up).  The result is a flailing agent, moving left and right, adjusting over and over. Though this setting opens the door to strange occurrences, there are definite applications, with more constrained environments, that this sort of program is very useful for that are within my range of ability.

I added the semi-transparent circles because, watching the program, I am reminded of videos of microscopic environments.  I remember watching an amoeba chase a small, bacteria meal, shifting and turning as it followed.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Tue, 06 Apr 2010 19:50:41 -0700 Initial Forays into Genetic Algorithms http://writing.ideacrank.net/initial-forays-into-genetic-algorithms http://writing.ideacrank.net/initial-forays-into-genetic-algorithms (download)

I've been interested in genetic algorithms and neural networks, but only recently had it occurred to me that I could create them with ActionScript 3.0.  The idea and general processes for this program came from a great resource for this sort of stuff www.ai-junkie.com.  The example code, however, was written in C++, so beyond the concepts, the code had to be written from scratch. 

I threw the interface together pretty quickly once the algorithm functioned, so it isn't the best looking program, nor does it show you what happens when the algorithm runs.  I am still really excited.  The whole thing is fairly simple, but the result is pretty damn cool to me.  When the algorithm runs, ten "chromosomes" of forty binary digits are randomly generated, each set of four digits representing a number, 0-9, or an operator, +, -, *, or /.  The chromosomes are decoded and computed in order:

0110 0111 1100 0000 0101 1001 1010 0100 0001 1011
   6      7      *       0      5      9       +      4      1       -

 The result (in this case, (67 * 59) + 41 = 3994) is compared to the goal (the default is 20), and given a reproductive fitness: the closer a chromosome's value is to the goal, the more opportunities it is given to reproduce.  After all ten individual chromosomes are decoded and given a fitness, individuals are randomly selected from the weighted gene pool to produce a new individual made up of a randomly spliced combination of the two parent chromosomes.

0110011111000000010110011010010000011011 parent one
1111000101001101001001001110100010011010 parent two
1111000101001100010110011010010000011011 new child

After the ten old individuals are replaced by new offspring, each chromosome is run through a mutation chance.  In this algorithm, the mutation rate is set to .001, so each digit in every chromosome essentially has a one in a thousand chance to be flipped from 0 to 1 or 1 to 0.  The mutation rate is low, but depending on where the mutation occurs, it could the result greatly. For example, some binary combinations, 1111, for example, don't represent anything, so they are ignored.  A 0111 (7) changing to a 1111 would knock the 7 out of the equation entirely (or the opposite could occur, and a number could appear suddenly).  A less drastic change could be something like a 0001 changing to a 0011, flipping a 1 to a 3.  This, coupled with reproductive fitness, makes for a pretty successful system.  Mutation prevents a whole population from being overrun for too long by a genetically fit, but not fully successful equation (this can be seen if the generations are listed out every time.. an equation the produces 7 instead of 8 is still so close that every individual becomes that equation, effectively removing reproductive variation and any chance of the equation getting closer), while on the other hand, only mutations that increase fitness are likely to be continued to the next generation.

Once the chance for mutations has passed, the ten new individuals are then run through the whole process again.  In the end, one of two things occurs: either an individual's value is equal to the goal and the problem is solved, or the algorithm runs out of time and produces the best result available.  I've set it run 2000 generations, one every .005 seconds, so it has roughly ten seconds. Some calculations slow the process down (the program can find equations for fractions, for instance, but the whole process crawls as it if it runs into equations that produce long or repeating numbers, so they were removed for now), which results in a longer time before the algorithm gives up.

Running the program a bunch of times yields two common results: either a solution is found, usually very rapidly, or the program gives up after dealing with an approximation of the goal (i.e. 19.925 instead of 20).


For speed and simplicity, I kept the population at ten individuals and assigned a limit that gives only a small window of time for the algorithm to find an equation.  If the program had a larger population and more time, I am confident it could find solution at a much greater rate of success.  Still, the fact that it works as well as it does is astounding to me.  The next step is to implement this sort of algorithm in a neural network!

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Thu, 11 Mar 2010 20:39:54 -0800 A Fully Operational Pattern Creator http://writing.ideacrank.net/a-fully-operational-pattern-creator http://writing.ideacrank.net/a-fully-operational-pattern-creator http://www.ideacrank.net/projects/PatternCreator/Drawing.html

I have reached a good stopping place with my pattern project.  It starts with all variables randomly selected.  Click "Generate Pattern."  If you like any part of the pattern, uncheck the "random" checkbox and it will stay the same, or add your own variables to see what it produces.  When you've found something you like, you can choose to export it as either a .jpeg or .png image. 

There is still more I want to add, but as of now, the program works.  All the inputs and check-boxes work and the input provides the information for all the variables of the current pattern.  I also cleaned up the look a bit and added a .png export button.  Jpeg is good for tiled desktop backgrounds and the like, but I wanted to be able to get png files for things like web design.  For now, I am going to take a break from the program and start applying what I've learned to some other, smaller programs.  In store for the future:

  • Slide bars for easy variable changing with results displayed immediately (i.e. dragging a slider that makes the pattern bigger without changing any other variable.
  • A larger set of pattern choices.  I have the code written for circles, hexagons, dodecagons and eight-point stars, but an interface would need to be made that could make them available without making the pixel size of the program much bigger.
  • A nicer look overall.
Though there is more to do, I am happy with how it turned out. 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Thu, 25 Feb 2010 11:29:00 -0800 A Working Program http://writing.ideacrank.net/a-working-program http://writing.ideacrank.net/a-working-program

Though there is still a lot more for me to work on, a functional pattern generating program is online, here.  Currently, a lot of the interface is still under development. For instance, none of the input boxes or check boxes are hooked up yet, they are more of an example of what the finished program will have.  The buttons at the bottom, however, do work.  Click "Regenerate Pattern," to produce a pattern.  When you have one you like, click "Export to JPEG." A tab should open up, and prompt you to give the file a name, then download the pattern.  The pattern is automatically cropped to allow tiling, so you can put it up as a tiled background.

One thing to note: I am still working out resource recycling for the patterns that are generated, so after a handful of regenerated patterns, the program will noticeably slow down (the old patterns are still present, drawn over by the new ones, which slows things down a bit).  Refreshing the page will speed the program up again. (Edit: Fixed.  Patterns are discarded now.  The program should run smoothly.)

At the moment, all variables are random.  The size of the stars and ribbons, the colors, and the opacity are all selected randomly within a set range.  The background is also always black (which actually makes for some pretty cool results.. better, in my opinion than a white background).  The pattern is also always a six pointed star.  These will all eventually be modifiable. 

Success!
 
http://www.ideacrank.net/projects/PatternCreator/Drawing.html is the address. 

 

**Edit: Internet Explorer seems to throw up an error that Firefox doesn't, but continuing will still work.  I'll have to look into that later.**

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Thu, 18 Feb 2010 06:57:09 -0800 Norway conquers infections by cutting use of antibiotics http://writing.ideacrank.net/norway-conquers-infections-by-cutting-use-of http://writing.ideacrank.net/norway-conquers-infections-by-cutting-use-of

OSLO, Norway -- Aker University Hospital is a dingy place to heal. The floors are streaked and scratched. A light layer of dust coats the blood pressure monitors. A faint stench of urine and bleach wafts from a pile of soiled bedsheets dropped in a corner.

Look closer, however, at a microscopic level, and this place is pristine. There is no sign of a dangerous and contagious staph infection that killed tens of thousands of patients in the most sophisticated hospitals of Europe, North America and Asia last year, soaring virtually unchecked.

The reason: Norwegians stopped taking so many drugs.

Twenty-five years ago, Norwegians were also losing their lives to this bacteria. But Norway's public health system fought back with an aggressive program that made it the most infection-free country in the world. A key part of that program was cutting back severely on the use of antibiotics.

Now a spate of new studies from around the world prove that Norway's model can be replicated with extraordinary success, and public health experts are saying these deaths -- 19,000 in the U.S. each year alone, more than from AIDS -- are unnecessary.

``It's a very sad situation that in some places so many are dying from this, because we have shown here in Norway that Methicillin-resistant Staphylococcus aureus [MRSA] can be controlled, and with not too much effort,'' said Jan Hendrik-Binder, Oslo's MRSA medical advisor. ``But you have to take it seriously, you have to give it attention and you must not give up.''

The World Health Organization says antibiotic resistance is one of the leading public health threats on the planet. A six-month investigation by The Associated Press found overuse and misuse of medicines has led to mutations in once curable diseases like tuberculosis and malaria, making them harder and in some cases impossible to treat.

Now, in Norway's simple solution, there's a glimmer of hope.

ANTIBIOTICS MISSING

Dr. John Birger Haug shuffles down Aker's scuffed corridors, patting the pocket of his baggy white scrubs. ``My bible,'' the infectious disease specialist says, pulling out a little red Antibiotic Guide that details this country's impressive MRSA solution.

It's what's missing from this book -- an array of antibiotics -- that makes it so remarkable.

``There are times I must show these golden rules to our doctors and tell them they cannot prescribe something, but our patients do not suffer more and our nation, as a result, is mostly infection free,'' he says.

Norway's model is surprisingly straightforward.

%u2022 Norwegian doctors prescribe fewer antibiotics than any other country, so people do not have a chance to develop resistance to them.

%u2022 Patients with MRSA are isolated and medical staff who test positive stay home.

%u2022 Doctors track each case of MRSA by its individual strain, interviewing patients about where they've been and who they've been with, testing anyone who has been in contact with them.

``We don't throw antibiotics at every person with a fever,'' says Haug. ``We tell them to hang on, wait and see, and we give them a Tylenol to feel better.''

U.S. REACTION

Dr. John Jernigan at the U.S. Centers for Disease Control and Prevention said they incorporate some of Norway's solutions in varying degrees, and his agency ``requires hospitals to move the needle, to show improvement, and if they don't show improvement they need to do more.''

And if they don't?

``Nobody is accountable to our recommendations,'' he said, ``but I assume hospitals and institutions are interested in doing the right thing.''

Around the world, various medical providers have successfully adapted Norway's program with encouraging results. A medical center in Billings, Mont., cut MRSA infections by 89 percent by increasing screening, isolating patients and making all staff -- not just doctors -- responsible for increasing hygiene.

In 2001, the CDC approached a Veterans Affairs hospital in Pittsburgh about conducting a small test program. It started in one unit, and within four years, the entire hospital was screening everyone who came through the door for MRSA. The result: an 80 percent decrease in MRSA infections.

The program has now been expanded to all 153 VA hospitals, resulting in a 50 percent drop in MRSA bloodstream infections, said Dr. Robert Muder, chief of infectious diseases at the VA Pittsburgh Healthcare System.

``It's kind of a no-brainer,'' he said. ``You save people pain, you save people the work of taking care of them, you save money, you save lives and you can export what you learn to other hospital-acquired infections.''

``So, how do you pay for it?'' Muder asked. ``Well, we just don't pay for MRSA infections, that's all.''

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Tue, 09 Feb 2010 20:48:39 -0800 More strap pattern examples http://writing.ideacrank.net/more-strap-pattern-examples http://writing.ideacrank.net/more-strap-pattern-examples These are some variants of the same strap pattern.  They unfortunately don't tile the way the first example did, but they show some of the ways in which the randomized sizes and colors can change the look.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Tue, 09 Feb 2010 20:03:57 -0800 A few new patterns, mostly invisible improvements http://writing.ideacrank.net/a-few-new-patterns-mostly-invisible-improveme http://writing.ideacrank.net/a-few-new-patterns-mostly-invisible-improveme

Worked out the math for strap patterns for six point stars so now I can produce some nicer patterns.  I almost have eight point stars, but there are still some lines overlapping where they shouldn't.  Mostly, I've been reorganizing the code into more manageable classes.  I am also now working on a very simple interactive version.  It will only have one button, "Start," and will generate a randomly colored pattern.  The eventual goal would be a program where the user could adjust and fine tune attributes to his or her liking.  In this pattern's case, for instance, the "strap," can be made wider or narrower, colors can be given limiting ranges (currently "dark," "mid," "light" and "all possible values"), the border of the background stars can be made thicker, which in this case, makes a nice outline along the hexagonal spaces, and adds a little depth to the stars, as well.  All of these things are adjustable right now, but only manually, within the code. 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Sun, 24 Jan 2010 18:41:45 -0800 Random Hexadecimal Colors in ActionScript 3.0 Code and Some Resulting Patterns http://writing.ideacrank.net/random-hexadecimal-colors-in-actionscript-30 http://writing.ideacrank.net/random-hexadecimal-colors-in-actionscript-30 So far in this project, I have some of the simple shapes down.. circles, hexagons, stars and dodecagons (though they're still not lining up) and each shape has a unique color transparency, line thickness and line color.  Overlapping each other, they make some pretty cool, though still very simple, patterns.  However, all the colors had been entered in manually for each shape in hexadecimal: 0x000000 for black through all combinations of red (the first two values after the 'x'), green (the second two) and blue (third) up to  0xFFFFFF for white. 

Instead of going through and manually changing the colors through the code, I wanted to have them randomly chosen and plugged in every time the program ran.  This is usually pretty easy for a normal value (the value = Math.random()*(the upper limit - the lower limit)+the lower limit), but in this case, I needed to convert to hexadecimal.  Here is what I did:

public function getColorValue():String
        {
            var a:String = randomColorValue();
            var b:String = randomColorValue();
            var c:String = randomColorValue();
            var d:String = randomColorValue();
            var e:String = randomColorValue();
            var f:String = randomColorValue();
            
            var colorValue:String = "0x"+a+b+c+d+e+f;
            trace(colorValue);
            return colorValue;
            
        }
public function randomColorValue():String
        {
            var getNumber = Math.floor(Math.random()*(15-1))+1;
            if (getNumber == 10) { getNumber = "A"; }
            if (getNumber == 11) { getNumber = "B"; }
            if (getNumber == 12) { getNumber = "C"; }
            if (getNumber == 13) { getNumber = "D"; }
            if (getNumber == 14) { getNumber = "E"; }
            if (getNumber == 15) { getNumber = "F"; }
            
            return getNumber;
        }

Each value of the hexadecimal color code is given a string variable that is randomly generated from the "randomColorValue" function.  It remains a string so that it can both be a number, 0-9, or a letter (A-F), and that at the end of the function, the strings can be added together as one.

The last thing that needed to be done was at the point that the variable colorValue was used.  It is still a string here, but the hexadecimal actually reads as an integer (strange, but convenient), so the string has to be turned into a number value when it is used, so:

var fillColorOne:uint = int ( getColorValue() );
var fillColorTwo:uint = int ( getColorValue() );

The return from function getColorValue is converted as it fills the variables for color.  Probably not as cool as I think it is, but I am happy with the result.  All the examples are based on the same layout, but the variation in color and line thickness really changes a lot.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Fri, 22 Jan 2010 17:26:41 -0800 Experimental Recipe: Black Bean Purée Over Rice with Avocado and Tomato http://writing.ideacrank.net/experimental-recipe-black-bean-puree-over-ric http://writing.ideacrank.net/experimental-recipe-black-bean-puree-over-ric

One of our favorite restaurants, Veggie Planet, serves up a really good spicy black bean purée with salsa and cheese over pizza bread that I get nearly every time we go for lunch.  I figured that the recipe couldn't be terribly complicated, so we made our own this evening.


  • 1 can of black beans
  • 2 or 3 cloves of garlic
  • Salt
  • Chili powder
  • Basil
  • 1 tomato
  • 1 avocado
I wasn't sure what consistency would be good, so I drained half the black bean liquid into a bowl, and the rest into the processor with the beans so if I wanted it to be thinner, I could add the extra in.  It also gave me a good way to test what spices I wanted add in.  Threw in a few cloves of garlic and tapped some salt and a good portion of chili powder in, blended it up and tasted it.  The beans were unsalted, and I had a difficult time bringing out a strong spice flavor, though I went through a couple of rounds of tapping chili powder in.  Blended the whole thing till it was paste and put it over rice, adding some shredded cheese.  Nicole chopped up a tomato into good size chunks and opted to put everything on top, whereas I chose to leave the avocado and tomato on the side. 

Man it was pretty good.  We weren't as blown away as when we first made pesto, but this was a definite winner, I'd say.  The quesadilla in the photo was purchased from whole foods and, though decent on its own, didn't compare to our homemade meal.  The flavors in ours were all pretty basic, but distinct, not blending into each other and getting lost, but complimenting.  I will say that in the future, I will just add the chili powder on top with the cheese instead of mixing it in to bring it out a bit more.

Overall, a B+.  With some minor additions, easily an A-.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Wed, 20 Jan 2010 07:55:00 -0800 First Successful Pattern Generated http://writing.ideacrank.net/first-successful-pattern-generated http://writing.ideacrank.net/first-successful-pattern-generated

After learning a few new tricks in flash, a positive result!  What had taken me a solid ten to fifteen minutes to draw, I can now produce... sort of.  Not everything works as it should.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Tue, 12 Jan 2010 17:15:49 -0800 Experimental Recipe: Navy Bean Dip http://writing.ideacrank.net/experimental-recipe-navy-bean-dip http://writing.ideacrank.net/experimental-recipe-navy-bean-dip We made some more pesto for dinner, which made us wonder why we don't have it every night.  While at Whole Foods picking up the basil, fighting small children for the free samples, I had some white bean dip that was pretty tasty, so, after dinner, Nicole and I attempted a modified version of the dip. 

  • 1 can of navy beans, drained
  • 3 cloves of garlic
  • 2 tbsp olive oil
  • 2 tbsp lemon juice
  • Basil
  • Salt
  • Pepper
Blended it all up and ate it with some sesame crackers my mom gave us.  It was good, though we both agreed: less or no lemon juice next time.  We were wanting a savory flavor and it was more tangy.  It was very much like a hummus, which, it now dawns on me, is something I hadn't realized I could so easily make with my processor.  There is a lot of potential here and many directions to experiment with.

Grade: B

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Wed, 06 Jan 2010 16:33:46 -0800 Daylight Hours Explorer http://writing.ideacrank.net/daylight-hours-explorer http://writing.ideacrank.net/daylight-hours-explorer
-->

flash animation

-->

I'm not sure what I can do with this right now, but I feel it could be useful sometime later on. 9.1 hours of daylight today in Boston.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Mon, 04 Jan 2010 19:32:00 -0800 New Recipe: Sautéed Bell Pepper and Onion Pizza http://writing.ideacrank.net/new-recipe-sauteed-bell-pepper-and-onion-pizz http://writing.ideacrank.net/new-recipe-sauteed-bell-pepper-and-onion-pizz

I made pizza for dinner tonight.  It isn't the cheapest meal to make, and ordering a pizza is probably cheaper, but I like homemade pizza.  It is very satisfying to make, particularly because it is not hard to make (with store bought dough, I suppose), and yields a delicious meal. 

Sautéed Bell Pepper and Onion Pizza

  • 1 bell pepper
  • 1/2 an onion
  • 2 cloves of garlic
  • Pizza dough
  • Some pasta sauce
  • Provolone Cheese, sliced
  • Salt, Basil to taste

I had a lot of trouble with the dough the first few times I made pizza.  I kept stretching it out, but once it went on the pan the whole thing shrunk back to about half the desired size.  I also don't have a great location to put flour on the dough without getting it everywhere.  I realized, however, that putting the flour into the bag of dough allowed me to prepare the dough without making a big mess.  At the end, the dough comes out, nicely floured, and the bag can be thrown away with whatever extra flour was left.  It also allowed me to handle the dough more thoroughly and to figure out the best way to stretch it out.  The rest is pretty easy. Butter a cookie sheet, throw the dough on, spread a small amount of pasta sauce on, and layer some provolone cheese.  We're tried different cheeses, but provolone works and tastes best.  While the pizza is baking, the onion, garlic and bell pepper can be sautéed with olive oil with salt and basil.  When the pizza is ready, the toppings are distributed on and the whole thing cools for a minute so it is easier to cut.

The picture isn't great, but the pizza was delicious.  I misplaced our grocery receipt, so I can't break the ingredients down by price until later.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Wed, 30 Dec 2009 19:16:29 -0800 Stephen Kellogg and The Sixers show at Club Passim - 12/29/09 http://writing.ideacrank.net/stephen-kellogg-and-the-sixers-show-at-club-p http://writing.ideacrank.net/stephen-kellogg-and-the-sixers-show-at-club-p Nicole and I went to Passim last night to see a killer show.  Stephen Kellogg performed this year's annual new year's (holiday?) show.  It was fantastic; definitely one of the best shows I've been to this year.  The music could command a much larger venue, but Passim made for a more personal vibe and really made all of the crescendos much more climactic.

I figure this is a good time to see how posterous handles two videos:

Adam Ezra, someone who was unfamiliar to me, opened, apparently as a spontaneous fill-in for a canceled original opening act, and was excellent on his own.  I really am appreciating the movement I've been seeing of artists offering up their CDs at a sliding scale.  I now have some new, good music to listen to that, at full price, I would have had to pass up, but was able to pay half the suggested price for.  Instead of forgetting about him, I'm actually more prone to suggest his songs to other people and to talk about him.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Wed, 30 Dec 2009 18:13:00 -0800 New Recipe: Mom's Pesto http://writing.ideacrank.net/new-recipe-moms-pesto http://writing.ideacrank.net/new-recipe-moms-pesto

I cashed in some rewards points I had from my bank and got a three cup food processor and called up my ma to get her pesto recipe.

Mom's Pesto

2 cups basil
4 garlic cloves, minced
1/3 cup freshly grated parmesan cheese
3 tablespoons walnuts (roughly 12)
1/2 cup olive oil
Salt to taste
Some extra basil leaves for garnish

The processor made the whole thing incredibly easy.  We put the basil in first and blended it a bit, then added everything else.  Over penne with some extra parmesan: very successful. 

Cost per item:

2 bags of basil @ $2.99 each
4 garlic cloves ~ $.15
3/4 a 5oz container of parmesan (we went for the pre-grated) ~ $3
12 walnuts ~ $.50
1/2 cup of olive oil ~ $.50

Total cost per serving (yielded 2 and 1/2):  ~$4.06

I had to buy the items in larger quantities of course, so it actually came out to a much higher number tonight, but it is still a great meal for the cost and for how easy it is to make.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Tue, 29 Dec 2009 14:13:45 -0800 The National - Fake Empire http://writing.ideacrank.net/the-national-fake-empire-0 http://writing.ideacrank.net/the-national-fake-empire-0

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Tue, 29 Dec 2009 05:05:00 -0800 Object Oriented Language http://writing.ideacrank.net/object-oriented-language http://writing.ideacrank.net/object-oriented-language

I’ve spent the last few days working through some beginner’s tutorials about creating applications and games using ActionScript.  It has put my mind in an object oriented state, as I’ve been grappling with the concept both while writing code and during a lot of the time I am not at my computer.  I took a Java programming course back a few years ago back in Buffalo and I remember getting as enthralled with the concept as I am now, so it is nice to revisit.

There is no really clear definition readily available for object oriented programming, only things like:

“A style of programming that defines data as objects with attributes and methods that are applied to those objects, and which can be inherited by other objects.”

In example, I’ve been thinking about creating a simple program available through a webpage that can be used to save recipes from a user’s input and give the recipe a standard format to be displayed in a separate webpage.  Say, as a quick sketch, the first screen of the program has text boxes, ten or so, to allow a user to enter in ingredients, and perhaps some other boxes to allow for amount, and pulldown menus to choose measurement type (tsp, tbsp, oz..).  I’ve just made scrambled eggs for the first time (they were awesome!), and so I’d put in:

  • Eggs
  • Butter
  • Pepper
  • Salt

What I want the program to do is take each one and save them for use later.  I would be able write a single function, an object within the code, and call that function for each ingredient. Instead of giving each box its own code, I can just invoke the one instance I wrote, as an object.

Simple concept, but it actually it gets really complicated when there are a ton of objects being called, with multiple pages calling other pages that call other pages, it becomes a bit harder to follow.

Language can be viewed in a similar way.  Single words represent tables of definitions with only certain definitions invoked through context.  Generally we try to stick to single definitions, and ambiguity is beaten out of writing.  We use adjectives, possession and structure to clarify objects in a sentence.   If you’re talking about multiples of the same noun, for instance, you’d clarify that it is his or her vehicle, or the silver vehicle, etc.. For nouns, it isn’t a problem, usually.

“She saw Julia walking into the building while talking on her phone.”

In this case, a section of the sentence is ambiguous, as we don’t know who is talking on the phone.  There are many ways to clarify this, which is pretty nifty.

The phrase though, “while talking on her phone,” is itself a sort of object.  Within it are five base objects, the five words, but also higherobjects, the combinations of those words in the particular combination, which in turn, get combined to form the whole phrase, the highestobject here (though, that will then be attached to the sentence in a few possible positions).  ‘While,’ defined as a conjunction, acts as the bridge to the other parts of the sentence, but also demands a certain structure from the other words and also sets the tone. ‘And’ would be an alternative and may actually clarify the sentence a little more (though it sounds a bit off, “walking into the building and talking on her phone”). ‘While’ requires something to be happening, in this case talking.  In contrast, ‘and,’ is not as limited and could be followed by a noun in other situations. For this sentence, what would follow ‘and,’ would be limited by what went before ‘and,’ as consistency in lists is desired. ‘Talking,’ requires a preposition, something like ‘on, at, to, into’ in order to make sense, and so, the two, ‘talking on,’ get grouped together before the whole phrase is constructed.  The same goes for ‘her phone,’ but in this case, her, as a possessive requires something to own. ‘Phone’ needs something before it, an article or possessive noun.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Tue, 29 Dec 2009 04:59:00 -0800 Changing From Wordpress http://writing.ideacrank.net/changing-from-wordpress http://writing.ideacrank.net/changing-from-wordpress

My brother introduced me to posterous, and I have to say, so far, I am really impressed.  My wordpress account is still up at www.ideacrank.net/writing, but I going to transfer the posts from there soon and begin using posterous only.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton
Mon, 28 Dec 2009 19:02:00 -0800 My First Blog Post http://writing.ideacrank.net/my-first-blog-post-22047 http://writing.ideacrank.net/my-first-blog-post-22047 audio.tenyearsof.us

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/353440/100_1151_edited-1.jpg http://posterous.com/people/3sTqpQrE1225 Maxwell Benton ideacrank Maxwell Benton