Guide to install vsftp on Ubuntu Server on Windows Azure
June 7, 2013 – 11:50 pm | 6 Comments

Once you install a Linux box on Azure you will want some way to send files to and from it. There are plenty of options but one way is to use plain old FTP. The …

Read the full story »
Online Gaming

All about online gaming focusing mainly on First Person Shooters on the PC platform. Consoles may get a mention also but PCZFTW

Game Programming

If its making mods using scripting languages like Unrealscript or dealing with SDK’s like DirectX using C++ it’s in here.

Dot NET

Focusing on the Windows .NET platform. Programming in C# using Visual Studio.

General Computing

Everything got to do with using computers. Whether its Windows, Linux, Mac or other flavour its in here.

Computer Hardware

Graphics Cards, CPU’s, Memory and everything else got to do with building your own PC and modding your existing ones.

Dot NET, Game Programming »

Tic Tac Toe in 2 lines of C# code
June 14, 2013 – 9:11 pm | No Comment
TicTacToe Code

Visual Studio Auto Code Formatting

Tic Tac Toe

2 Line TicTacToe Running

For fun I have been trying to see how compact I could write a game of TicTacToe. I started with an old version I had wrote a while back that was about 60 lines and gradually worked my way down. What I’m left with is a call to Console.Write and a recursive call to Main. Obviously the readability leaves a lot to be desired but the game works.

Code Below


class Program { // Created By: John Cleary, WWW: www.johncleary.net, Email: clearz@gmail.com
    static void Main(string[] foo) {
        for (var i = 0; i < 9; System.Console.Write((foo = (foo.Length == 0 || foo[3] != "") ? new[] { "0", "0", "O", "" } : foo)[3] + (i == 0 ? "\n\n 1 2 3\n\n 1 " : "") + (((int)(System.Math.Pow(2, i)) & int.Parse(foo[0])) != 0 ? "O" : ((int)(System.Math.Pow(2, i)) & int.Parse(foo[1])) != 0 ? "X" : ((i < 6) ? "_" : " ")) + ((i % 3 < 2) ? "|" : "") + (++i % 3 == 0 ? "\n " + (i < 9 ? (i / 3 + 1) + " " : "") : ""));
        System.Linq.Enumerable.Any(new[] { 7, 56, 73, 84, 146, 273, 292, 448 }, t => (int.Parse(foo[foo[2] == "X" ? 1 : 0]) & t) == t)) ? (foo[3] = ("\n Tic Tac Toe Biaaaatch! '" + foo[2] + "' wins.\n Press any key to play again. ")) : "\n " + (foo[2] = (foo[2] == "O") ? "X" : "O") + "'s turn.\n Enter the row and col you want it in: ";
        Main(System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(foo, (s, i) => (i == (foo[2] == "O" ? 0 : 1) ? (int.Parse(foo[i]) + (int)(System.Math.Pow(2, (3 * (System.Console.ReadKey(foo[3] != "").KeyChar - 49) + (foo[3] == "" ? System.Console.ReadKey().KeyChar - 49 : 0))))).ToString() : s))));
    }
}

Ok yes the lines are kind of longish and there is more than two, seven to be exact but the last two are both closing braces and the first two are a class and method declarations. That leaves three lines of game code which all end in a semi-colon which is my defination of a line of code. The first two lines could be combined into the one call to Console.Write which would leave 2 lines of accual code which is where the title comes from. I like leaving it with 3 lines better because then each line has a singleish function. Line 1 Draws the game board, Line 2 Checks the game state and Line 3 gets input. So there it is, Tic Tac Toe in 7 3 2 lines of code.

Download JTunes iTunes Windows Service
November 28, 2009 – 4:52 am | 106 Comments
Download JTunes iTunes Windows Service

Update 21st July 2013
I will be releasing a new version of JTunes in the comming weeks. If you would like to be notified of the release date simply leave your email in the box on …