Saturday, October 3, 2009

Monopoly City Streets Enhanced Street Finder

With source code!

Monopoly City Streets is a game developed by Hasbro's UK digital agency Tribal DDB. The idea of the game is as follows. The game board is essentially a roadmap of the Earth. The data behind the map is a composite of Google Maps and Open Streets. Online players can use virtual currency (the M$), a small amount of which is provided initially to every player, to buy virtual equivalents to any roads on Earth. They can then develop houses and other buildings on those streets in predefined positions. The roads and buildings generate a return on investment. This "rent" accrues daily. The goal of the game is to become the richest player within a limited time frame of about a month. It was launched on Sept 9 2009, and had a rocky start. The entire game database was reset on Sept 17th. The game end date is still supposed to be some time in October.

The front-end for the game runs entirely in the browser using JavaScript. The interface presents a street map and includes a "find streets" feature. This feature uses the center of the current map view as a point of search, and returns a list of streets that are available to buy either from the bank or from other players. However, this feature reports streets sorted alphabetically, and streets that are owned by other players are mixed in with streets that are owned by the bank. The only distinction is a color code. This is a limitation because streets owned by other players require the player to make an offer. The other player may reject the offer, but either way, it takes up to 7 days to execute it. It is much more productive to buy streets from the bank if any are available. Furthermore, unless a player is looking for a certain street by name, for example if he wants to buy the street he grew up on, in terms of advancement efficiency, the base value of the street is probably the most important consideration when deciding how to spend your virtual M$. The built-in street finder is limited in this regard.

Monopoly City Streets use AJAX for all of their data services (and game operations). It is not difficult to retrieve the data outside of the supplied front-end. About a week ago I created a web based tool that increases the area of the find street function by about 25 times. It does this by requesting nearby streets not only in the area of the longitude and latitude of interest, but also a few similarly-sizes areas to the north, east, etc, in a 5x5 grid. It then aggregates the results and filters out any duplicate entries. Most players are interested first in the streets that are unowned (owned by the bank), so the report highlights these results in green. Secondly, because of the different return on investment for streets of different base value, players are usually interested only in streets with a base value of 1 million Monopoly dollars or more. So, the report sorts the aggregated list of streets by descending value. Later, I added a feature to allow a Google Maps link url to be pasted directly into the search form, which can save the user some time.

I announced the Monopoly City Streets enhanced street finder tool via Twitter about a week ago, and Google Analytics reports 2,390 page views (report date 2009-10-02). Via Twitter, several users asked about the code underlying the tool. Meanwhile, many other users have also figured out the urls behind Monopoly City Street's operation, and created tools of their own. Similar data services are responsible for every other bit of data and player operation in the game. As you can imagine, it is possible to create bots indistinguishable from real players, and really ruin the game for legitimate players. I don't see a way to prevent this, and I'm not the first person to realize it. In any case, I probably won't make any more enhancements to this tool. I have released all of the PHP code behind the tool for the benefit of the community. I have released it under an attribution license. Please use the code for good, not evil.

9 comments:

  1. HI adam,

    Thanks for code byt I obtain every time this error

    Parse error: syntax error, unexpected T_VARIABLE in /web/mcs/listing.php on line 593

    it's arround these line :

    $corr = str_replace('\\', '', $corr);
    $s = split("[{},\\\\/:\"]+", $corr);
    array_shift($s); //discard first entry
    $streetset = array_chunk($s, 10, false);
    array_pop($streetset); //discard last entry
    //add result set to accumulation table
    array_splice($streets, count($streets), 0, $streetset);
    $querynum++;

    I have not seen the error, perhaps do you know, where can I found these

    Best regards,

    Phil

    ReplyDelete
  2. What is the version of your PHP interpreter?

    ReplyDelete
  3. Hi Adam,

    Thanks for the great works.
    It can help me to find out the free strets with green colors.

    But my question is:
    With this table, how can I get back to Monopoly to locate to the particular street?

    Best regards,
    Jackie

    ReplyDelete
  4. Yeah that's a bit of a flaw in the interface. I wrote it before I realized that you can go directly to a street directly by composing a URL based on the coordinates. The URL looks like this http://monopolycitystreets.com#110039400z476844945 and you have to have previously checked the "log in automatically" check box on the normal login screen.

    Anyway, with the tool as it is, you'll just have to copy and paste the street name into MCS's street finder.

    ReplyDelete
  5. @Philiane
    the builtin function array_chunk() was not introduced until PHP version 4.2
    http://www.php.net/manual/en/function.array-chunk.php
    That is my best guess.

    ReplyDelete
  6. Hi Adam,

    Yeah, http://monopolycitystreets.com#110039400z476844945 should work.

    But the problem is:
    the latitide/longitude should have 7 digits after the decimal point, but your code shows only 6 digits. This will forbid the usage as your above example.

    I also found one minor issue in the result page:
    The first 2 columns in result table is Lat/Lng,
    but it should be Lng/Lat actually.

    best regards,
    Jackie

    ReplyDelete
  7. I have corrected the column labels, added a decimal place to both coordinate figures, and made the street name and active link to the game.

    I updated the source code.

    Thank you for your clear and concise bug report.

    The links are like http://www.monopolycitystreets.com/game.html#street_id , BTW.

    ReplyDelete
  8. Thanks for your great job!
    Version 0.2 works absolutely fine!

    ReplyDelete