20 October, 2008 | Written by Vincent Tan 7 Comments

Quivers, RSVP and the Singaplogosphere

This will be one of those writings with no particular direction. Feel free to go read something else that might be more interesting, like the stock market or something.

Archery, Bows and Clairvoyance

I’ve always found bows in RPGs kind of … quaint. It feels to be one of the flimsiest weapons available. It’s practically useless in close combat. And you need two components for it to work, the bow itself and arrows.

It works great for long ranged attacks though. It also brings with it other factors to consider. Wind speed, speed and direction (or velocity for the physics-inclined) of a moving target and angle of trajectory.

You also need to keep in mind the number of arrows you have at hand. I’m so afraid of running out of arrows in games that sometimes, I don’t shoot them at all. I would save them for more important battles, such as boss fights. Of course, the character was usually physically weak (like Rosa in Final Fantasy IV), so the character ends up using other skills like magic to wreak havoc. And I ended up with a lot more arrows than I expected.

There are also different types of arrows in the games. Like fire-based ones for fighting yetis, snowmen and other fire-fearing enemies. Or lightning-charged ones for fighting water monsters.

I too have different types of arrows and I keep them in separate quivers. There’s the quiver of mathematics, quiver of programming and I usually shoot arrows from my quiver of curiosita.

I encountered this term curiosita from the book How to Think Like Leonardo da Vinci by Michael Gelb. The author defines it as

An insatiably curious approach to life and an unrelenting quest for continuous learning.

That might explain my fascination with puzzles recently, such as the one on digital clocks and the math puzzle in a game.

The thing is, I feel like I’m shooting all those arrows into the future, and hoping that when it’s the present, someone, like me, and hopefully you, will find these articles useful, interesting, thought-provoking and preferably funny and downright entertaining too. I don’t always hit the target. I just try very hard to be on the mark.

So I could use some help here. If you have anything you want to talk about, math or programming or even general fun stuff to think about, send them to me and I’ll write something on it. Like puzzles. I love puzzles. Not too hard though… Oh what the heck. Send them to me anyway (original ones please, or cite their source.). I need to look publicly foolish once in a while, trying vainly to solve a puzzle or write on a subject … and failing. Humility’s good for the soul, I’ve heard.

Which brings me to…

Repondez s’il vous plait

I left all the accents alone. R.S.V.P. is short form of a French phrase that means “please respond”. I’d love to hear something from you. In fact, I’m so desperate, I’d love to hear anything from you.

My colleagues don’t really talk about programming very much. Unless they’re in trouble. Then they’d sometimes ask me for suggestions. So I don’t get a lot of intelligent conversation about programming. Not that my colleagues aren’t intelligent. Just nothing about programming. The weather, current affairs and how the latest corporate management rule is going to mess up our lives pretty much fills up our conversations.

By the time this article you’re reading is published, the material is probably about 18 hours old. By the time you actually read it, it’s probably about a day old. I use the scheduling feature of WordPress. Typically, I write the articles the night before and set them off to be published at 5pm the next day. That’s 5pm Singapore time, which is 8 hours ahead of UTC (+0800). That’s about 5am in the morning for America and 9am for United Kingdom.

I do my web site stuff at night, around 8pm to 12 midnight. So if I respond late to your comments and emails, it’s because of the time zone difference. But please feel free to talk to me. You will make a lonely programmer very happy.

You don’t even have to type out a comment or email if you don’t feel like it. Just think of it in your mind. I’ll receive it, because amongst my many talents, I’m also psychic. I’ve already received a few comments in this manner. They usually pertain to enlarging some male body part, so I ignore them. I might even have to set up an ethereal spam filter soon. Do you know of a service like this?

And I want to thank all the wonderful people who’ve commented here or emailed me. I’ve even got a notable visit from the eminent Raymond Chen from The Old New Thing. I jumped out of my chair when I saw his name. I kid you not.

The Singapore blogosphere

Because of my lacklustre attempt at reaching out to people in a geographically agnostic way, I’ve decided to see what I can do closer to home. My impression of the Singapore blogosphere or Singaplogosphere (you know, that’s actually quite cumbersome) is dominated by the technological, political and the personal genres.

I know it’s much more than that now. I found out about this event called Social Media Breakfast, Singapore version, and I attended its 3rd event. It was awesome! I met lots of wonderful people. Then I attended the 4th event (with the practical modification to brunch instead of breakfast. Singaporeans do not like waking up at the unearthly hour of 8am on a Saturday morning to attend an event). It was just as awesome!

Sadly, I didn’t find any programmers there. Everyone’s eyes glazed over when I mentioned math and programming in the same sentence. They’d probably glaze over even if I mentioned math or programming in its own sentence. But everyone’s passionate about something. They’re energetic, opinionated and generally nice people to be around with.

They are so friendly, they managed to get me into Facebook. Yeah, friend power! It’s also why I left Twitter and joined Plurk instead. I think social media sites mean nothing to you if you can’t find a way to have interesting conversations there, whether you invite all your friends or you make new ones.

With that, here are some of the interesting people I know:

  • Daryl Tay, a social media enthusiast and founder of Social Media Breakfast Singapore
  • Claudia, who is in love with her Nikon camera. Check out her spinning photos.
  • Tech65 on technology in general. Check out their podcasts.
  • Sheylara. She’s famous. Seriously. Her face is plastered all over the XBox poster ads in Singapore.
  • Darryl Kang (not to be confused with the Daryl above) or DK as he prefers to be known, had a recent aversion to McDonalds.
  • Krisandro, and his recent pwnage by a 2.21 metre giant.

And that’s that. Back to regular topics. And I’ve got a kicker coming up…

16 October, 2008 | Written by Vincent Tan 5 Comments

The confounding digital clock puzzle

Recently, I played Professor Layton and the Curious Village on the Nintendo DS. It’s basically a game filled with puzzle after puzzle for the player to solve.

There are 3D questions testing your visualisation skills (the IQ question on the painted cube for my job interview also came up). There are the logic questions such as “Only 1 of the 4 kids is telling the truth”, and you have to figure out the answer from their statements.

I can solve most of the puzzles in my head. The only time when I needed to write something down was where the puzzle can be distilled into a pair of simultaneous equations. You know the kind, the father is x times as old as the son, and after y number of years, he’d be z times as old as the son, and how old are both of them currently. Or some kind of puzzle with some math variables I need to keep track, but don’t want to do that mentally.

Digital clock by claylib
[image by claylib]

Then comes this one puzzle. I was stuck on it for over an hour. I thought, I categorised, I simplified. It’s too mentally taxing to hold all the pieces mentally, and I’m too lazy to write everything out on paper. Here’s the puzzle, paraphrased:

You have a digital clock, displaying the hour and the minute only, with hours in the 12-hour format. How many times during an entire day will 3 or more identical digits appear consecutively in a row? For example, 03:33 is counted as once.

My brother solved it by using Excel to generate all the combinations, and eliminating each combination by inspection. I didn’t want to do that. After some time, I did the only sensible thing. I wrote a program to solve it. Muahahahaha…

// any date will do, as long as the time is set
// to zero for the hour and minute (and second?)
DateTime dt = new DateTime(2008, 10, 1, 0, 0, 0);
string s = dt.ToString("yyyyMMdd");
string sTime;
char[] ca;
int iCount = 0;
// while still the same day
while (s.Equals("20081001"))
{
    // small hh for 12-hour format
    sTime = dt.ToString("hhmm");
    ca = sTime.ToCharArray();
    // check if first three digits are identical
    // or if the last three digits are identical
    if ((ca[0] == ca[1] && ca[1] == ca[2]) || (ca[1] == ca[2] && ca[2] == ca[3]))
        ++iCount;
    dt = dt.AddMinutes(1);
    s = dt.ToString("yyyyMMdd");
}
Console.WriteLine(iCount);

That took me a couple of minutes to whip up. I added the comments so you can follow the thought process easily. Note the “hhmm” format for 12-hour versus “HHmm” for 24-hour format. 2 seconds to compile and run, and BAM! I got the answer. No, I’m not telling you. Go figure it out yourself.

So I solved the digital clock puzzle with programming. Somehow, it felt like cheating. Anyway, my challenge to you is, can you solve it in a non-programmatic, non-exhaustive-list-writing way?

14 October, 2008 | Written by Vincent Tan 2 Comments

Stack Overflow is hard

I tried. Not with as much effort as I could muster, but I really tried. I can’t answer a single question at Stack Overflow!

There was this one where I could answer, and someone already gave the answer I’d give (if I did write a reply). So I decided to vote that answer up instead. Not enough reputation to do it.

To earn reputation at the beginning, I’m practically left with two options: ask a question or answer a question. We’ve already established that I’m incapable of answering any of them. I looked at the questions tagged with C# and sql. Maybe I didn’t look hard enough…

Anyway, I didn’t want to ask a question for the sake of getting reputation. If I’m asking one, it better be because it’s bugging me. And I eventually asked one.

It’s something to do with the Month function in Visual Basic. The code I’m maintaining mixes traditional Visual Basic code with VB.NET code in an ASP.NET web application. On the web server, Month("10/01/2008") returns 10 (October). On developers’ machines, it returns 1 (January). Note that a string is passed as a parameter instead of a date.

I created a test web application with a similar setup and deployed it on that server and … I got 1. Aarrgghh! For some reason, I’m unable to replicate that behaviour.

My best guess is that some setting on the server specific to that web application is set, and I don’t know where. The machine.config? The web.config? Some IIS setting?

If I added this to the globalization tag in the web.config file on my machine:
culture="en-US" uiCulture="en-US"
I am able to replicate the return of 10. But the server’s web.config doesn’t have those attributes in its globalization tag.

I can solve the problem by forcibly using DateTime.ParseExact() with “dd/MM/yyyy” format all over the place. I just want to know why the Month() function is inconsistent. If you know, please tell me your answer. I’d appreciate it very much. Send your answer in a comment, or visit the Stack Overflow’s question page for it. Thank you.

13 October, 2008 | Written by Vincent Tan Leave a Comment

The truth about fog

What do you need to know about fog? You know it as the condensation of water vapour in the air at low heights. That’s the scientific explanation. Little do you know there’s a more … evil reason behind it’s existence…

So you can’t see squat in front of you!

That quality of obscuring objects serves a more important purpose in computer games and 3D renderings. Because of finite calculations, outdoor scenes need to be “contained”. The trick is to use clipping planes, a near plane and a far plane, to restrict the amount of visible information.

Due to this restriction, objects that are really far, but you know is there, aren’t rendered. This has the effect of objects appearing suddenly when you move forward in the scene. As you move, objects meet the visible requirement and are thus rendered.

To help assuage this effect, we add fog to the scene. Objects that aren’t visible can now be partially explained by the presence of fog. At least to your brain.

That was to improve the aesthetics of the rendered scene. In some games, particularly of the horror genre, fog’s main purpose is to hide practically everything from sight. If you can’t see a monster, but you can hear heavy breathing and footsteps, the scare factor goes up (hopefully).

This is illustrated with the use of fog in the game Silent Hill 2.

So now you know the truth about fog.

9 October, 2008 | Written by Vincent Tan Leave a Comment

Featured demo - dopplerdefekt

Today’s featured demo is dopplerdefekt (video link) by farbrausch. It’s about 47.8 KB and 3 minutes in length. (download page at Pouet)

The demo’s prominent feature is the 3D effect; you need 3D glasses to watch it. The technique is called stereoscopy.

The entire demo has two copies of every object, one for each eye (or colour). With the help of 3D glasses, you’ll see objects popping out. Which reminds me, I’ve got to go get one of ‘em 3D glasses.

Enjoy the demo!

← Previous PageNext Page →