### Developers Club geek daily blog

2 years, 8 months ago

Except a genre, games have the form. It as art — is poems and even novels, and there are poems. Pushkin, for example, occasionally ten verses in a week in Appstore spread. And we plow sometimes not worse than the genius. Ouch yes we with Pushkin, ouch yes sons of a bitch!

One of games written recently seemed to me to the noteworthy general mathematical public which adores geometrical puzzles, competitions and self-irony.

#### Problem definition

On the plane the random finite number of points is set.
Two players go in turn.
For one course the player can connect any two points a direct line.
The line should not cross other figures.

#### Game purpose

If as a result of the course the triangle which is not containing in itself other points is formed — that the player receives a prize-winning point.
Game zakanchivtsya when all triangles are constructed.
It is necessary to gather points more than the rival.

#### Game modification

If as a result of the course the triangle which is not containing in itself other points is formed — that the player adds the area of the formed triangle to the asset.
It is necessary to win big, than the rival, the area.

#### Features of geometrical implementation

For an initial arrangement of points I cut off the iPhone screen to a rectangle 300 on 400 and I do at the edges of a field 10 pixels wide.
Distance between points I limit to number not less than 16 pixels (for convenient capture by a finger).

The number of points is set accidentally in the range from 12 to 30 pieces.

At creation I prohibit to pass lines closer than 5 pixels to any points which are on the way.

#### Features of intelligence

As the rival the processor of Apple firm is selected. It plays in two statuses.
At the player's rating less than 25 points, Apple suspects one course forward, accidentally connecting points if there is no option with immediate receipt of a point.
At a rating of the player of 25 points and above, the rival suspects 2 courses forward, checking parity of the opportunities of creation of triangles which are had after the course.

In development process I increased course depth to 10 then the program left in deep a trance and fell a muzzle in salad.

In the course of game standard tricks by means of which sometimes it is possible to win were developed. I hope, you will find them.

Did not build the mathematical theory of game, but considered primitive options of deals for an arrangement of 4 points.

Depending on camber 4-ekh a point template, at optimum game on both sides the player going the first plays or in a draw 1-1, or wins 2-1.

Convex template. The player going the first plays in a draw 1-1

Nonconvex template. The player going the first plays wins 2-1

For 5 point templates, the player going the first always loses.

5 point convex template. The player going the first always loses.

Game time something reminds a snuker when the rival receives the course and can construct obviously turning out triangle would not seem — block other figures.

For those who became interested — there is small video. In total happy New Year — it with a bonus!