# Net

## Rules

The game *net* is a single-player logic puzzle.

The game consists of a 5x5 grid with squares containing pieces, comparable to cables or pipes, which can be rotated by a quarter turn in the clockwise (or anti-clockwise) direction. These pieces have a certain shape (endpoint, segment, corner, or tee) and a certain orientation (N, E, S, W). Each shape consists of one or more arms, connected to the center of the square, called *half-edges*.

By convention, here is the representation of the pieces based on their shape and orientation that we will use.

![](ressources/pieces.png)

Here is the text representation of the pieces, to allow for display in a Linux terminal.

```
|          |  N  |  E  |  S  |  W  |
| -------- | --- | --- | --- | --- |
| endpoint |  ^  |  >  |  v  |  <  |
| segment  |  |  |  -  |  |  |  -  |
| corner   |  └  |  ┌  |  ┐  |  ┘  |
| tee      |  ┴  |  ├  |  ┬  |  ┤  |
```
Here is a representation of the pieces with textures, those will be displayed with an SDL renderer.

![](ressources/textured_pieces.png)


**Original Rule**: According to the Simon Tatham's Portable Puzzle Collection, the game rule is simply stated as follows: *Rotate the pieces in the grid squares so that they come together in a single connected network, without loops.*

You can try the original game [here](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/net.html).

Indeed, by rotating the pieces, it is possible to correctly match the half-edges of two adjacent squares, so that they connect the centers of the squares (or *vertices*), forming an *edge*.

![](ressources/edges.png)

## Project Architecture

Our project is based on a single library named *game* library (`libgame.a`),
whose interface is divided into several header files:

* Basic Game Functions: @ref game.h
* Auxiliary Game Functions: @ref game_aux.h
* Extended Game Functions: @ref game_ext.h

This interface manipulates an [opaque data
type](https://en.wikipedia.org/wiki/Opaque_data_type), that is the structure
@ref game, by means of pointers or const pointers (@ref cgame).

About Const Pointer:

* See also: <http://www.geeksforgeeks.org/const-qualifier-in-c/>
* See also this more technical discussion: <http://stackoverflow.com/questions/8504411/typedef-pointer-const-weirdness>

Based on this library, our project will provide several programs, including but
not limited to the following:

* `game_text`: a simple text-based program to play our game in a terminal ;
* `game_test_XXX`: 3 program with many tests to check the validity of the library
  functions ;
* `game_sdl`: a program made to play our game on a SDL renderer with textures
## Authors

This project is made by 3 person

**Nicolas Lespinasse**  
**Pauline Ricaud**  
**Arthur Chaminade**  
