A Simple Puzzle Game [Now with exotic creatures!] (Prototype)
I got an urge this weekend to toy around with some mechanics that you may recognize from Triple Town, HackWorks and Reversi.
http://www.code-spot.co.za/downloads/hexmatch/HexMatch_2jan2013.zip (13 MB Zipped Windows executable).
Essentially, it combines the match-to-upgrade with the surround-to-reverse mechanics on a hex grid.
The rules are:
There are a few known bugs. The logic is surprisingly tricky to implement correctly, so for the moment I resolved a few infinite recursions with a depth check, and (possible) one other remains. At times I can swear a tile reverses colour when it shouldn't, but it is also common to mistake the tile you are currently playing.
There are cases where two (or more) matches / reversals are possible, and the one that is realised depends on the order in which the tiles are processed (I find this very unsatisfying, but cannot think of a way out of it). In some cases I made rules to deal with this: Jokers always match the highest-level possible, and red before blue.
I'd like to theme the game (similar to what Triple Town has done) at some stage; but for now it's just the raw abstract version.
Except for the Joker priority rule above, the game is totally symmetrical in blue and red; at this stage you even get score for matching and reversing-to blue. (So the main goal is not so much enforced or encouraged, and you have to "do it in your head". The up side is that it allows you to try out different end-goals). This is temporary, until I got the theme sorted.
I started implementing special tiles (that increases or decreases surrounding tiles, reverse them, rotate or swap them), but each addition makes the code exponentially more intricate (and lead to yet more infinite recursions that are hard to track). Hopefully, a new version will have some of these in.
I'd appreciate any feedback if you want to give it a whirl!
Update 6 December 2012
http://www.code-spot.co.za/downloads/hexmatch/HexMatch_2jan2013.zip (13 MB Zipped Windows executable).
Essentially, it combines the match-to-upgrade with the surround-to-reverse mechanics on a hex grid.
The rules are:
- Match three or more tiles to replace the group with one tile of a higher level.
- Surround a tile with three of more tiles with higher level to change its colour.
- Level four tiles become forts when matched.
- Forts cannot be matched or changed from one color to another.
- The game ends when no more moves are possible.
- The goal is to have as many red fords as possible at the end of the game.
There are a few known bugs. The logic is surprisingly tricky to implement correctly, so for the moment I resolved a few infinite recursions with a depth check, and (possible) one other remains. At times I can swear a tile reverses colour when it shouldn't, but it is also common to mistake the tile you are currently playing.
There are cases where two (or more) matches / reversals are possible, and the one that is realised depends on the order in which the tiles are processed (I find this very unsatisfying, but cannot think of a way out of it). In some cases I made rules to deal with this: Jokers always match the highest-level possible, and red before blue.
I'd like to theme the game (similar to what Triple Town has done) at some stage; but for now it's just the raw abstract version.
Except for the Joker priority rule above, the game is totally symmetrical in blue and red; at this stage you even get score for matching and reversing-to blue. (So the main goal is not so much enforced or encouraged, and you have to "do it in your head". The up side is that it allows you to try out different end-goals). This is temporary, until I got the theme sorted.
I started implementing special tiles (that increases or decreases surrounding tiles, reverse them, rotate or swap them), but each addition makes the code exponentially more intricate (and lead to yet more infinite recursions that are hard to track). Hopefully, a new version will have some of these in.
I'd appreciate any feedback if you want to give it a whirl!
Update 6 December 2012
- Added tiles for swapping tiles along any of the three axes, and tiles for increasing or decreasing levels.
- Fixed the bug that caused the program to stall when you place three Jokers next to each other.
- Made more appealing tiles.
- More tiles added.
- Descriptions for special tiles added.
- Special tiles now have to be unlocked.
- Minor bug fixes and graphical update.
- Fort combination mechanic added
- Temporary: removed special tiles
- Temporary: removed level 2-4 tiles
- Added game modes (One Color, Two Colors, and Sand Box).
- Added a visualisation for showing sequence of events (matchings and take-overs).
- Updated tile sets to be more interesting.
- Added 5 game modes.
- Temporarily disabled the unlocking systems.
- Added new tiles ("Unknown" and "Rotation" tiles).
- Tweaked the way in which molecules are chosen (most games only feature a selection of the special tiles).
- Updated rule descriptions to reflect theme.
- Updated art.
- Added sound.
Comments
I gave it a quick play. Got to 5 forts then the Tetris syndrome of waiting for the perfect piece countered my entire strategy :P. I think if you can get the "special tiles" in it would increase the depth of the game quite a bit. I found one of your infinite recursions, it happens when I place three joker tiles next to each other with no other tiles next to them. But you probably knew that :)
Just a few questions that came up while I was playing.
1) How does the distribution for the level of tiles work? Do you decrease the spawn rate of level 1 tiles or do you steadily increase higher level tile spawn rates as it progresses?
2) Do forts count as higher level tiles when trying to switch colours? It didn't seem so while I was playing, but I thought it would
And finally, can I pleaaaaaaaase see your code for the hex grid? It's something I've been struggling with for a week or so now. It's probably not that complicated, I just can't seem to wrap my head around it.
Would love to see the next iteration. :D
To answer your questions:
1) I maintain a bag of potential next-tiles. Initially the bag is filled with only 7 level-1 tiles. After each turn, I add a tile with the same level as the one you placed (now possibly upgraded after matching) into the bag if it is not a special tile (I call them "defense tiles"). Special tiles (except for forts) are generated at a fixed frequency (currently 20%), otherwise a defense tile is chosen randomly from the bag, and the colour is switched with probability 50%. This has the effect that as you play, the chances of getting higher level tiles increase, and you cannot get a tile of a level if you have not created it yet in the game. Also, how you play in the beginning affects the tiles generated quite a bit. If you hold off making matches, you increase the long-term probability of getting lower-value tiles.
In a previous version I did not switch the colour of the tile randomly, so that your play-style (and dumb luck) also affected the tile colours. This was quite interesting, but yes, you could get games where one colour completely dies out, which is not desirable for the current end-goal.
2) The are supposed to. I really should make a debug panel so that I can test certain formations directly.
-----
Yes, it is rather tricky to get right, and my code is quite messy tbh.
To simplify the math a bit, I made the hexes slightly less regular, as you can see from the image. The top and bottom side lengths are 4 units, and the other sides are 5 units, so the hex is exactly 10 units wide and 8 units high.
Edit 1: I made a mistake below, screen "should" really be "world" (in my setup they are almost the same).
x, y are screen coordinates, and i, j are grid coordinates.
The tiles are simply stored in a 2D array. There are then these methods to do operations:
- GridToScreenX(i, j), GridToScreenY(i, j) to place the tiles on screen.
- GetNeighbors(i, j)
For convenience, tiles know their own grid positions. This method is used for mouse input:
- IsInside(x, y) to determine whether screen coordinate x, y is inside this tile
I pasted the relevant methods into the attached file.
Edit 2: I just realised (after making the images above) that it is not necessary to make the hexes non-regular. If the top and bottom side lengths are 5 units (instead of four) all the formulas will still work with minor modifications... grrr
Edit 3:I was wrong, the hexagons are not regular if the modification is made as in Edit 2. A closer approximation is possible though for a hex with vertices on a grid. In the image below the side lengths are given from the top. (And sorry for this technical derailment).
- You could include a small help text under non-standard tiles.
- It felt weird to place blue tiles when I know I want to end up with red forts. Not saying it is wrong, just a weird feeling, like "Where do I put this nonsense for now?"
- Some sort of visual indication of what will happen when I place a piece would go a long way to help the joker priority thing.
- In some of the text you say "fort" and other places "ford".
- Why not make the board area a large hexagon?
- I can place a swap tile in the middle of nowhere, which basically does nothing. Also if I place it on the edge. Is this expected?
- It seem like you get stars from matching more than 3 tiles, but what good are they actually?
The help text is a good idea. I'll include it in the next version.
I know the weird feeling you are describing. The "strategy" is to build cages for these pieces, but of course it still is weird. Not sure how to deal with it though. [Some of my ideas around the theme may solve this, perhaps, but we will have to see]. For now I note it as a know "design problem".
The visual indication I think is key... also perhaps to show what happens after you place a tile step by step... The result even surprise myself at this stage, and seeing what went down will help a great deal. Unfortunately this is a pain to implement...
Yeah, the swap issue is annoying. These tiles are in fact not really useful until the final stages. (I mostly use them to move inconveniently placed forts). At this stage, it is intended to "do nothing", but it is not very intuitive.
At this stage the stars are not much good (except for higher score). This is another mechanic lifted from Triple Town (although there it is only up to one "star"); in that game they basically give you nicer items (tree with apples, for instance). The reverse mechanic in my game, however, changes the play style to become more immediate - you don't construct such elaborate plans as in Triple Town. In that light, I may remove the stars thing, but have not made up my mind. (I could give the player a real benefit, but that may just needlessly complicate it.)
Thanks again for the feedback, it's been really helpful!
I only managed to unlock two tiles, the one was the joker tiles and the other was the "Priest" tiles. But that kind off screwed me over. I don't think the priest tiles are functioning like they should. It says that you take over a level 4 blue piece, but I don't think it behaved like that at all. If there weren't any blue pieces I still had to place it, but then when there was 2 adjacent tiles of the same type adjacent to the priest tile, the priest tile dissapeared. I couldn't figure out if it was something that wasn't working like it was supposed to, or if it was just me not getting it.
I like the idea of "unlocking" the tiles. I think you implemented it now with every red fort giving you a new unlock. Correct? If that is the case I think it should be every x-tiles as well as every red fort. The games doesn't function like a game with level or item progression. So there really isn't a reason to keep back any of the tiles to increase the longevity of the game, if that was your reasoning behind it. I like the unlocking because it teaches me one tile at a time. But I want to get to all the different tiles sooner rather than later so I can design my "perfect strategy" to beat the game.
Keep up the good work :)
@Rigormortis I don't communicate the unlocking and the tile behaviors properly. The Unlock screen actually tells you what to do to unlock a tile group. The priest tiles actually turns adjacent tiles to the opposite color - the red priest turns blue tiles red and vice versa. The confuser tile (star with blue and red spikes) turns both red tiles to blue, and blue tiles to red. I will definitely clean up the information screens to make this clear.
Yes, exposing the tiles gradually is a good way to teach them actually. So that is a good thing to try and bring out.
The reason why I want to unlock the tiles gradually though goes in hand with some of the ideas I have for where this is going. I'm still figuring it out, but basically I want to give the player a sense of discovery. The unlocking of cool tiles will be one aspect of this; another will be how the tiles will actually be represented, and a third is a new mechanic that I have been thinking of - basically, to represent different shapes of connected forts differently. (For example, if the theme is building a city, an isolated fort may be just a fort, to connected ones a castle, three connected ones a palace, etc.) So it will be matching on a different level. In this scheme then, the tiles will be different building materials or characters for instance.
@francoisvn Yes, I must admit that I miss the placeholder cell quite a bit. I may do something similar, and test whether it will work. The visualisation system (or something that at least tells you what did happen properly) is something I am working out at the moment. It will unfortunately be at least two or three iterations before that comes in...
Thanks again :)
I'm not sure where you are heading with the whole experience, but I think if you want to have that sense of discovery you might want to consider not letting the player get all the tiles in one play through. If the complete game is built around some kind of city building then you can limit the player to only get (let's say) 60% of all unlockable tiles that they choose instead of everything being able to unlock. That way they can try again with different strategies.
Edit: Ok, so the tiles make a lot more sense to me know :). One thing I picked up on the menus. If I click on the info about the unlocks(or whatever) and the mouse is over the board, then I immediatley place a tile.
Yes, limiting the tiles is a good idea (with or without unlocking) to make successive games more different from each other. And thanks for the spotting the bug... (another reminder why GUI work in Unity is so gratifying...)
---
I started to work on the next step, which is making connecting forts into more interesting things.
There are several ways to do this; one way I am investigating is to design a special tile set with the features built-in. The design of such a tile set is quite tricky, so I made one to see how difficult it is. This system uses 23 tiles. Because the hexagons are not totally regular, only vertical and horizontal flips are allowed when matching them on the grid, so no rotations. (With rotations allowed, the tile set could be smaller, but I think this would lead to artefacts even if the hexes were regular).
Some quite interesting shapes are possible. I must admit: can't wait to have it in the game.
Is the plan that you do this linking with forts only? Seems interesting. Will you do this after a fort is created?
Also, I understand from a technical point why you don't want to just allow rotating, but from a user perspective it might be confusing. I would recommend you allow rotating and just have two separate graphics you use, depending on the rotation.
Dunno, is there a potential for this to become a creative game of artistic expression too? :P
@francoisvn Yup, the player don't have to worry about this detail at all. The tiling is automatic based on the forts you build; hopefully you will see it in action soon. The idea is basically for the end game to be a reward by the "coolness" of how it looks. (But I underestimated how much fun it is playing with such a tileset... I was up until five this morning building all kinds of shapes, and in the process stumbled on a slightly better design).
@Tuism... it's not so much a game of creative expression as it is a Rorschach test ;)
The new tile set is shown below; I originally missed one tile, so it actually has 24 tiles.
And this is for @Tuism:
Looks awesome man :)
There are some other changes as well: new game modes (including a sand box mode), and a visualisation to make it easier to see what happens when you match a tile.
@Tuism The type of dead-ends I think you mean do not really come up, because the game automatically chooses the right tile to match. There is a different kind of dead-end though, and that is holes too small to build in. I am playing with various ideas; possibly something along the lines as making it into a strategy as you suggest.
Do the eyes blink? ;)
The new gameplay modes need a lot of work; I will probably drop at least some of them ("Metamorphosis" is the only one other than the default three that I kind-of-like at this stage).
@dislekcia You are very right, the eyes should blink! I'm playing around with the original "stars" to be eyes, and then remove them from the actual tiles. At the moment, I only have one "level" of eye, and I kept the eyes in the tiles. The "star" eyes blink, but I have not devised a clever scheme for their placement yet... so it's a bit odd. But the eeriness of blinking is already there :)
Any feedback is always welcome :)