C# in 24 hours

What the hell am I, an avowed microsoft hater doing with c#? What the hell is microsoft doing on github? When Visual Studio Code was announced for linux, I was more than sceptical. I scoffed at folks who tried it out. But now here I am having a crack at it myself. Right now I am on holiday at my sister's place in the hills. This is where I learned python a few years back. Maybe it's time to investigate C# . Let's see if it can be learnt in 24 hours. I will probably make a fool of myself with the comments I am making on this blog post and maybe even the next few posts as well. But never mind. The time now BTW, is 6:41 is in the morning. It's cold but very bright and sunny.

Program stucture.

The first thing that csharp hits you in the face with is Namespace. I rekon this is more like java packages than C++ namespaces. Inside a name space you can have classes and interfaces and we all know what they are. Less obvious was Using, this sounds a bit like import package.* in java. Shudder. But perhaps it's more like the same keyword in C++. The program entry point is public static void Main(string[] args) now where have I seen that before?


Why does csharp have so many different types? Who in his right mind will bother with ubyte, ushort or byte instead of using plain old int? What's the good of toasting a few brain cells to save a byte of storage? And here we have the enum  One of my pet hates. That hatred comes from the enum in SQL, but as a result I am generally averse to it's use in other languages too. Not many people use it in python but lots of java folks do. Ccsharp's version seems to be something along the same lines. The struct keyword is straight out of C, so why is it needed in an object oriented language?

Delegates are a bit tricky, it seems to be like a pointer to a function in C which again raises the question of why it's needed, perhaps a better way to think of it would be to compare it to python function which are objects and can be passed around as parameters to other functions or perhaps Java predicates.

While still on the subject of types, you can always trust microsoft to make things as complicated as possible. Proof:

Nullable value types also do not have to be declared before they can be used. For each non-nullable value type T there is a corresponding nullable value type T?, which can hold an additional value, null. For instance, int? is a type that can hold any 32-bit integer or the value null.


Nothing much to write home about here. Pretty much the same as almost any other language. Except for maybe checked and unchecked. If the expression is wrapped in checked it will not raise an exception if there is an arithmatic overflow.

Classes and objects

Again a well traveled path but the internal access modifier was something that I didn't quite get the hang of and I had to brush up on virtual methods to get it through to my head. After so much of Java and Python almost didn't recognize the ':' notation to extend a class as coming from C++. properties smell like @properties in python. Events and event handlers are going to take a bit of getting used to, specially because they are tied to delegates (which I am not 100%) with yet and also because event handlers are added with += and removed with -= . I suppose it does make some sense when you think about it.

This is beginning to look easy. Should have tried this out long before this.

Dec. 6, 2016, 12:33 a.m. » Tagged: csharp , dotnet , vs code

Predictability of tournament results based on ratings.

This is a part of a series of articles on the King Of The Hill Pairing System and it's use at Scrabble tournaments. King Of The Hill or KOTH for short is a strict 1 plays 2, 3 plays 4 , 5 plays 6 pairing system commonly used at the last few rounds of a Scrabble competition. It allows repeat pairing. In other sports it's sometimes used without repeats and then it's called Monrad, Danish Pairing, Australian Draw etc. This analysis is based on the results of the Sri Lanka age group Scrabble Championship 2015. As any Scrabble enthusiast will tell you, Sri Lanka is a power house for scrabble at the junior level, so the conclusions drawn here can be applied in other countries as well.

Pre tournament ratings are an excellent indicator of whether or not a player can be considered a contender for any of the prizes. Past winners of this event have been players with high ratings. The defending champion Hasindu’s rating was 900 at the time he won the event and he entered the tournament with a rating of 1053 which clearly indicates a significant improvement of his playing skill.

A total of 17 rated players took part in the event with the highest being Migara with 1148 points. These 17 players regularly compete against adults and beat them in rated tournaments. The rest of the field only participate in age group or inter schools tournaments which are not rated and the standard of competition is much lower. As a result There is a huge gap between the strengths of the rated and unrated players. 

Rank Name Rating Wins Position Difference
1 Migara Jayasinghe 1148 5 2 -1
2 Aabid Ismail 1134 6 1 1
3 Janul De Silva 1054 4 20 -17
4 Hasindu Arumapperuma 1053 4 13 -9
5 Janidu Karunarathne 964 3 38 -33
6 Thavalakshman Yoganathan 938 4 21 -15
7 Hayati Rassool 924 5 3 4
8 Radinka Dissanayake 897 5 5 3
9 Thirandi De Silva 847 3 37 -28
10 Vignesh Pirapaharan 840 4 15 -5

Table 2.7 Players sorted by rank vs their final position.

Only four of the ten highest rated players managed to secure prizes. As has been shown in 2.3 many of the players who missed out had to play more contenders than the prize winners. It will be shown in the ensuing sections that the pairing effectively prevented these players from winning any prizes.

In previous sections, we had already discussed how the draw had a huge negative impact on Janidu and Thirandi, but Thavalakshman is a special case. The draw did effect him by pitting him against 5th placed Radinka very early in the tournament. He might still have ended up in the top ten if he didn't suffer an unexpected defeat in the last round by just one point!

July 28, 2016, 6:51 a.m. » Tagged: KOTH , Scrabble , Pairing

When should top players meet in a Scrabble tournament?

In any sport, it's undesirable for the top players to play against each other during the early stages of the tournament. When it happens some of them will be knocked out or be out of contention for the top prize. That's why almost all chess tournaments involving a large number of players employ the swiss pairing system. If we take as an example a swiss tournament with 50 players and 5 rounds, the top two players will meet in the fourth or fifth round provided that both of them have managed to defeat all weaker opponents. Thus the overall winner isn't known until very end of the tournament.

A chess tournament

Now suppose the same chess tournament was conducted using King Of The Hill pairing (In chess KOTH is actually known as the Monrad system). Because players are seeded based on their pre tournament rating, if both the top players win their first round game, they would be adjacent to each other in the standings. King of the hill, the simplest pairing system of them all pairs 1 against 2, 3 against 4, 5 plays 6 etc. Thus top two players would be paired against each other in the second round itself. If they draw their game someone else might go on to win the tournament! If either player wins, the loser is immidiately out of contention for the top prize and we are only just at the start of the tournament! The rest of the games are likely to be less interesting.

How does it work at Scrabble tournaments that employ KOTH? Lets look at the results from the Sri Lanka Age Group Scrabble Championship 2015 to see what happens. Janul entered the tournament as the third highest rated player. Migara had the highest pre tournament rating and he also happened to be the champion of 2013. They met in the second round and Janul lost. Hasindu was 4th in pre tournament ratings and he entered the tournament as defending champion. He met 5th rated Janidu in the second round. Hasindu lost. Which meant at the end of the seond round the defending champion had practically been knocked out!

The software used for pairing this tournament was TSH, and it's website speaks thus:

“Top players should be paired with each other, especially toward the end of the tournament. King-of-the-Hill pairings do this best, Round Robin pairings do this worst.” (Chew, John 2016)

This statement clearly isn't very accurate, the following table which highlights the number of prize winning players met by each top 10 finisher provides more proof. It allso provides the Average Opponent Rank for the same players.


position Player Average Opponent Rank Opponents Among prize winners
1 Aabid Ismail 16.67 1
2 Migara Jayasinghe 42.83 0
3 Hayati Rassool 32.50 2
4 Hansi Weerasooriya 22.67 3
5 Radinka Dissanayake 28.17 2
6 Rehan Wijesekera 46.17 1
7 Danusha Muhandiramge 31.50 2
8 Yenuli Hewage 35.50 0
9 Navodya Jayaratna 37.50 1
10 Akshai Yogalingam 56.67 0

As well as their Average Opponent Rank. Three of the prize winners have not played against any other prize winners at all. Akshai has not played any prize winner and as will be shown in section 2.4 has not played with any top ten rated players either.

The last round of the tournament saw Aabid paired against Hansi as they were ranked first and second based on round 5 results. This was the only occasion where the champion was paired with another prize winner or another top rated player.

Thus King Of The Hill pairing has failed to ensure that top players meet towards the end of the tournament.

July 13, 2016, 6:28 a.m. » Tagged: scrabble , chess , swiss , dutch , koth

Average points scored in a game of Scrabble.

What is a good score in a game of Scrabble? Nigel Richards averages 462.54 in international tournaments. He has gone past 400 points 84.41% of the time. Craig Beavers averages 438.59 and has gone past 400 points 73.34% of the time. Mind you these are international tournaments where they would be coming up against strong opponents most of the time. Their averages would go up considerably if national level and state level tournaments were also taken into consideration. Anyway, this is not an exhaustive study on average game score, it's merely a study on the use of average game scores to evaluate the fairness of the pairing system (what's colloquialy know as the draw).

At the Age Group Scrabble Championship 2016, weaker players struggled to pass 300, the top rated players notched up 500+ and even 600+ scores with ease. That was due to a huge disparity between the top players who are some of the best young Scrabblers in the world and others who compete only at the domestic level. This disparity makes it possible to use the average number of points scored by each player as an indicator of the leve of competition faced by that player.

Position Name Wins Margin Mean Points
13 Hasindu Arumapperuma 4 1409 506
1 Aabid Ismail 6 829 475
37 Thirandi De Silva 3 660 461
14 Shakeel Ahamed Ajim 4 754 459
3 Hayati Rassool 5 738 450
38 Janidu Karunarathne 3 619 443
15 Vignesh Pirapaharan 4 494 434
16 Hemaka Gunasekera 4 492 432
20 Janul De Silva 4 404 429
2 Migara Jayasinghe 5 746 428

Table 1 Average (mean) points per game and marging sorted by average points

Janul won the prize for highest game score by racking up 646 in the first round. Despite two losses defending champion Hasindu averaged 506 per game, 31 points higher than the new champion's average. Hasindu had three scores between 500 - 600 and once scored 625. Hasindu’s lowest score was 367. That means Hasindu’s lowest score is higher that 91% of scores in the entire tournament.

As with many other comparisons for this event Aabid is right up there with the best. It shows that despite it’s faults King Of The Hill (KOTH) is capable of selecting a champion. However only three other prize winners make it to this list.

37th placed Thirandi averaged 461 per game which is the third highest despite losing three games and she has a healthy margin of 660 points too (sixth highest among all players). Janidu with 443 was 38th. Compare this with an average of 259 for 36th placed Jithmi Linara.


Position Name Wins Margin Mean Points
1 Aabid Ismail 6 829 475
2 Migara Jayasinghe 5 746 428
3 Hayati Rassool 5 738 450
4 Hansi Weerasooriya 5 630 425
5 Radinka Dissanayake 5 574 421
6 Rehan Wijesekera 5 481 427
7 Danusha Muhandiramge 5 421 406
8 Yenuli Hewage 5 417 379
9 Navodya Jayaratna 5 400 383
10 Akshai Yogalingam 5 269 326

Table 2 Average scores for the prize winners

The first 7 prize winners have very respectable average number of points scored but for the last three places the spread and the average per game is much below par.

Position Name Wins Margin Mean Points
2 Migara Jayasinghe 5 746 428
1 Aabid Ismail 6 829 475
20 Janul De Silva 4 404 429
13 Hasindu Arumapperuma 4 1409 506
38 Janidu Karunarathne 3 619 443
21 Thavalakshman Yoganathan 4 390 381
3 Hayati Rassool 5 738 450
5 Radinka Dissanayake 5 574 421
37 Thirandi De Silva 3 660 461
15 Vignesh Pirapaharan 4 494



Table 3 Average scores for the rated players.

Though six of the rated players have not managed to get on the prize list, they have done very well in terms of average points score. The lowest amongst them is 381 by Thavalakshman. He would be disapointed with that. But it is still a respectable score.

So in conclusion it can be seen that King Of The Hill is grossly unfair if you use Average Points Score as a measure of performance. Earlier we looked at Buchholz score and Average Opponent Rank to find that KOTH has been grossly unfair.

Do I rest my case? Not yet. We will next look at Aristomancy to judge the effectiveness of the pairing system

July 11, 2016, 5:21 a.m. » Tagged: Scrabble , KOTH , Pairing

Buchholz score as a measure of fairness of the draw.

Average Ratings of Opponents, the Buchholz and Sonneborn-Berger System are some of the methods recommended by FIDE for breaking ties in Chess tournaments. While ties are the order of the day in chess tournaments, in the Scrabble world it is virtually unheard of. But what works for tie breaking in chess works well for evaluating Scrabble pairings. We will take a closer look at Buchholz in this post particularly since it's one recommended by John Chew, the creator of Tournament Shell for exactly this purpose.

The sum of opponent scores or Buchholz is “..the idea is that the same score is more valuable if achieved against players with better performances in a given tournament. Looks like an ideal tie-breaking method and has been used since the Swiss system was invented.” (Swissperfect, 2008) 

In this context the score means the number of games won by each player. To avoid confusion with the number of points scored on the board, the term Bucholz score will be used when the discussion is about the total number of games won by a player's’ opponents. And this discussion is about evaluating the fairness of King Of The Hill pairings in Scrabble. This is fourth part in a series. 

For example Hayati played against Erandi (3 wins), Thirandi ( 3 wins), Danusha ( 5 wins), Janidu (3 wins), Lalinka ( 3 wins), Navodya (5 wins) so her Buchholz score is 22. This is what is looks like for all the prize winners.


Position name Buchholz score
1 Aabid Ismail 25
2 Migara Jayasinghe 19
3 Hayati Rassool 22
4 Hansi Weerasooriya 26
5 Radinka Dissanayake 24
6 Rehan Wijesekera 19
7 Danusha Muhandiramge 23
8 Yenuli Hewage 21
9 Navodya Jayaratna 22
10 Akshai Yogalingam 17

Table 2.4 Sum of opponents scores for each of the prize winners

Most of the prize winners have a Buchholz score greater than 20. For Akshai, it's only 17 but that's reasonably since he is placed only tenth overall isn't it? Let's see what the next table, it lists the players with the best Buchholz scores


Position Name Buchholz score
4 Hansi Weerasooriya 26
1 Aabid Ismail 25
5 Radinka Dissanayake 24
25 Qays Sangani 24
41 Lalinka De Silva 24
18 Nikesh Moorthy 24
20 Janul De Silva 23
16 Hemaka Gunasekera 23
7 Danusha Muhandiramge 23
75 Therunee Karunaratne 23
30 R Nikesh 23
23 Harindu Wijayanayake 23

Table 2.5 Players with the highest Buchholz scores.

There are 12 players with a Buchholz score of at least 23 and one of them Therunee ended up in 75th place. For comparison purposes the player at the 76th position had a score of 14. Among the prize winners only four players had a score of 24 or more. Let's also take a look at the table for top rated players.


Rank name Buchholz score
1 Migara Jayasinghe 19
2 Aabid Ismail 25
3 Janul De Silva 23
4 Hasindu Arumapperuma 20
5 Janidu Karunarathne 21
6 Thavalakshman Yoganathan 21
7 Hayati Rassool 22
8 Radinka Dissanayake 24
9 Thirandi De Silva 22
10 Vignesh Pirapaharan 17

Migara and Rehan suffered losses in the third and fourth rounds so their Buchholz scores are only 19 but Hasindu who suffered a loss in the second round and another loss in the third round still has a Buchholz score of 20 as shown in the table above.

Except for Vignesh most of the other rated players have Buchholz scores that compare favourably with the prize winners. Except that many of these players didn't actually win any prizes!

Though Janul lost the second game he obviously didn’t have an easy time of it from that point onwards, as can be seen by the fact that his opponents racked up 23 wins among themselves. In other words, Janul kept running into tough opponents who were all lurking in the second half of the field! Janul's Buchholz score is higher than that of five of the prize winners.

Thus in conclusion, the pairing system (King Of The Hill) has not treated all players equally as shown by the huge disparity in Buchholz scores. But I am not going to rest my case! There is a lot more evidence coming up!

July 5, 2016, 5:17 a.m. » Tagged: chess , scrabble , buchholz , KOTH

Fairness of KOTH pairing.

This is part three, in a series of posts on King Of The Hill pairings a widely used pairing system at Scrabble tournaments. The analysis is carried out using the results of the Age Group Scrabble Championship 2015.. The tables on this post can be recreated by web scraping the contents of the above link.

The fairness of the draw can be calculated based on three different criteria as described on the official website of tsh, the most widely used pairing software in Scrabble and the one used for this tournament

Average Opponent Rank

The rank of a player is the position he occupied at the end of the tournament. Therefore Average Opponent Rank is the sum of the rank of each opponent faced by a given player divided by the number of rounds.

As an example Qays played against Lochana, Zahra, Rizvi, Ashvin, Duilini and Radinka their ranks were 34, 42, 11, 58, 24 and 5 which add to 174 and averages to 29. Players with lower Average Opponent Rank (AOR) have faced stiffer competition.

The table below outlines the average opponent rank sorted by AOR in ascending order. Lower AOR means the player's opponents secured better placings.

Position Name Average Opponent Rank Number of prize winning opponents
1 Aabid Ismail 16.67 1
4 Hansi Weerasooriya 22.67 3
41 Lalinka De Silva 24.50 3
18 Nikesh Moorthy 27.17 2
75 Therunee Karunaratne 27.67 2
20 Janul De Silva 28.00 2
5 Radinka Dissanayake 28.17 2
25 Qays Sangani 29.00 1
7 Danusha Muhandiramge 31.50 2
37 Thirandi De Silva 32.17 1

Table 1: Best Average Opponent Ranks

Only four of the prize winners figure in this list but the champion has the best AOR of all players. 75th placed Therunee and 41st placed Lalinka have better AORs than eight of the prize winners. Lalinka and Hansi were the only players to meet three prize winners. Lalinka managed to win two of those games (vs Migara and Yenuli) yet her own position is 41st.

Compare the above with the next table which examines the AOR figures for top rated players.

Position Rating Name AOR Prize Winning opponents
1 1134 Aabid Ismail 16.67 1
20 1054 Janul De Silva 28.00 2
5 897 Radinka Dissanayake 28.17 2
37 847 Thirandi De Silva 32.17 1
3 924 Hayati Rassool 32.50 2
38 964 Janidu Karunarathne 35.33 2
21 938 Thavalakshman Yoganathan 37.00 2
2 1148 Migara Jayasinghe 42.83 0
13 1053 Hasindu Arumapperuma 44.83 0
15 840 Vignesh Pirapaharan 49.17 0

Though top rated players are the most likely contenders for the title as well as the remaining nine prizes, and the stated objective of KOTH is to pair contenders, three of the top rated players haven’t been paired against prize winners at all. These three happen to be two former under 18 champions and a two time under 13 champion!!

Thus the Average Opponent Rank shows that there is considerable disparity in the manner in which rated players were paired and KOTH has failed to fulfil its objectives. Based on Average Opponent Rank, King of the Hill has been anything but fair

(Note: Average opponent rank table for Prize winners is presented in section 2.3)

July 4, 2016, 7:15 a.m. » Tagged: KOTH , Pairing , Scrabble

Analysis of Pairing Systems : Definition of Terms.

This the continuation of a series of articles that analyses the King of The Hill pairing system. Before we get to the analysis proper, we need to get some definitions out of the way.


The King Of The Hill Pairing system, which is a strict 1 plays 2, 3 plays 4 .. (2n-1) plays 2n pairing system.


A reference to the Swiss Pairing system which is almost always the format that is used for tournaments where the number of players exceeds the number of rounds. It finds widespread usage in scrabble and some other sports too

Prize winner

It is customary in Scrabble tournaments to award prizes and/or certificates to players who finish with in the top 10 at the end of the tournament. These persons will be called prize winners

Rated Player

Age Group Scrabble Championship is the only tournament conducted by the SLSL that specifically targets beginners. As a result it attracts a disproportionate number of novices. There is a huge gap between these players and rated players. For the purpose of this discussion a rated player is a person whose name appears on the SLSL ratings list. Further the players with the 10 highest ratings will be called the top rated players.


A person who is either a prize winner or a top rated player

Strong Player

Players who have scored an average of 365 points per game will be defined as a strong player. Only the top quartile had an average greater than 365 .

June 30, 2016, 4:44 a.m. » Tagged: KOTH , Scrabble , Pairing

King Of The Hill Pairing System - An Analysis.

The King Of The Hill pairing system is one where the “Top ranked plays second, third plays fourth, etc. Usually used for the last round(s) of the tournament” (NSA 2008, p53) “KOTH pairings are often used in the final round(s) of a tournament to ensure that contenders face each other” (Chew, John 2015)

This is the start of a series of posts on the King Of The Hill Pairing system based on the results of the results of the Sri Lanka Age Group Scrabble Championship 2015. Before you run of thinking Sri Lanka, Bah! Consider that this was a tournament in which three of the top 10 finishers at the World Youth Scrabble Championship took part. In fact Sri Lanka is a country that has produced many a strong performer at international level

KOTH was used for pairing 5 out of 6 rounds at the All Island Age Group Scrabble Championships in 2015 and 2014. In previous years when KOTH was only used it was only in the last round of the tournament. The format is also used in 6 out of 18 rounds at the Scrabbler of the Year tournaments held four times a year.

“It is estimated that as many as 75-80% of all tournaments use the KOTH for the last one or two rounds, including many R-R events. But, almost none use KOTH in the early rounds.” (NSA 2008, p53)



Chew, John. 2015. 'Tsh: Commands'. Poslarchive.Com. http://www.poslarchive.com/tsh/doc/commands.html#pairing.

>2008. New York: National Scrabble Association.

June 28, 2016, 5:41 a.m. » Tagged: scrabble , pairing , KOTH