Code Blog

Displaying 31-35 of 46 results.
2016/03/24 AI

Lee Sedol played an already historic 5 game match series against Deepmind's AlphaGo computer software. Lee Sedol had been quite confident in press conferences before the event and expected to win. From the analysis of AlphaGo games against Fan Hui (the European champion) prior to playing Lee Sedol it was clear that AlphaGo made mistakes and was not yet at the top professional level. However, the games against Fan Hui was played in London in October 2015, about 5 months before the game against Lee Sedol. The question was: How much stronger might AlphaGo be now? Did it have enough time to improve to a level where it can beat Lee Sedol?

Here a short introduction about Lee Sedol might be necessary. Lee Sedol is a Korean Go player that has been one of the worlds strongest Go players for the last 15 years or so, and for a big part of that time also the strongest in the world. Recently he has been surpassed by the young Chinese player Ke Jie who is considered the strongest player in the world right now. Lee Sedol is currently ranked top 5 in the world.

Go how did it all turn out? Amazingly enough AlphaGo won 4 out of 5 games! That's a huge achievement for AI research and it was for certain something that came quite unexpectedly to me! As I'm a Go player myself I have followed the game for quite some time. When I started playing Go around 2003 there was no strong Go computer software around at all. Me and some local players started LuleGo (Go club at Lulea University of Technology) and I remember writing the short introduction to the game. Part of the attracttion with Go was it's somewhat mysterious realm which no computer could enter, because if the computational difficulties of the game.


Date Black White Result
9 March 2016 Lee Sedol AlphaGo AlphaGo (white) win
10 March 2016 AlphaGo Lee Sedol AlphaGo (black) win
12 March 2016 Lee Sedol AlphaGo AlphaGo (white) win
13 March 2016 AlphaGo Lee Sedol Lee Sedol (white) win
15 March 2016 Lee Sedol AlphaGo AlphaGo (white) win

Game format was Chinese rules with a 7.5-point komi, with a 2-hour set time limit for each player followed by three 60-seconds byoyomi periods.

AlphaGo surprised everyone by playing a very solid and impressing first game. Lee Sedol also said he had trouble handling the pressure. In the second game Lee Sedol had chances but didn't take it, and AlphaGo was in the lead 2-0. It was quite a bit of speculation wether AlphaGo can play ko well or not. Maybe there might be some weakness here, many pros seemed to suggest, and recommended Lee Sedol to try to set up a ko to test AlphaGo.

The 3rd game was rather well controlled by AlphaGo but Lee Sedol displayed some great skill and almost managed to live inside AlphaGo's moyo. Lee Sedol actually managed to get a ko, but as he lacked ko threats he had to give up in the end.

Now AlphaGo had already won the series. Maybe this releaved a bit of pressure on Lee Sedol. In the 4th game AlphaGo once again seemed in control and in a winning position. However, from the earlier games it was clear that AlphaGo is superstrong at large area directional play, and uses this skill to build big moyos, which is a very effective way to get a lot of points. As Lee Sedol now knew AlphaGo's tactic he could devise a strategy against it. He went for stable groups and safe territory (cash) straight from the start and let AlphaGo build a big moyo. Then the deciding moment happens: he will need to reduce or destroy the moyo. If he can pull it off its a win for sure. In the 4th game just this happened, and maybe AlphaGo should have been able to win, but Lee Sedol pulled out a great tesuji that AlphaGo totally missed. AlphaGo went into "tilt mode" as it obviously had difficulties understanding what was happening and Lee Sedol could run away with the win!

After the 4th game Lee Sedol requested he take black in the final game. The feeling was that if he can beat AlphaGo as black as well as white he may actually be the stronger player even though he lost 3/5 games. In the 5th game Lee Sedol was probably slightly in the lead in the opening but AlphaGo turned it around in the middle game. Maybe Lee Sedol got a bit too defensive here again which is extremely dangerous against an opponent such as AlphaGo, that will always push its strongest play as long as it feels its necessary. AlphaGo's eng game is also pretty much perfect, so if you're behind after the middle game it's almost impossible to turn it around in the end game.

In the end AlphaGo managed to win the 5th game, but the feeling is still that a human might still be able to beat AlphaGo (at least at AlphaGo's current strength). The series displayed some weaknesses by the computer. As it's a frozen software (the servers were all in London so obviously hard to control, but we trust Deepmind on this)  AlphaGo never changes it's strategy according to it's opponent. AlphaGo would be much more difficult if it could adjust it's overall strategy as well. This would require a more high-level thinking and factor in known information about your opponent. Also the time-management by AlphaGo is quite simple as the Deepmind developer put it himself. In the 4th game when Lee Sedol played the tesuji, a human opponent would have been extremely careful and read through the situation completely. AlphaGo didn't do this, it probably more or less ignored the play as a "weak move" and played on it quite quick fashion. It's hard to translate human behaviours on to computers, as this analogy most of the time will be completely meaningless, but for a human to act like this would be arrogant. AlphaGo didn't realize that this move was key to the game and worth spending all it's remaining time thinking about. So there's still some areas where AlphaGo can improve. And it would be really cool if they could make it as strong on a "normal" computer.

The achievement by Deepmind is nevertheless mindblowing. I think the implications of this event will be profound. 

Michael Redmond (to the right in photo), an American Go player who is 9-dan professional in Japan, was commentating the official Google broadcast on Youtube. He went about the analysis very calmly and provided some nice explanations. However, the official broadcast had to keep in mind that probably the majority of people watching didn't know Go and therefore Michael Redmond had to keep the analysis relatively simple. I was still quite impressed with Redmonds explanations and my feeling is that he must be great teacher. Less rememberable was Chris Garlock suddenly starting to count points (not competely quiet) after Michael Redmond basically said better wait and see the next development.

American Go Association had an excellent live commentary of the games (except game 3 when Kim Myungwan was away) with former Korean professional Kim Myungwan (now living in the US) commentating. Most Korean and Chinese Go professionals don't speak too much English, but here Kim Myungwan proved to be the exception. He's obviously a very strong player and his feeling for the game was very fascinating to follow. Kim Myungwan may actually be the very famous "Tartrate" on KGS according to some Internet posts!

It will be an interesting to see what will be the next step for Deepmind and what they will do with AlphaGo.

AI research will get a huge boost after this for sure. There are actually already headlines in the media that Samsung is trying to find AI companies to acquire. Google and Facebook are already investing in large-scale AI projects.


2016/03/24 VPN

 All started just before the Chinese New Year:


No comments necessary :)  Still wonder what the message was that provoked the Beijing government. Seems like anyone can go ahead and sabotage VPN competitors in this case. 

It seems a bit counterintuitive why to spend money on a VPN that the Chinese government can shut down whenever they want. Seems Astrill now just have to accept being on Beijing's radar, which probably will mean a lot worse business for them, or make their product a lot harder for the government to shut down.

Unfortunately the result has been no / very poor VPN connections via Astrill starting from the Chinese New Year (8 Feb 2016) and then over the recent congress. 

This year's congress was first the "Chinese People’s Political Consultative Conference (CPPCC)" then directly followed by "the third session of the 12th National People's Congress (NPC)". Altogether ran for about 2 weeks from March 3 2016.


The "tipsforchina" website and twitter account has quite a lot of useful information regarding VPN performance.

2016/02/20 VPN

So during the recent Chinese New Year it seemed the chinese government let whatever bureau that is in charge of internet censorship to have a go at all VPN providers. I've been running PureVPN for over a year, and I must say performance has gone downhill most of the time. PureVPN mac client is also really bad, not very user-friendly at all, its just a simply tool that set up mac vpn/dialup connections (using the Mac OS builtin functionality). Anyway, just before CNY the PureVPN stopped working 100%.

I decided to try Astrill as some friends of mine use it and seems happy with it. Had much better performance than PureVPN and also much better Mac OS client (same functions as the Windows client).

However, Astrill was only working 2 days before that one also was blocked! Luckily I managed to find out via a forum post that the "Sweden 2" server for some unknown reason was still available, which made my CNY youtube watching a lot better.

Anyway, all this made me think that it may be good to look for alternative solutions. After doing some research online I decided to give Shadowsocks a try. I used to use GoAgent before, which was working great, until Google servers all got blocked by China. Shadowsocks is pretty much the same thing as GoAgent.

Shadowsocks is a lightweight socks5 proxy, written in python. It's open source, supports many encryption algorithms, it's easy to install, and can be run from many hosting providers (I'm using Amazon Web Services). 

proxy auto-config (PAC) file: defines how web browsers and other user agents can automatically choose the appropriate proxy server (access method) for fetching a given URL.
This is quite handy because you can have a PAC file that lists URLs blocked by the Chinese firewall, so you can minimize the amount of traffic going through the VPN. The ShadowSocks Windows client comes with a local PAC file, and it can also update it's PAC online from GFWList.

Shadowsocks can use the ChaCha20 cypher (a variation of the older Salsa20 cypher) which seems quite popular (a relatively new cipher with fast performance), although the default AES-256-CFB should be plenty safe as well.

The Great Firewall of China (aka Golden Shield Project) is said to perform active probing of foreign servers and block them if they host VPN services. It is therefore important that the HTTP proxy is encrypted but even this may not be enough. GoAgent used a technique called "domain fronting", a way of hiding/tunneling the traffic inside large Content Delivery Networks (CDN) that China would not like to block for economic reasons. This means a client is also needed for http-tunneling, as the web browser don't have this functionality.

Next step will be to try to run the client from a OpenWRT router.

VPNdada Shadowsocks guide
Great Firewall PAC (BASE64 encoded)
OpenWRT client
2016/02/17 Yii

Run into the following situation: The CListView in Yii dynamically loads data into its view, but the Lightbox/Slimbox and SyntaxHighlighter don't know about this change. The easiest solution I found is to attach javascript code to 'afterAjaxUpdate' for the CListView widget to run through and update the new content. I found the SyntaxHighlighter solution in a forum, but had to slightly modify it so it will autoload all possible syntaxes. I don't really like to edit the source code of the extension (as it will break at next update), but I'm not sure what the better way would be to do this.

Add this function below in the JMSyntaxHighlighter.php (JMSyntaxHighlighter extension directory)

The timeout value is a quick hack that's not very pretty. I hope there's also better ways to fix this.

function ajaxHigh(){
  SyntaxHighlighter.autoloader.apply(null, path(
   "applescript @shBrushAppleScript.js",
   "actionscript3 as3 @shBrushAS3.js",
   "bash shell @shBrushBash.js",
   "coldfusion cf @shBrushColdFusion.js",
   "cpp c @shBrushCpp.js",
   "c# c-sharp csharp @shBrushCSharp.js",
   "css @shBrushCss.js",
   "delphi pascal @shBrushDelphi.js",
   "diff patch pas @shBrushDiff.js",
   "erl erlang @shBrushErlang.js",
   "groovy @shBrushGroovy.js",
   "java @shBrushJava.js",
   "jfx javafx @shBrushJavaFX.js",
   "js jscript javascript @shBrushJScript.js",
   "perl pl @shBrushPerl.js",
   "php @shBrushPhp.js",
   "text plain @shBrushPlain.js",
   "py python @shBrushPython.js",
   "ruby rails ror rb @shBrushRuby.js",
   "sass scss @shBrushSass.js",
   "scala @shBrushScala.js",
   "sql @shBrushSql.js",
   "vb vbnet @shBrushVb.js",
   "xml xhtml xslt html @shBrushXml.js"
 setTimeout("SyntaxHighlighter.highlight();", 250);

In the view file:

$this->widget('zii.widgets.CListView', array(
   $(".viewcontent a").slimbox();

The JQuery call will match all <a href> tags within every <div class="viewcontent"> box and bind its event handler to slimbox (i'm running slimbox2.js).

On a side note this is what the official website ( of SyntaxHighlighter says about AJAX integration:

Version 3.0 is fully CommonJS compatible.

A lot of people have tried using SyntaxHighlighter with AJAX and other "non-standard" ways that I have never originally imagined it being used in. With 3.0 release, SyntaxHighlighter can just render HTML code for you completely separately from the DOM, which means that not only it plays well with AJAX, you can use it on the server side with node.jsRingoJSJaxer or any other JavaScript platform.

This sounds quite interesting but would be a quite different solution than my current Yii1 build.

2016/02/15 Yii,CSS

Wanted to update my TinyMCE editor to be able to upload images directly in the browser. So updated the TinyMCE (using the "newtinymce" extension for TinyMCE 4 and "elfinder" extension).

Some things needed changing.

The attribute is the model field that stores the text for the editor.

The "connectorRoute" default set to 'admin/elfinder/connector' made me a bit confused. I guess this means I should have an AdminController to control access for this functions. But the documentation only specified adding an ElfinderController.

The elfinder is a file manager extension to TinyMCE as it doesn't support file uploads out of the box.

I had some problems that the "file upload" got hidden behind the other popup dialog boxes. I solved it by this hack, probably not the best solution ..

elfinder.full.js in extensions/elfinder/assets/js I added:

$('.el-finder-dialog').css( { 'z-index': '10000000'} );

after the append(..).dialog(..) call in the upload function definition (line 2106 in the source file).

But the better way is to add it to the CSS file. First I had to create a CSS for the specific item's views.

To include the CSS add the code below to the view files:

$baseUrl = Yii::app()->baseUrl;
$cs = Yii::app()->getClientScript();


    z-index: 10000000;

Things left to do:

  • Compressor
  • Spellchecker

Links for Yii extensions:


I'm currently running Yii version 1.1.16