30 June, 2008 | Written by Vincent Comments Off

Launching Ragnarok Code

It’s my new website! Visit it at http://ragnarokcode.com.

For some time now, I’ve been stagnating in terms of writing code. My day job usually provides me with ideas for post material. The thing is, much of the code, concepts and business logic is proprietary and confidential. So the material’s fairly mangled to unrecognisable pieces before it’s seriously considered for publishing.

I’ve also noticed that my articles are starting to lean towards the theoretical, and not enough practical ones. Practical referring to code, and trying out new concepts, and testing new technology. Besides, I’m starting to bore even myself…

Thinking hard, I came up with the answer. Do my own thing and write code! But I need some purpose. It’s fine and dandy to just write code, but without any purpose, the motivation to write code dies quickly.

My considerations:

  • Show my work
  • Current interests in C# and ASP.NET
  • Love simulations

So I’ve decided to launch a new website, running on .NET. I’ll be able to fulfil the first 2 at one go. The simulations thing will probably be a Windows application, powered by DirectX (or XNA?) for graphics. I’ve got water surface simulations, particles affected by “gravity” fields and so on in mind. I can create the simulations, and make them available for download, maybe even the code (once I make it presentable).

Do you know what’s the hardest part? Coming up with a domain name. I thought through a few, and discarded them one by one. I finally decided on one, but it was taken (expired, but still renewable by the owner).

It’s gone on for a few days, with the search for the perfect domain name and the perfect ASP.NET web host. It started to drive me crazy. Until something inside of me screamed “Stop this!”. And I made a decision, and bought a hosting package and registered the domain name “ragnarokcode.com”.

After I registered the domain name, I realised a fatal mistake. I’m not going to rank well for the word “ragnarok” due to a popular game Ragnarok Online. Totally forgot about it. Eeesshh… It’s fine, since I plan on using the website like a test bed for concepts.

So right now, I’ve only got an implementation of reverse polish notation on the site. What it means is, you can type “2 + 6 / 3″ and get “4″ as an answer. Hardly noteworthy, since you can write that in code and get an answer anyway. Until you realise that to evaluate a new expression “4 – sin(pi/2)”, you have to recompile your code.

This type of dynamic evaluation requires dealing with the symbolic meaning of the terms in the expression (symbolic computing?). There’s this software called Mathematica, which I used in my university days. My implementation just scratches the surface of what’s achievable.

Because I want exceptions to fail silently, that even if the expression doesn’t make sense, every best effort was made to evaluate the given expression. Which gave surprising results when I tested my own creation. Did you know “love + hate” has a numerical answer? *smile*

So here’s the link again: http://ragnarokcode.com. Have fun!

27 June, 2008 | Written by Vincent Comments Off

Never incorrect

My friend approached me for help today.

“What does ‘He will never be incorrect‘ mean?” he asked.

The genius logician that I am, I answered “He will always be correct”. My friend gave me a puzzled look. Then I translated the answer into Chinese, because he’s more familiar with Chinese than English.

It took a while, but he finally got it.

Use “positive” words whenever possible. Even words such as “reckless” can be considered “positive”, in the sense that it’s opposed to “incautious”, a direct negation of “cautious”.

This applies to writing code too. Don’t expect the next programmer who reads your code to be an expert logician. Nor a philosopher.

I hate writing about double negatives… I always end up focusing on negatives myself…

27 June, 2008 | Written by Vincent 6 Comments

From dilemma to tragedy

In game theory, there’s an interesting problem called the prisoner’s dilemma. There were these 2 prisoners who were accomplices in a crime, but they didn’t know each other prior to the crime. They’ve been caught, and were individually questioned. Assuming no social consequences nor retributions, each prisoner was asked to confess to the crime.

If prisoner A confessed, but prisoner B kept quiet, A was let go and B was to take the full blame (and vice versa). If both confessed, both gets jailed, but less than if a single prisoner took the fall. Now, if both kept quiet, both still gets jailed, but for a significantly less amount of time than the previous situation.

Prisoner hands by Andrejs Zemdega
[image by Andrejs Zemdega]

The action “keeping quiet” corresponds to “cooperate”. The action “confess” corresponds to “defect”.

When I first learned of the concept, it was in the form of rewards, as opposed to punishment above. So here’s a table where the values correspond to rewards.

  A cooperate A defect
B cooperate A gets 0.8
B gets 0.8
A gets 1.0
B gets 0.0
B defect A gets 0.0
B gets 1.0
A gets 0.2
B gets 0.2

[the table might look a bit crushed together if you're reading in a feed reader]

I made up the values. They’re meant to illustrate the disparity between the cases. You might also have heard of other versions of the prisoner’s dilemma. I want to highlight the part where both prisoners benefit more from cooperation than defection. The special case is if one chose to defect and the other chose to cooperate. But cooperative benefits are higher than an individual benefit.

When total selfishness comes into play, the selfish individual achieves the optimal benefit. But the optimal benefit isn’t much higher than the cooperative benefit. Being even a little less selfish creates a better outcome for all.

Now compare this with tragedy of the commons. A group of people have a shared finite resource. When everyone cooperates by taking only their fair share, all is well. When one person selfishly takes more than his fair share, the group on the whole suffers.

Since there’s no real incentive to be selfless at that point, more people might start taking more (defecting). And suddenly the finite resource gets abused and becomes useless.

For example, carbon footprints. Everyone wants to be environmentally friendly. When someone thinks there’s enough clean air for everybody, he might selfishly decide to up the noxious gas output (as a means of upping his profit too). If it comes to a “every man for himself” situation, the planet is going to be in deep trouble.

Economically speaking, there isn’t much relation between the prisoner’s dilemma and the tragedy of the commons. Socially speaking, in particular selflessness and care for the common good, the latter is a scaled up version of the former.

With the rise of social media and software tools to connect people, I find the relation between the two concepts interesting. Let me know what you think.

Next Page →