Jesper Niedermann's .NET Blog
about .NET and related technologies RSS 2.0
# Thursday, 28 July 2011

When making the WP7 game Photo Challenge we quickly agreed that we needed leaderboards. The problem is that is time consuming to build a scalable high quality leaderboard service tailor made for our game and secondly we would have to pay for server storage for a game that statistically won’t make a dime anyway. This meant that we searched for a ready to use leaderboard service. It wasn’t easy to find. But then a miracle happened. We found the amazing Mogade.com.

Mogade.com is an incredible fit for our game.

Features:

  • Most importantly there is great support from the developer Karl Seguin when you run into trouble (which we did – actually one of our problems led him to find and fix a bug in the service).
  • It has an easy to use API. The basic API is Rest based with data transferred in JSon format. This means that is possible to access the leaderboards from any application. I am currently working on an ASP.NET MVC / JQuery based web page to access our leaderboards on the web.
  • On top of the REST API there is a WP7 API which you can reference from your game and it looks like an Android API is currently under development.
  • When you register an account you gain access to adding any number of games, to each of these games you can add a number of leaderboards.
  • Furthermore mogade.com supports achievements and even has some Facebook integration which I haven’t looked into yet.
  • There is also statistics. A cheap way to see the popularity of your game. On the AppHubs you can see number of downloads, but on Mogade.com you can actually see how many are playing your game.
  • For accessing a leaderboard from your game you use a gamekey a  leaderboardkey and a secret. Each of these are Guid like Id’s. You can fetch pages of 50 scores at a time, and you can get the Rank of a specific user.
  • The leaderboards can be defined as High-to-low or low-to-high. Meaning if it is preferable to have a low or a high score.
  • Each score is associated with a username, a rank and the date&time at which the score was added.
  • In the WP7 API there are a number of ways to define a user in mogade.com terms e.g. one uses your liveid and another the deviceid combined with a username. The last one is the one we use. This means that 2 users with the same username but different phones will be two distinct users on the leaderboard.

To get started you should download the code from Github https://github.com/mogade/mogade-windowsphone and look at the samples there. Furthermore I found this nice blogpost to help me get going http://briansolli.wordpress.com/2011/03/30/online-leaderboard-for-your-wp7-game

In http://www.niedermann.dk/2011/07/26/PhotoChallengeReleased.aspx you can see a screenshot of the graphical look of the leaderboard we came up with in Photo Challenge.

Thursday, 28 July 2011 23:35:35 (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Games & Puzzles | Windows Phone 7
# Tuesday, 26 July 2011

I and a team of 1 graphic artist and 1 sound engineer just finished our first game for Windows Phone 7 called “Photo Challenge” a few weeks ago. We planned this pretty simple game to get experience before going for the big hit. The concept has been seen before. A Puzzle Slider where you have to solve a square puzzle with 2x2, 3x3, 4x4, 5x5 or 6x6 squares with one square missing. The Puzzle can be made from you own photos or from some build in ones. Here is a few screenshots:

screenshot_1screenshot_2screenshot_4screenshot_7

The point of the game is to solve the puzzle as fast as possible to make it to the leaderboards. We used the great service Mogade.com for the leaderboards. I plan to cover that aspect in another post.

We are very satisfied with the style and feel of the final game. Even for such a simple game details are important. Similar competing games seems to have been made in Silverlight and thus are more limited with regards to graphics and sound than our XNA game.

Some of the learnings from making the game are:

  • XNA is a fantastic framework and my own framework for XNA developed over time for PC and XBox could be used directly with very few changes.
  • WP7 has a fantastic developer platform. IMO better than the iPhones.
  • The WP7 API’s still lacks a lot of functionality that is present in the iPhone API’s but slowly catching up.
  • If you use some of the build in “Tasks” like the PhotoChooserTask or the MarketplaceReviewTask you cannot play sounds on the device if it is connected via USB to the computer. Sounds like a small thing but it means you cannot debug on the device ! Really horrible. My solution was to not play music and sound effects in the DEBUG edition.
  • On the other hand you can debug on the emulator. On the iPhone it is extremly important to debug directly on the iPhone because the iPhone simulator cannot be trusted. I have often experienced that code working in the iPhone simulator was not working on the device. This never happened once for the WP7 emulator and my Samsung Omnia 7. Still it is important to be able to debug on the device since there are things not available in the emulator.
  • As mentioned the API is somewhat lacking. E.g it is impossible to send images in emails via the EmailComposeTask. It is not possible to integrate facebook in an XNA app and so forth. The last one is supposed to be fixed in the Mango update since it has opened up for mixing Silverlight and XNA. I have not tried it yet. But hope it will be possible. Facebook integration in games is almost a must these days.
  • Despite being extremely happy with the developing experience for WP7 the iPhone is still an overall better smartphone experience in my opinion (seen from a user perspective). I hope and think WP7 will catch up in time. Competition is good.
Tuesday, 26 July 2011 23:47:58 (GMT Daylight Time, UTC+01:00)  #    Comments [5] -
Games & Puzzles | Windows Phone 7 | XNA
# Friday, 13 November 2009

I am currently developing the game Klimakonflikt with 5 other guys. It is a Retro arcade game, Pac-man style, with nice 2D Graphics and music. Here is a screenshot from the game:

klimakonflikt_screenshot

The current release, documentation and source code can be downloaded from here http://klimakonflikt.codeplex.com 

The game is inherently for 2 players but we are working on the single player edition. The AI in the current release is pretty daft, but in the next release it will be much improved. Also we are working on a WPF leveleditor, powerups and other fun stuff.

One of my co-developers Jakob has released a blog about the game and XNA development in general at http://xnafan.net

Friday, 13 November 2009 23:11:29 (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Games & Puzzles | WPF | XNA
# Monday, 03 August 2009

I must admit that I have never understood why it was fun to solve Sudoku's. But as a programmer I was fascinated with the idea of making the perfect Sudoku puzzle generator algorithm from the very first time I heard of Sudoku. Of course I wanted to make it so general that it could not only make the boring old 9x9 sudoku. But sodukus of any size 4x4, 9x9, 16x16, 25x25 and so on...

This resulted in a .NET 1.1 WinForms program 4-5 years ago in which I could randomly generate all sudoku combinations from 4x4 to 36x36. I created an algorithm that started in the upper left corner and put in a random number then moving to the next square put in a new random number from the remaining numbers. This meant that the algorithm had to backtrack when coming to a deadend where no number was valid. This approach guaranteed that all possible Sudokus could be generated, but it was extremely slow. Well for 9x9 sudokus it was less than a second but for 36x36 sudokus it was around 16 hours :O)

A few weeks ago I thought it was time to try out Silverlight and make a small program to test Microsofts "new" programming platform, but I had to come up with an idea for a small program. And for some reason Sudoku popped up again.

And I came up with a novel idea for an extremely fast generator (try it here). It has been said that no ideas are new anymore and I am pretty sure that I am not the first to think of this since the algorithm is pretty obvious. I start with a valid Sudoku as a template and then apply transformations of the columns, the rows and the numbers themselves.

To generate a valid Sudoku I first generate the template. The template is generated by starting with 1 in the upper left corner and then counting upwards. Next I go to the 4th row and start in the second column counting from 1 again like this:

s1

Next I go to the 7th row and the 3rd columm and so on. So I add 3 rows (the square root of 9) each time. In a 16x16 sudoku I add 4 rows each time. The final template is generated in a few milliseconds even in a 400x400 Sudoku. The final template for a 9x9 sudoku looks like this:

s2

The template is itself a valid Sudoku.

Now I make the transformation using an observation I have made. In any valid Sudoku I can make another valid Sudoku by switching the columns within each block of 3 columns. As indicated in red colour for the first block above.

Secondly I can do the same for the rows.

And last I can transform the numbers themselves so that all 1's are transformed to a number from 1 to 9. all 2's are transformed to one of the remaining 8 numbers and so on.

I could also have applied a 4th transformation  that switched the big blocks as columns and rows, but I don't think that it will add much value.

In all this the entire puzzle can be generated in milliseconds for even extremely big Sudokus.

Try it out yourself at http://www.niedermann.dk/Sudoku/Sudoku.aspx

A few calculations

Now for some thoughts on completeness.

A 4x4 Sudoku has 4x3x2x3x2x2 = 288 possible combinations. Not counting combinations for empty tiles. In my original algorithm I was sure I covered all these combinations.

When using my new algorithm I can generate 2x2x2x2x4x3x2 = 384 possible transformations for a 4x4 Sudoku. This is more than the number of possible Sudokus. Which means that some of these transformations must result in the same Sudokus. And furthermore I do not know if there are Sudokus not covered by the transformations.

In a 9x9 Sudoku there are 1,83493E+21 possible Sudokus and I can generate 264.539.520 of those or 2.380.855.680 if I had used the extra big block transformations. Not complete at all, but on the other hand a very large amount of Sudokus and at lightning speed.

Empty tiles

A Sudoku isn't really a Sudoku without the empty tiles left for the person to fill out.

I just generate the empty tiles by choosing them at random. This method could probably lead to either very boring Sudokus or Sudokus that are impossible to solve. One day I might device some clever algorithm for emptying tiles in a more interesting fashion :O)

Silverlight

My conlusions on this my very first silverlight project is that it is extremely easy to make something appealing in silverlight. On the other hand there are som downsides. It is difficult to communicate between different silverlight hosts. I can only pass strings. When you hit the print button I open another browser window. And I actually have to serialize the Sudoku Grid and deserialize it again in the print window.

Another downside is that is not really browser agnostic. I have tried with 3 browsers IE8, IE7 and Firefox 3.5. Right now the only one working properly is IE8. In IE7 the new browser I open for printing has no menu, and so you cannot really print :O) In Firefox the silverlighthost cannot be resized, which is apparently a known issue. But it is a problem in the Sudoku generator because I offer Sudokus of any size. This means that in Firefox only 4x4 and 9x9 Sudokus will look good.

BTW: The rendering of a very large Sudoku takes some time of course even though the generation is over in milliseconds.

For my next silverlight project I think I will try out Prism and also the Out-of-browser experience.

Monday, 03 August 2009 22:16:48 (GMT Daylight Time, UTC+01:00)  #    Comments [5] -
Games & Puzzles
Archive
<2017 June>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678
About the author/Disclaimer
I am a software architect with focus on Microsoft Technologies. I have been working with these in different large companies since 1995. I am currently employed at UVdata A/S.
Here is my View Jesper Niedermann's profile on LinkedIn

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Privacy policy
The privacy policy of this site.

© Copyright 2017
Jesper Niedermann
Sign In
Statistics
Total Posts: 28
This Year: 0
This Month: 0
This Week: 0
Comments: 32
All Content © 2017, Jesper Niedermann
DasBlog theme 'Niedermann' created by Jesper Niedermann, based on 'Business' created by Christoph De Baene (delarou)