Posts from July, 2012

Learning to Play Go Online

Al Billings

Untitled

I’ve been learning to play Go lately. Like many people, I learned the rules when I was much younger and then forgot them due to lack of play. Growing up in America, Chess has always been the traditional game of strategy played by geeky sorts. (I’ll admit to being in chess club in junior high school.) Go has fulfilled that same role in much of Asia but has never taken off as much in America (or, I suspect, Europe). That said. it has a strong following these days and has been gaining popularity over the last few decades. After my childhood Chess days, I went on to role-playing games (Dungeons and Dragons) and various popular board and card games, continuing these, off and on, to this day. I haven’t played Chess much in many years though I do have a set or three around the house. I never really got into Go though.

Now, here I am decades later and a bit of a fan of many things Asian, though I already was as a child to some degree thanks to my mother’s love of Japanese culture, especially Toshiro Mifune. I’m a Zen Buddhist and, strangely, it is hard to be a Zen practitioner and not run into Go on a regular basis. In addition, there is a strange intersection of people who play Go and computer geeks. At least a few acquaintances of mine originally met playing Go. Because of this irregular exposure and a lifelong love of games, I’ve been wanting to really learn how to play.

The problem with learning Go, especially by yourself, is that the rules are deceptively simple and the game is amazingly subtle. It is easy to play bad chess and to start to get a feel for the different pieces and how they interact. You have to learn to see patterns in play by playing against a real person and getting a sense of what works and what doesn’t. It is additionally difficult to play go against a computer as there aren’t really good programs for it. Unlike chess, which various specialized supercomputers can play admirably well, there has not been a mastery of go exhibited by a computer program at this point. I gather that the game is a complex enough problem that computers are still relatively incapable of winning against a good go player (which I am not).

The end result is that you really need to play against people, as well as study existing games or perhaps read a few books on the matter. Since this is not an uncommon problem and people love to play, there are a variety of solutions.

You can join one of the many Go clubs, if you happen to have one in your area. Near where I live, the Berkeley Go Club has been going for a many decades. There is a regular meetup group for people who play in Oakland, as well. This provides for the ideal, which is in person play with people. (A longterm leader of the Berkeley Go Club was the original owner of the goban at the top of this post, which now resides at Ace Monster Toys.)

As a geek, though, I’ve found that I like online play. With some resources, you can play asynchronously, allowing each player to play a turn when ready without the other having to watch, or you can play simultaneously in a live match.

The dead simplest way to play online that I’ve found is Dave Peck’s Go, a simple webserver based system that allows you to play with single opponent and which will email each player when it is their turn. You can specify board size, handicap, etc., which is rather convenient. Like a real mensch, Dave even has his code for this up on GitHub so you can even run your own server if you want. This just requires a web browser and email, which makes it pretty easy, and allows for people to send moves and move on to other things.

Go with Jim

The downside of the Dave Peck’s server is that it is a little clunky and only really works if you already have a designated player available (such as I did above). If you need to find an opponent because you don’t have a handy Go partner (or it is frustrating to play with only that person), there are places to go to find many other players.

For the real Go action, the place to…go…seems to be Pandanet, which runs the big “Pandanet Go Server.” There is a KGS Go Server as well but it requires you to run a Java client and friends don’t let friends run Java in their browsers (it is probably the #2 vector for attacks on your computer and should be disabled), leaving it out for me.

The Pandanet Go Server is an IRC-like application (you can watch text stream by in the console) that mediates Go games. This server has a number of very cool things going for it. Once you make an account, you can provisionally self-assign yourself a rank. (Did I mention that Go players are ranked by skill?) Once you play a 20 games against another ranked opponent in a conforming manner, your rank is set in the system. Pandanet’s server allows you to see a list of players who are connected to it, their official rank, and whether they want go play a game. This means that you can select an opponent of a suitable skill level to work on your play (or even a much more skilled player and play with a handicap) and actually advance your rank over time. You can record your games for later review and even send them to others. Additionally, you and others can observe the play of any games on the server, allowing you to watch (and review) the games of much more skilled players. All in all, this makes it an ideal environment in which to play Go if you aren’t going to do it in person.

The really cool thing about Pandanet’s server is that it is so ubiquitous that many people have written clients that can talk to the server. For OS X, which I normally run, there is Sente Goban, which is very nice even though not entirely open source. It is based on the Free Software Foundation’s GNU Go application, an open source (cough free software) project going back over 20 years (which hasn’t released a new version in three years now). Sente Goban is able to connect to Pandanet’s server, allowing me to log in and play games from my laptop. Pandanet offers their own older client, glGo (or here) but the OS X version doesn’t work anymore and I haven’t tried the Linux and Windows versions. Their officially listed client, GoPanda is another Java app that you shouldn’t run. They also offer the Panda Egg Go client for Windows.

The best way I’ve found to play on Pandanet is on a portable device. They have wonderful iOS and Android clients called “Panda-Tetsuki.” The clients have a lovely page with links to the various versions and they are available as free applications. I’ve embedded their video for the iPad client below and it is a great app.

As far as basic resources for learning to play Go, there are a number of decent ones online. You can download a free copy of the introductory book, The Way of Go by Karl Baker to get you started on learning the rules and play. There is also the somewhat clunky The Interactive Way of Go. Sensei’s Library also has a set of dedicated beginner’s pages. “ChiyoDad” wrote a delightful blog for a few years, ChiyoDad Learns Go about his adventures learning Go as well.

Continue reading

Setting Up PyCharm to Run MozWebQA Tests

Syndicator

PyCharm is a Python IDE, released by JetBrains.
I quite enjoy using it and, as I’ve recently started contributing some tests to Mozilla’s Web QA
department (mozwebqa), I wanted to use it to interactively debug some mozwebqa tests. This turned out to be a lot trickier than I had imagined, so I am documenting
the steps to do so via this post.

This post assumes you have a project open in PyCharm for one of the mozwebqa projects. I am going to use marketplace-tests
for this example. As I am on a Mac the instructions and screen shots will be OS X specific, but I imagine they will translate pretty closely to Windows.

Step 1 – Configure py.test as your default test runner

  1. Open up the Preferences… dialog and choose Python Integrated Tools under Project Settings.
  2. Choose py.test as the Default test runner.
  3. Click OK.

Step 2 – Set default run configuration parameters for your project

  1. Type ctrl + alt + R to open the Run configuration selector.
  2. Type 0, or choose the first option (Edit configurations…) from the select list.
  3. In the Run dialog, expand Defaults > Python’s test and choose py.test.
  4. Make sure the Python interpreter that you want to use for this project is selected for Python interpreter.
    If you are using virtualenv you may have to configure a new Python interpreter for your virtualenv. More on that in a separate post.
  5. Choose the root of your project for Working directory.
  6. Click Apply, then Close.

Step 3 – Create a pytest.ini file in the root of your project

This is necessary to pass command line options to py.test. It would be nice if there were a way to do this via the IDE, but I was not able to do it.
If anyone knows how, or can figure out how, to do that I’d love to know. I was able to pass a single option to the command line from PyCharm,
but could not get it to work with multiple options.

  1. Create a file called pytest.ini in the root of your project.
  2. Add the command line options you need into that file under the [pytest] section. See below for an example from marketplace-tests.
  3. Click OK.

[pytest]
addopts = --driver=firefox --credentials=mine/credentials.yaml --destructive

Step 4 – Create a copy of credentials.yaml in a personal folder

You are going to have to edit credentials.yaml to place some actual credentials in it, so in order to not have it overwritten each time
you do a pull, you should put a copy that you are going to use somewhere else. I tend to create a /mine folder under the project
root and place it there, but you can put it anywhere you like. You will notice that the command line option above uses that /mine
folder to locate the credentials file.

Step 5 – Run your tests

With a file that contains tests open in an editor window, type ctrl + shift + R and PyCharm will run all of the tests in the file.
If you wish to run just one test, type ctrl + alt + R, followed by 0 to open the Edit configurations…
dialog and then place the name of your test in the Keywords input. Click Run.

Continue reading

A Review of Doctorow’s Pirate Cinema

Al Billings

Pirate Cinema

I recently managed to score an advanced reader copy of Cory Doctorow’s upcoming young adult novel, Pirate Cinema. This comes out in early October, so it will be a while yet. Cory has been on a kick writing YA novels for a couple of years now. I believe Makers was his last adult-focused book but both For the Win and Little Brother were YA oriented (and did an excellent job at it as well).

Pirate Cinema is a pretty unabashed polemic piece along the lines of Little Brother. The book blurb reads:

Trent McCauley is sixteen, brilliant, and obsessed with one thing: making movies on his computer by reassembling footage from popular films he downloads from the net. In the dystopian near-future Britain where Trent is growing up, this is more illegal than ever; the punishment for being caught three times is that your entire household’s access to the internet is cut off for a year, with no appeal.

Trent’s too clever for that too happen. Except it does, and it nearly destroys his family. Shamed and shattered, Trent runs away to London, where he slowly he learns the ways of staying alive on the streets. This brings him in touch with a demimonde of artists and activists who are trying to fight a new bill that will criminalize even more harmless internet creativity, making felons of millions of British citizens at a stroke.

Things look bad. Parliament is in power of a few wealthy media conglomerates. But the powers-that-be haven’t entirely reckoned with the power of a gripping movie to change people’s minds….

I enjoyed this book a bit and I’m going to leave this review spoiler free, for the most part, given that it is three months until the book comes out. My main criticism of the book is two-fold. The first criticism is that this book is largely a rehash of arguments that Cory has been making for years about video (and other forms of) piracy on the net. If you’re a reader of Boing Boing and have read any of Cory’s pieces on video piracy, Youtube policing, or remixing culture, you’ve heard most of the arguments that are presented in fictional form in Pirate Cinema. In that sense, as a regular reader of his work, I kind of felt “Yeah, yeah, I know this point…” a lot while reading the book.

The arguments weren’t really new and the presentation was not particularly subtle. When the main character has horrible things happen to him or people he knows in response to the draconian privacy regime that his government has set up in concert with Hollywood studios, it is exactly the kind of worst case scenarios that we hear on Boing Boing and other outlets in response to the industry sponsored anti-piracy law of the week. It is painted in broad strokes and kind of hits the reader over the head with the clue bat repeatedly. That isn’t to say it is bad but it is pretty overt and presented as very black and white. The media guys are unrelentingly bad. In fact, I don’t think that there is a single positive portrayal of them in the entire book. They’re all clueless, money grubbin’, and evil, out to put poor kids in prison, etc. in order to protect their outdated business model and profits. The portrayal of government insiders, similar to Little Brother in parts, is a mix. You have the ethically bankrupt members of parliament and their parties willingly bought and sold by the movie industry and then you have the few, slightly less compromised, ones trying to do the right thing but in a compromised situation. They have a little more “gray” in them but not much for the most part. Almost without fail, government types, especially older adults, are largely either clueless, bought and sold, or just ineffective. The political activists, who are older, are helpless against blocking the horrible laws as they get worse until the kids take direct action and rally the populace.

All a bit polemical and not terribly nuanced. That said, it wasn’t badly done and it is good page turner. Cory Doctorow is an excellent writer, by and large, and knows how to craft a good story.

My second criticism is a bit more of a subtle thing (what I criticize, not my criticism itself, which is blunt). It is related to the above comments in a way. The criticism is that the world and the lives of the characters in them is not portrayed very realistically. On finishing the novel, this left me a bit frustrated. Trent, the main character is a runaway from a nowhere town in the north of the UK. Without giving much of a spoiler (it is the beginning of the book!), he spends an entire, single, night on the rough streets of London before finding a positive change in his fortune. While the kinds of things that happen to runaways to the big city are mentioned in passing, Trent never sees any of this directly. He meets good people. He’s unmolested. The bums and locals are friendly. Heck, even the drug dealers are friendly and leave him and his friends alone. It is like an ant-gritty version of a runaway story. Rather than strung out on heroin, beat up by the local predators (he is homeless after all and all of 16), or similar, it is all glossed over and presented in a positive light. This kind of tone is presented throughout the book, which is written in the first person (with a character that “sounds” a lot like Marcus Yallow in Little Brother). This may simply be that this is a YA book but I’m not sure that Cory really writes “gritty,” when I reflect on his earlier books. While people get beat up (for being gay even) at one point, anything violent or dangerous happens out of the direct perception of our viewpoint character. I think this detracts from the book.

If this was a movie, along with not being a very realistic portrayal of the life of homeless kids fighting the government, I’d say that it lacked tension. Little Brother had most of the same issues that I discuss above except for the fact that our viewpoint character witnesses violence first hand and is waterboarded in the first person, along with being imprisoned. The fact that horrible things are directly happening to Marcus and his friends in that book gives it a lot more tension and makes it more gripping. In contrast, Trent’s biggest issue is legal. No one is threatening him physically, ever, in the entire book. He may go to jail for his pirate activities and his activism but it is all kind of dispassionately presented. He’s never really terrified of it and you never really believe it is going to possibly happen. Without the threat of personal harm, either physically or in the sense of actually going to prison, the whole legal thread just kind of goes without being immediately present.

Reading the above, you’d probably think that I don’t like the book or think it is horrible. I don’t. Most of this criticism is that I was hoping for a better and more gripping tale than what I read. This is a good book, just not a great book. For people, especially teens, not well versed in the arguments around pirating movies (or other digital content) or the various proposed (and successful) draconian legal responses, I think that this would be a pretty good introduction to it. The characters are likeable and well written. The sex (of which there is much more than Little Brother) occurs “off camera” so the library associations and schools won’t need to necessarily ban the book for “showing” a little reality of what it is like to be a teen.

Would I recommend this to my adult friends who are very active online? Maybe. It is a quick read and enjoyable. It isn’t Makers though and that was the most gripping and best written of Cory’s novels in my opinion (and which I still recommend to people involved in hackerspaces with me).

Give this to your teenager or maybe your college kid and I think they’ll enjoy it but realize that it really is written as an anti-corporate, pro-sharing/remix culture piece and it isn’t terribly subtle about it. If you’re already a fan of Cory Doctorow’s, you’ve already heard all of the arguments in it.

Continue reading