Category Archives: Fun

The resonance of monopoly (3-2): Selecting the right strategy

Monopoly

Monopoly

In the previous posts, we have seen through the history of monopoly game and the source of its popularity. We also see how monopoly is not simply a game of chance. For this blog post, we will answer the question of the previous post: why shouldn’t we choose to invest in Red and Yellow block, while they are great in term of ROI (Return on investment) ?

Every financiers love ROI, not? The number provides a way to compare the benefit we can yield from different projects, given that we don’t have enough money to invest all of them. We need to figure out how, with our limited resource, we get the best result we can get.

But ROI doesn’t mean everything. There are two other key issues here: timing and resources.

We all love ROI, but it doesn’t tell how fast the money will come back to you after your investment. And you need money to invest in other properties and to pay your own rents, no?

Capital Turnover

In the beginning of the game, you have a certain amount of capital, but far from enough. Usually, I will need to calculate very carefully when I have bought my first 7 – 8 properties. You don’t want to over-spend too much that later you need to sell houses to pay for lunch.

And that comes the equation. Providing that the amount of money to buy the Red/Yellow block is fairly high, it is not a good use of money to pursue a domination on Red block. Chance are, if you managed to own these properties, you will run out of money. A property block without houses is like a tiger without teeth: in fact, you can’t sustain a steady income in any property block without houses.

For the Orange block, though its ROI is somewhat less, it’s the block with the highest chance for players to land on. What does that mean? That means it will take less time to recover your investment, and later you will have money to build houses or sustain your business else where, even buying more blocks!

 

The resonance of monopoly (3-1): Selecting the right strategy

Following the blog post Monopoly: The Game of Finance, we have seen how important it is to realize the “real” value of a property in Monopoly. Needless to say, it’s the same with the property of real life: the business value of a house is not at its price. If you plan to use the building for business, you had better build it where there are lots of people.

Many of beginners make that mistake. They love building on Boardwalk, where they can charge their visitors a hefty price. However, these naive business owners don’t realize that they have to store in a big fortune on these blue blocks too. With the same money, one can easily generate a better income flow elsewhere.

Our question for today: out of all building block in the Monopoly board below, which one yield the best Return-on-investment ratio? That means the block which will give you averagely the highest rents in the same amount of time.

Before you scroll down for the answer, think a minute. It may not be obvious as you think.

Monopoly Board

Have you got the answer? Great!

The property block which will give the best return on investment is the Red and Yellow block. They give great rent for a fairly ok price and their chance to be landed on ranked second in the game! So if you own one of these two blocks, you have a very good chance to win.

But… In the last post, didn’t I advise you to buy the Orange block first?

Yes I did, and it has a reason.

To uncover this reason, you can check my next post.

The resonance of monopoly (2): Game of Finance

Monopoly

Monopoly is one of the most popular board games in the US.

However, people seldom gets it right.

It’s not until last year that I got my hand on a document on the origin of Monopoly. It is so different to what I have thought! The game is made as part of a thesis (what?) to illustrate how the big guy gets rich by bankrupting the small businesses. It outlives its creator, however, and lives on…

Like I say on the previous article, this game is not a gamble. With the development of computer, now we can calculate the chance of a property will be hit in a single trip around the board. And no, not every property has the same chance. Some has better chance to be hit, some has worse chance, and the gap is quite significant.

Need a hint? The orange block is your friend. Although they are quite cheap, they have the highest chance to be hit in a single round of travel, thanks to their position after the prison. The blue block, though attractive, doesn’t worth a crap at beginning, since you will never have enough money to finance its hefty price.

Lesson: never judge a book by its cover (so classic)

Monopoly Board

The resonance of monopoly (1)

Monopoly

Monopoly is one of the most popular board games in the US.

But so many people have misunderstood this game.

I have played my first game since I was six. That time, my father bought me this board game, and I take it to my parents’ hometown. The kids there are so excited. We think we can buy and sell the most famous streets in the city, That is crazy!!

We don’t have anyone to show us how to play, so we just follow the instruction. We go around, buy immobile, train stations, electric facilities… We laugh when someone land on our property. And then, after a very long time, finally, someone goes bankrupt. But usually the game ends before that, since we all have to eat. The time and experience we enjoy is so memorable.

You know what? I never thought the game has so much depth under the simple cover. Not until getting my hand on the origin of monopoly, I realize that there are actually science in this game. No, it’s not gambling at all. You won’t ever know what you get when the dice rolls, that’s true. However, when statistics come into play, everything is possible…

A quick experiment on HTML5 Canvas

Photobucket

/** Vietnamese: một thử nghiệm nhỏ lên trang canvas của HTML5 **/

HTML5 is out for a while, and many people have already play with it. Inspired by the great article here, I managed to make a simple dirty experiment.


<!DOCTYPE html>

<html lang="en">

  <head>

    <title>Good night</title>

  </head>

  <body><script type="text/javascript">
  if ( !window.requestAnimationFrame ) {

    window.requestAnimationFrame = ( function() {

      return window.webkitRequestAnimationFrame ||
      window.mozRequestAnimationFrame ||
      window.oRequestAnimationFrame ||
      window.msRequestAnimationFrame ||
      function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {

        window.setTimeout( callback, 800 / 60 );

      };

    } )();

  }
</script><script type="text/javascript">
var canvas, context;
var xx = new Array();
var yy = new Array();
for (var i = 0; 40 > i; i++) {
   xx[i] = Math.random()*600;
   yy[i] = Math.random()*150;
}

init();
animate();
function init() {
  canvas = document.createElement( 'canvas' );
  canvas.width = 600;
  canvas.height = 400;
  context = canvas.getContext( '2d' );
  document.body.appendChild( canvas );
}
  
function animate() {
  requestAnimationFrame( animate );
  draw();
}
function draw() {
  var time = new Date().getTime() * 0.001;
  var x = Math.cos( time ) * 250 + 300;
  var y = Math.sin( time ) * 250 + 300;
  
  if(150 >= y) {context.fillStyle = 'rgb(250,250,250)';}
  else {
    if (200 >= y) {
      context.fillStyle='rgb(200,200,200)';
    } else {
      context.fillStyle='rgb(14, 14, 14)';
    }
  }
  
  context.fillRect( 0, 0, 600, 400 );
    
  context.fillStyle = 'rgb(255,255,0)';

  context.beginPath();
  
  context.arc( x, y, 15, 0, Math.PI * 2, false );
  context.closePath();
  context.fill();
  
  context.fillStyle = 'rgb(0,0,255)';
  context.fillRect(0, 215, 600, 400);
  
   for (var i = 0; 15 > i; i++) {
      
      context.fillStyle = 'rgb(255,255,255)';
      context.beginPath();
      context.arc(xx[i], yy[i], 1, 0, Math.PI * 2, false );
      context.closePath();
      context.fill();
  
      if (y > 200) {
          if (Math.floor(time) % 2 == 0) {
            context.fillStyle = 'rgb(255,255,255)';
            context.beginPath();
            context.arc(xx[i], yy[i] + 215, 1, 0, Math.PI * 2, false );
            context.closePath();
            context.fill();
          } else {
            context.fillStyle = 'rgb(255,255,255)';
            context.beginPath();
            context.arc((yy[i] / 150) * 600, (xx[i] / 600)*150 + 215, 1, 0, Math.PI * 2, false );
            context.closePath();
            context.fill();
          }
        }
      } 
    }
    </script>
  </body>
</html>

You can view the example online here.

Free ads: thanks for the start-up Handcraft for letting me quickly “craft” this product.

Lorem Lipsum

Lorem Lipsum

Source: http://www.lipsum.com/

“Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.”

Do you find the above passage familiar? If yes, can you guess what language it’s written by?

“Lorem lipsum” is simply a dummy passage which often appears on mocking website. Since the first appearance at 1500s, it soon become the standard text for printing and typesetting industry. Surprisingly, such an old standard still survive till today.

There are 3 reasons to use “Lorem lipsum”. First, it looks more like natural English than “Content here Content here …” text. Reading it give the customers a more accurate image of how the text look like when the site is complete. Second, the content on mocking website shouldn’t be uP/nderstandable, because many studies have point out that people are inclined to be distracted by readable text. And finally, since it has become a standard, it’s a shared background for any content layouters.

And… in case you don’t know, the content of “Lorem lipsum” actually has a meaning. It’s a Latin text taken from ”de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC – a popular book during the Renaissance.

I have been developeing website for more than a year, and such simple things always make people surprised…

P/s Thanks bro Lai Huu Nhon – a senior from my company (Evolus) – for this piece of knowledge. And by the way, I think his layout is cool.

Text

Good comments, Bad comments

/**
/* Vietnamese:
/* Đôi điều suy nghĩ về cách thức ghi chú (comment) trong mã nguồn.
/* Nếu bạn là một lập trình viên từng bực mình đến phát điên vì ai đó code “chuối”,
/* có lẽ bạn sẽ quan tâm đến những điều tôi viết dưới đây
**/

Not too long ago, I came across an “interesting” question on StackOverflow. It was “What is the best comment you have ever seen?“.

The answer list is very very long with thousands of comments. The highest-voted answer is a comment “placed far, far down a poorly-designed God Object“:

/**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you... /*a lot more here*/
*/

Well, it seems all of us developers need a little humor to spice up our steady (sometimes tedious) work. In a work environment with lots of tension, laughs are always loved.

But the thing that caught my eyes in that SO question is not humor. I mean dirty code, which smell through the comments.

// somedev1 - 6/7/02 Adding temporary tracking of Login screen
// somedev2 - 5/22/07 Temporary my ass

From that comment, you see how long a hotfix can live.

#define TRUE FALSE //Happy debugging suckers

If you quit your job, at least don’t treat the maintainers like that.

//Dear future me. Please forgive me.
//I can't even begin to express how sorry I am.

You may think it’s funny. Actually, to me it’s not. Please remember that 60% of developing effort is put on, not coding, but debugging.

Bad code along with poor comments is truly a nightmare to developers. Do you want days in & days out fix bugs caused by comments like this, please go on:

/** * Always returns true. */
public boolean isAvailable()
{
return false;
}

So the question is that: how good a comment should be?

Accoring to Robert C. Martin, comments don’t make up for bad codes. In stead, code should speak for itself, by good naming & structure. For a very simple example, the following code doesn’t have a comment, but it should be fine by itself:

      User currentUser = userService.getCurrentUser();
      if (currentUser != null) {
            if (urlOnlyAllowAnonymousAccess(requestUrl)) {
                log.info("An authenticated user try to access a non-logged-in link. Redirect to homepage");
                httpServletResponse.sendRedirect(contextPath + "/account/home.do");
                return;
            }

            if (urlNotAllowNonActivatedTVAccess(requestUrl)) {
                TVTracking tvTracking = currentUser.getAssociatedTV();

                if (tvTracking == null) {
                    log.info("A non-activated user is trying to access settings. Redirecting to activation page");
                    httpServletResponse.sendRedirect(contextPath + "/account/activate.do");
                    return;
                }
            }
        }

Dilbert & Programmer jokes

Some simple jokes for morning. Enjoy! :)


A Software Engineer, a Hardware Engineer and a Departmental Manager were on their way to a meeting. They were driving down a steep mountain road when suddenly the brakes on their car failed. The car careened almost out of control down the road, bouncing off the crash barriers, until it miraculously ground to a halt scraping along the mountainside. The car’s occupants, shaken but unhurt, now had a problem: they were stuck halfway down a mountain in a car with no brakes. What were they to do?

“I know,” said the Departmental Manager, “Let’s have a meeting, propose a Vision, formulate a Mission Statement, define some Goals, and by a process of Continuous Improvement find a solution to the Critical Problems, and we can be on our way.”

“No, no,” said the Hardware Engineer, “That will take far too long, and besides, that method has never worked before. I’ve got my Swiss Army knife with me, and in no time at all I can strip down the car’s braking system, isolate the fault, fix it, and we can be on our way.”

“Well,” said the Software Engineer, “Before we do anything, I think we should push the car back up the road and try to reproduce the case.”


A guy is standing on the corner of the street smoking one cigarette after another. A lady walking by notices him and says
“Hey, don’t you know that those things can kill you? I mean, didn’t you see the giant warning on the box?!”
“That’s OK” says the guy, puffing casually “I’m a computer programmer”
“So? What’s that got to do with anything?”
“We don’t care about warnings. We only care about errors.”


If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.

The rest of them will write Perl programs.


And Dilbert: