2010/04/08

Squares

The first (and only) program I ever made in Visual Basic was a game called Squares. I was in high school at the time, and didn't even know C, so I just wanted to make something simple and interactive.

In Squares, you have an 8 by 8 grid like a chess board. Players take turns putting their pieces on the board. When their pieces make a square, they get points equal to the area of the square. The game is tricky because squares can be rotated at any angle and are often hard to see. It's quite fun.. I made a simple hotseat version in canvas a while ago to test out canvas (Rendering shadows is slow!). Let me know if any of you are interested and I can show you the game.. if there is enough interest I could make it multiplayer online.

On a 2x2 board, there would only be one possible square. On a 3x3 board, you can make 6 squares.



So the question is, how many can you make on an 8x8 board? How about an NxN board? Or better yet.. an NxM board?? Anyone? :) It actually works out to be a nice clean answer.

4 comments:

Unknown said...

This seemed like a fun little puzzle but it ended up being harder than I expected. I figured out the NxN case but I'm not going to try the NxM. :-)


The equation I ended up with is:
(N^3 - 2N^2 + N) / 2

Unknown said...

Oh - comment moderation - never mind.

Michael said...

I don't think that works.
Here are the answers you should get.

2x2 = 1
3x3 = 6
4x4 = 20
5x5 = 50
6x6 = 105
7x7 = 196
8x8 = 336

My answer came out as a sum, not a simple equation.

Unknown said...

I missed the squares that are rotated some angle other than 45 degrees. I guess it's been a while since I played.

It's interesting that I could find such a simple equation to represent my version of the game.