viernes, 19 de abril de 2013

Trizz

A new game in this forgotten blog. This time I wanted to introduce something different and experiment with websockets. So I came with the idea of making a multiplayer game.
The game is called Trizz and consists of a competition between two players to see who finishes the puzzle before.
To play the game you can either create or join a session. In case you create a session you need to share the session ID with you opponent. Once your opponent joins, you can start moving with the arrow keys and picking squares with the space bar. These are the rules of the game:

  • The board is divided in four zones, a home base and puzzle zone for each player.
  • The creator of the session is the red player and plays on the left, the joined player is the blue player and plays on the right.
  • The first player to fill the orange delimited zone of its puzzle zone with grey squares wins. There cannot be any grey square in the puzzle zone outside the orange delimited zone.
  • For the puzzle to be considered finished the player must not be holding any square.
  • The player can enter into the opponent puzzle zone but only if he is holding a square.
  • The player can then leave the square and pick one of the squares in the opponent's puzzle zone, this square can only be dropped in the player zones.
  • Squares taken from one player's field to the other change their color.
  • The player can never enter the opponent's home base.
  • New squares appear periodically on the broken line zone in the player's home base but only if the cell is empty

Of course you need two players to play but you can check what it looks like by opening two windows of your browser.
If you try to access from Chrome you should not have any problem. If you are trying to access from Firefox the websocket communication is by default not allowed. You can enable it by going to about:config and then setting network.websocket.allowInsecureFromHTTPS to true.

I have hosted the server in www.nodejitsu.com, right now I have a free account so the game will only be available for a month.
You can check the code here https://github.com/kdlevin/Trizz
The game can be played here.


martes, 15 de mayo de 2012

RushScript

Long time since my last post, but, you know, this games are not made in an afternoon.

I have been playing "Battlefied 3" lately and I love the game, specially "Rush" one of the multiplayer modes. That's why I decided to make a 2D replica of the Rush mode on BF3.
In this mode of BF3 basically you have to plant a bomb on the MCOMM stations without being killed if you play as an attacker, or prevent the attacker from doing so if you play as a defender.

In my 2D replica I made some simplifications, the game is single player and you can only play as attacker. To plant the bomb simply stay on top of the MCOMM (yellow circles) until a red ring starts flashing.

To play use arrows and mouse, left click to shoot. After some time dead enemies will reappear on the top right corner. Click on the image to play:
The result is not as funny as I thought at first. Moreover it is not even finished as the defenders do not try to dismantle the bomb. I hope to update it soon.

lunes, 26 de marzo de 2012

Slide Puzzle


For my third game I wanted to try some 3D and so here it is in isometric projection. As you can appreciate this is no normal slide puzzle as there are two empty spaces and there is no unique solution. The rules are simple:
  • Try to make a path from the left circle to the right by moving the arrows on the table.
  • A tile can only move if there is one and only one empty space beside it. 
  • The arrow on the clicked tile indicates the direction in which the other empty space will move.
Good luck!

Tiles


This game is circular puzzle in which the original figure is messed up, you have to click on the circles to return to the original state. I introduced a rule to make it a little more interesting, when a circle has two and only two lobes of the same color the normal rotation is modified from 90º to 180º. More instructions on the game itself.

Flood It!



Here is my version of the popular "Flood It!" game for Android. I played the game a lot on my phone and always wondered if there was an algorithm that could find the best solution for any "Flood It!" game, then I found this article that demonstrates the problem is NP-hard for boards of height 3 or more. That did not stop me and I tried to build the best algorithm I could. I decided to program it in JavaScript because I wanted to learn a new language and wanted it to be available to anyone. I implemented the game and the following algorithms:

  • Greedy Approach. Pick the colour that results in the largest gain (number of acquired tiles). The number of moves for this approach is calculated for every new table. The colour with the black wide border is the one that gives the largest gain at any stage.
  • Force (Brute force approach). Typical brute force algorithm, tries all the combinations and returns the solution with the minimum moves. It can take very long for tables of more than 3 colours.
  • SD  (Shortest Distance). To undestand this algorithm and SD2 we have to define the shortest distance to a tile, this value is the minimum number of moves needed to flood a concrete tile. In this approach at each stage we calculate the matrix of shortest distances after choosing every next colour. The color which gives the table which sum is minimum is the color we pick.
  • SD2 (Shortest Distance 2). In this approach at each stage we calculate the matrix of shortest distances before and after choosing every next colour. Then we compare only the maximun values. The color which reduces the most the maximum values in the shortest distance matrix is the chosen one. This is my best try but is difficult to compare to the optimal solution as the force approach takes too much time.
The solutions are displayed on the left pane using numbers, 1 for red, 2 for yellow ... moreover you can play pressing the numbers on the keyboard.