5x5 Updated...... V1.5 The Knights Gauntlet.......... Now with demo mode.

Search This thread

stephj

Inactive Recognized Developer
May 2, 2007
721
101
Lancashire
There is a game on the iPhone called Lights Out where the object of the game is to light up or knock out all the lights in a 5x5 grid. When a square is selected that square and its four immediate neighbours, above, below, and to each side invert. There is no wraparound. The object of the game is to get all the squares black.

At the risk of revealing my age, I saw a hand held version of this game in the early 1980's.

When mastering any new programming platform, this application becomes the standard with which I start. I know the logic, so the problem merely becomes getting the thing to run under the new platform. I wrote this in 2005 while fighting my way through the very steep learning curve of Embedded C++. Previous platforms for this program have been, ZX81, BBC Micro, DOS, Windows and finally Windows Mobile. Next stop Linux!

It is an example of minimalist programming on WM. Written in Embedded C++ as a Win32 application it is targetted at ARMv4 chipsets. As such it should run on all PPC versions from Windows Mobile 2002 onwards. The menu is limited to two main items, so WM 5/6 will display it as a WM 5/6 app. Minimalist programming means it can be distributed as as a single .EXE file of a mere 9.5 Kb in size. The DLLs it calls are already on your device, there is no need for a .CAB installation.


It has 5x5, 7x7 and 9x9 grids, all are solvable.

I hope you enjoy it. It will keep you quiet but it might drive you totally nuts!

UPDATE!!! Now works with 480x800/240x400 devices, see later posts for the details.

UPDATED!! Version 1.2 released.

Changes: 11x11 grid added. It is solvable, but it took me a while to figure it out!. You may need a stylus as fingers may be a bit too awkward. For that reason, I do not intend to go to 13x13 and beyond.

The short display glitch on initial program load now fixed.

Game and drawing code optimised. (There are often better and faster ways to do things, if you take the time to look.)

UPDATED!! Version 1.3 released.

Now also runs on both Pocket PC and SmartPhone devices. Now runs on any sized screen, even those that have not been released yet! The blank screens that were reported in later posts are now a thing of the past. Here's the method, take the width and height of of the client area and size the game to 90% of smaller of the two. Why did I not think of that in the first place?

SmartPhone users:- Welcome aboard! Image attached below: The white square is the target square. Move it to the square you want to change with the D-Pad/Arrow buttons, then press 'Enter' to change it. Smartphones prior to Mobile 6.0 may not have the 'File Explorer' application. (It depends on the OEM build). In this case, use ActiveSync. Connect to your phone and drop the unzipped 5x5.exe file via the 'Explore' option into the \Windows\Start Menu\Programs\Games\ directory, and it will appear alongside Solitaire and BubbleBreaker in the games menu of your device. Smartphone 2002/2003 users need to use \Storage\Windows\Start Menu\Programs\Games\

Pocket PC users won't see any change, just tap the square you want to change. The program looks at which platform it is running on, and behaves accordingly.

UPDATED!! Version 1.4 released. - The Knight's Gauntlet.

Just when you thought you've mastered it, the Knight's Gauntlet is firmly thrown down. Selecting Knights from the main 5x5 menu, changes the pattern of squares that are inverted to those a knight's move away in chess, (two forward, then one to the side), as per the Knights image below. Up to 9 squares will invert on each move. As per changing the grid size, toggling the knights game on and off will restart the game.

All four grid sizes are solvable, but you are warned, it is a lot harder than the normal cross game.

It was only a small change to the game logic, and this program was all ready to go in September, but I would not release it, until I had proved to myself that it could be done. A brute force attack can be used to break the 5x5 Knight's game but as the grid gets bigger the problem grows exponentially. A quad core processor running a console C++ application, using the SSE3 PC registers (XMM) macros to play one move on the entire board in one machine instruction, was not enough.

I had to use a special version of the mobile program that could dump the state of the board and moves out to a file to be analysed by the PC later by a suite of programs that could combine boards together by the thousands. All good fun!

On and off, it has taken me three months to find the knights solutions to the 7x7, 9x9 and 11x11 games.

UPDATED!! Version 1.5 released. Now with demo mode.

For those who think it is impossible, let the demo mode show you how to do it.... But there is a slight twist........ You will be shown the same solution for each puzzle each time, but the moves are shuffled and they may also be reflected or rotated, just to confuse matters further. Shuffling the moves, rotating, or reflecting, logically, has no effect on the final result.

Happy puzzling!

18th Feb 2010 update fixes WinMo 6.5.3 Dialog box issue mentioned in http://xdaforums.com/showthread.php?t=635063

23 June 2011 CE version added. Note this version is for Windows CE, ARM powered devices only, as is displayed in the last of the images below. Don't run this version on a WinMo device the display will look awful! As an extra caveat, it will only run properly if the OEM of your CE device has built the OS with components that are expected by the 'Standard' version of the SDK as used by EVC 4.0.
 

Attachments

  • Knights.JPG
    Knights.JPG
    30.6 KB · Views: 177
  • Smart5x5.JPG
    Smart5x5.JPG
    26.6 KB · Views: 92
  • 5x5.JPG
    5x5.JPG
    29.8 KB · Views: 97
  • 5x5.zip
    5.6 KB · Views: 141
  • CE5x5.JPG
    CE5x5.JPG
    19.3 KB · Views: 67
  • WinCE_5x5.zip
    4.9 KB · Views: 75
Last edited:

gil@spoontools.com

Senior Member
Apr 15, 2007
58
0
Small problem

Hi,

I'm probably missing something here, but I get a white screen without anything I can actually do with it (using Omnia).

Any help?
 

stephj

Inactive Recognized Developer
May 2, 2007
721
101
Lancashire
Anybody thown their phone out the window in frustration yet?

To the members having trouble with high resolution devices, it was only written to run on 'standard' Pocket PC screens, 240x320 portrait/landscape and 240 square devices.

Sorry it doesn't work properly on larger screens. I'll have a look at it. I may have to borrow one of these later wizzo phones from someone, and find out what's going wrong, or I'll see what's in the WM6 SDK emulator.

May take a while, but I'm on it. Watch this space.
 

marcelvanblankers

Senior Member
May 3, 2007
176
1
doesn't work on touch diamond 2 with 800x480?
any solution you might know?

anybody??

seems like a great hit, this game.....


tnx in advance

marcel
 

stephj

Inactive Recognized Developer
May 2, 2007
721
101
Lancashire
I have downloaded the WM 6.1.4 SDK from Microsoft's site. It includes a 800x480 device image.

The bad news is the program produces the effect mentioned above. i.e white screen, and nothing.

The good news is exactly that, the bug can be reproduced. This will allow me to step through it, figure out exactly what the hell is going wrong, and fix the code.

This may take few days to sort out, more later.
 
Last edited:

stephj

Inactive Recognized Developer
May 2, 2007
721
101
Lancashire
Fixed! Now works on 800x480 devices as well, in landscape or portrait. Use the zip file in the original post at the top, it has been updated with the new program.

The reason for the fault was that 800x480 devices return a bigger value for the long side of the screen when using GetClientRect();

The program did not recognise this value and could not figure out whether it was landscape, portrait or square, which fouled up the WM_PAINT code.

The code automatically centres the grid in the window, so that bit was OK.

Have fun, until a new screen format comes along.........
 
Last edited:

nickio1230

Senior Member
Feb 7, 2009
61
46
HOLLY BALLS! lol this game is addicting and hard. i am yet to beat it!! haha. great game thanks! :)
 

stephj

Inactive Recognized Developer
May 2, 2007
721
101
Lancashire
Reply to GreenOmnia

GreenOmnia,

This program will run on 480x800 devices as marcelvanblankers above can confirm. The problem may be that you still have the old version of 5x5 active in your phone.

On a PC you can run multiple versions of Word, Excel etc. until you run out of memory. Under WM only one version of any program is allowed to run at any one time. When a program starts it looks for the same named process. If it finds it it, it activates that copy, and then kills itself. Later versions of WM may correct this, but earlier programs still run to these rules. If you load a new version of the program to your phone and have the old version still active in memory, when you run the new one you only reactivate the old one.

Listen up everybody! Think about the above paragraph. If you have understood it, that is a real WM pearl of wisdom!

To fix the problem, if your version of WM has Task Manager, use that to kill the running version of 5x5, or use Settings->System->Memory->Running Programs and then select 5x5 and end it. Delete all versions of 5x5 from your phone, then reload the new version from the top post in this thread and retry it.

If all this still doesn't work, I will post a test program to run on your device that reports the actual size of the client area window.

We'll take it from there.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Now some solutions are starting to appear, it is time to 'up the ante' a little.

    Consider the following point.

    As you first start to play the game, it soon becomes clear, that if you tap a square, then tap it again, it undoes the previous move. No big surprises there.

    What might not be so obvious, is that if you tap a square, tap a few others and then tap the original square again, the final result is exactly the same as if you had never tapped the original square in the first place!

    In a nutshell, pairs of clicks of the same square are redundant. You have just wasted two moves! In the example quoted above in the previous post for the 5x5 solution, moves 1 and 20 are identical. Cross them both out, and the puzzle will still solve in two fewer moves.

    Try it out...........

    Now......., solve it it fewer moves!