Prisoner’s Dilemma

Finished Prisoner’s Dilemma: John Von Neumann, Game Theory and the Puzzle of the Bomb today, a rainy miserable Saturday just like every other Saturday the last couple weekends here in Massachusetts. When will the weather get better? As before, I like to post interesting quotes:

“… Jacob Bronowski wrote in 1973, ‘You must see that in a sense all science, all human thought, is a form of play. Abstract thought is the neotony of the intellect, by which man is able to carry out activities which have no immediate goal in order to prepare himself for long-term strategies and plans.'” [pg 39]

“It’s no exaggeration to say that society is founded on cooperation. Whether to litter — leave a tip — shoplift — stop and help someone — lie — conserve electricity — etc., etc. — all are dilemmas of individual gain and the common good. Some commentators have speculated that irrational cooperation is the cornerstone of of society, and without it life would be, as Hobbes put it, ‘solitary, poor, nasty, brutish, and short.'” [pg 227]

On the TIT FOR TAT strategy that Robert Axelrod used in the iterative prisoners dilemma game: “… one of the more surprising findings was that TIT FOR TAT won without ever exploiting another strategy. ‘We tend to compare our scores to other people’s scores,’ he explained. ‘But that’s not the way to get a good score. TIT FOR TAT can’t beat anybody, but it still wins the tournament. That’s a very bizarre idea. You can’t win a chess tournament by never beating anybody.” [pg 241]

Pages 249 & 250 describe real-life examples of iterated prisoners dilemmas in the lives of stickleback fish (read more about that here) and the vampire bat of South America.

Using Sockets in CFMX

I’ve read emails [1] [2] from a couple different people on the various email lists that CFMX can’t use sockets…. which is true in the sense that CFMX doesn’t have a <cfsocket> tag, but not true in the sense that you can’t easily use sockets in ColdFusion. I banged around this morning for a bit and came up with this example, which does an HTTP request of using a object and then loops over the returned headers and prints them out to the screen:

// get a socket object
socket = CreateObject(“java”, “”);

// call the Socket constructor
socket.init(“”, 80);

// get a PrintWriter object
printWriter = CreateObject(“java”, “”);

// call the PrintWriter constructor
printWriter.init(socket.getOutputStream(), true);

// get an InputStreamReader object
inputsr = CreateObject(“java”, “”);

// call the InputStreamReader constructor

// get a BufferedReader object
input = CreateObject(“java”, “”);

// call the BufferedReader constructor

// request the homepage
printWriter.println(‘GET /index.cfm’);
// loop over result by reading line by line
run = true;
while (run) {
   // read the result line by line
   resultLine = input.readLine();
   if (len(resultLine) GT 0) {
      WriteOutput(“Header: ” & resultLine & “<br />”);
   } else {
      run = false;

You could easily modify this to write xml to a server socket:

printWriter.println(‘<order orderType=”quote” customerType=”RETAIL” orderNumber=”1234″ orderDate=”2003-03-21″>’);
printWriter.println(‘<shipment ID=”1″ city=”Boston” state=”MA” zip=”02210″>’);
printWriter.println(‘<line_item ID=”1″ SKU=”18JK23″ category=”GSHOE” quantity=”2″ total=”39.90″ />’);

or do a variety of other useful things like send SMTP email, do DNS lookups, or send SOAP packets.

Sharing session data between ColdFusion and J2EE components

Informative article on developerWorks titled Together at last: Sharing session data between ColdFusion and J2EE components. After you read that article, read my notes on creating session listeners for CFMX. I show you how to capture CFMX sessionOnStart and sessionOnEnd events using servlet listeners.

I little birdie told me that sessionOnEnd and sessionOnStart events were coming in Red Sky, but I’m not in the beta program so I wouldn’t know…

yosemite pics

You know how some places don’t look as beautiful once you get there? These pictures of Yosemite are amazing, but if you go in person it’s a religious experience, even if you’re not into religion. I grew up camping in Yosemite during the summers and Karen and I camped in the valley and climbed Half Dome on our first anniversary. Bring your camera and watch out for the bears! [via]


Update: A ResourceBundle object is the way to go. In comparison to the Properties class, the ResourceBundle class is a breeze. To load, read and retrieve the key ‘searchlib.dblibrary’ from a text file called ‘’ using the Properties class, you’d end up with something like this:

String databaseDriver;
try {
  FileInputStream propFile = new FileInputStream(“c:\\myapp\\sandbox\\”);
  Properties p = new Properties();
  databaseDriver = p.getProperty(“searchlib.dblibrary”);
} catch ( fe) {}
} catch ( ie) {}

where you have to hardcode the path to the properties file and if the path changes, you have to recompile.

To do the same thing with the ResourceBundle class, you’d end up with something like this:

String databaseDriver;
ResourceBundle res = ResourceBundle.getBundle(“database”);
databaseDriver = res.getString(“searchlib.dblibrary”);

The file this time is located by JVM, located somewhere in the classpath. No try/catch is necessary. Alot easier isn’t it?

If you’re interested in reading more about the ResourceBundle class, check out this article on

Java Internationalization: Localization with ResourceBundles