Entanglement Game
Also found in: Thesaurus, Idioms, Encyclopedia, Wikipedia.
Entanglement is a level 2 Glyphword in the Hearts of Stone expansion that can be crafted by the Runewright.
en·tan·gle
(ĕn-tăng′gəl)tr.v.en·tan·gled, en·tan·gling, en·tan·glesentanglement
(ɪnˈtæŋɡəlmənt) nen•tan•gle•ment
(ɛnˈtæŋ gəl mənt)n.
Noun | 1. | entanglement - an intricate trap that entangles or ensnares its victim spider web, spider's web - a web resembling the webs spun by spiders trap - a device in which something (usually an animal) can be caught and penned |
entanglement
nounentanglement
noun1. The condition of being entangled or implicated:entanglement
[ɪnˈtæŋglmənt]Nentanglement
[ɪnˈtæŋgəlmənt]nromantic entanglement → amourmcompliqué
entanglement
nentanglement
[ɪnˈtæŋglmənt]n (fig) (gen) → coinvolgimento; (romantic) → relazionefsentimentaleentangle
(inˈtӕŋgl) verbWant to thank TFD for its existence? Tell a friend about us, add a link to this page, or visit the webmaster's page for free fun content.
Link to this page:
Overview
This is a clone of Entanglementpuzzle game for iOS, made with Swift. You start with a tile at the center ofthe board, which gives you the tiny amount of a redline. Your goal is to create the longest red line path possible.You can use either the tile in your hands or swap it with the onein your pocket.
Note: more detailed application internals overview you can find on my blog.
Architecture
The board is represented as a two-dimensional array of Tile
objects.Both map and each tile are hexagons.
Tiles
Each Tile
object has 12 possible path fragments.Each side of a tile holds two ends of a path fragment.Connections between tile sides are represented by 12-element array,connections
, where each element is a tuple, containing the beginningand the end points' indices for each path fragment.Order for those numbers does not matter inside connections
array.But it does matter in the meaning of the whole tile:
Here, if you join, say, c0
and c5
, you shall got the line fragment.
Tile
class has these helper methods:
outputFromNeighbourOutput(output: Int)
- for finding out the connection 'pin' indexfor the neighbor tiles (if you place two tiles one above another,their pins' indices on the join line will be different - the topone will have pinsc7
andc6
whilst the bottom one will havec0
andc1
).intput(output: Int)
- for fianding the endpoint for a pin (c5
ifc0
is given orc0
ifc5
is given, in our example)output(intput: Int)
- finds the correspondence between neighbour pins (in our example with stacked tiles, this method associatesc0
withc7
orc6
withc1
and others)rotate(direction: Int)
/rotateLeft()
/rotateRight()
- rotates a tile, changing pins on its sides
There are a few derived classes. Those are used to distinguish the borders ofa board (BorderTile
), empty places within a board (Tile
),tiles outside the board (EmptyTile
), the starting point (ZeroTile
)and the tiles which already on the map (NonEmptyTile
).
It has an environment which is purposefully fraught with danger and paranoia, a sandbox where people are allowed to be awful, and a challenging and (at times) impenetrable user interface. Here is where Hackmud starts to shine. Hackmud game. It shares many characteristics with EVE Online.
Board
Board stores tiles, which have been already placed and those which are empty,and the 'zero' one (the one where you start), and the borders.. It's allabout the board.
The tiles are stored in a two-dimensional array, but here's the trick:to draw them (and for the better understanding's sake) I placed themin the non-orthogonal coordinate system (note the u
and v
coordinatesused in the code), formed by a two lines, lying through the tiles' centersand crossing under 120o angle:
The center of the map, the form of the map - those two are configuredparameters of the board, but generally those are set to a hexagon boardshape and its center in the (4, 4) point.
Board class provides a way to detect the place for the tile, which will be placed next.This is done using simple switch .. case
operator. Say, you have your last tile placed at(u, v)
point and the line ends at its c_i
pin. The findNextPlace() -> (Int, Int)
methodwill provide you with a neighbour tile placeholder' coordinates. Note: this method does notcheck if the placeholder contains BorderTile
or ZeroTile
or whatever - this check is performedwhilst the new tile is being placed.
The placeTile(tile: NonEmptyTile)
method performs placing tile and checks for the game end.This method also performs the extension of a path. The information about current path isstored in the Path
class instance in the form of (u, v, localInput, localOutput)
structure.Most of those parameters are stored for the debugging purposes - the only thing you need isthe output pin of each tile.
Game
Game
class encapsulates Board
object, next tile (the one you 'hold in your hand') and the 'pocket'tile. It also provides convenient methods to manipulate game state - rotateTileLeft()
,rotateTileRight()
, usePocket()
, placeTile()
and isGameOver() -> Bool
to check if the gamegoes on.
You can use those method and create any UI you can imagine (to display game state) to createyour own distribution of the game.