Archive for May 16th, 2008

It’s All In a Roll of the Dice

Friday, May 16th, 2008

White dice Sitting in an airplane recently I began thinking about roll playing games and how they’re slowly gaining popularity on Facebook and MySpace as MMOG’s (Massively Multiplayer Online Games for those who don’t know). Basically the game engines of Dungeons & Dragons etc are simply extensions of more conventional game dynamics from simple board games. Specifically I began thinking about RISK and how the odds change based on the number of armies you bring to the fight.

So sitting in that airplane, I created a PHP class to play around with the odds and how things come out using classic risk weighting. First I created a simple class to roll a six sided die and then expanded it so many instances could be created representing virtual dice. I then created a roll method which will take an optional parameter to handle multiple dice (say 2 dice with 6 sides each common in many games). Last but not least I created to classes for actually rolling an opponent vs. defense, vs() and risk(). The risk class returns a Losses object with the number of units defeated in battle.

Have Fun!

I should note, I’m not the first person to be curious about the odds of Risk or other games for that matter. Google returns over 3.4 Million results for “risk odds”, but I wanted to call out a few that do a nice job of explaining the whole idea here, here and here.

class Dice {
	private $s = 6;
 
	// General constructor
	function __construct($faces = 6){
		$this->s = $faces;
	}
 
	// Returns a roll based on the sides of the dice being thrown
	function roll($dice = 1){
		$total = 0;
		while($dice){
			$total += rand(1,$this->s);
			$dice--;
		} 
		return $total;
	}
 
	// Uses a classic risk model that rewards putting more troops in play
	// removing the 3/2 limit if desired.
	function risk($of = 3, $df = 2){
		$losses = new Losses();
		$dl = 0; $ol = 0;
		$dt = array(); $ot = array();
		for($i=$df; $i>0; $i--){ $dt[] = $this->roll(); }
		for($i=$of; $i>0; $i--){ $ot[] = $this->roll(); }
		rsort($dt); rsort($ot);
		while(count($ot) > 0 && count($dt) > 0){
			if(array_shift($ot) > array_shift($dt)){
				$losses->defense--;
			} else {
				$losses->offense--;
			}
		}
		return $losses;
	}
 
}
// Helper class to pass back the losses from a risk roll
class Losses{ var $defense = 0; var $offense = 0; }

Who’s Data Is It Anyway?

Friday, May 16th, 2008

DataPortability Logo Data portability has been a hot topic as of late. What I think everyone has neglected to consider is who owns which bits of data. For example, my email address is mine. I choose to give it out to friends, family, associates that I want to be able to contact me. That doesn’t, however, mean that it’s also theirs to use how they see fit.

For example, if you’re my friend and you wish to download your social graph to port it to Hi5, Ning or somewhere else, you should be able to do that. However, that doesn’t mean you can take my email, phone, physical address etc with you. What needs to be preserved is our association, not my data. This could be achieved by a public identity such as OpenId and a UUID value tied to each user - ideally the solution would be easier to create so even my mother could do it. Conversely, your data should be able to be ported to the new network without interference from Facebook, MySpace or anyone else.

What makes this discussion difficult is shared property. Consider a tagged photo on Facebook for a minute. I’ve taken the photo which includes you. To make it more complicated, let’s say you tag yourself in the photo. I still own the photograph, it’s even protected under US Copyright law should I choose to exert my rights. But you’re in it - and you want to use it as a profile picture… what to do? This type of shared relationship requires permission in my opinion. Since we’re friends, you know if I’m likely to grant you permission or not when you ask. This process could easily be automated. This could even be automated to the less vague bits of information such as contact information (email, phone, address etc).

Twitter Noise

Friday, May 16th, 2008

Today marks a milestone for my Twitter usage. I tweeted my 1,000th tweet. What does that mean exactly, well, honestly not very much. However, as I scanned over the last 2-3 hours of tweets when I woke up this morning I noticed the increasing number of flame wars between thought leaders in technology frustrating. A feed of 20-30 tweets might contain 5-6 messages back and forth between folks who are in some sort of pissing contest about who’s right, wrong, cool or whatever.

It’s kind of sad.

As everyone struggles to really figure out how to effectively use Twitter it becomes hard to determine the best method for leveraging the technology effectively. I’ve been using it to keep up on industry insiders thoughts (which is probably why I get so much noise and childish banter in my feed). Others use it as initially intended, to tell folks what they’re doing and yet more for shameless self promotion.

I’d love to see more quality information from the industry visionaries who could all take a lesson from @jowyang and @guykawasaki and less banter about who’s right and who’s wrong. Guy and Jeremiah, and I’m sure many others, somehow keep above the fray and still add value to my Twitter experience.

© 1998-2008 AF-Design, All rights reserved.