17 Commits

Author SHA1 Message Date
ed82ef5c0e Revamp the triangular grid generation in Loopy, which I've been
meaning to revisit for a while. The new version generates more nicely
symmetric grids (best at even heights, but still improved even at odd
heights), and avoids any 'ears' on the grid (triangles at the corners
connected to only one other triangle, which tend to be boringly easy
places to start solving).

I've reused the grid-description-string mechanism invented for the
Penrose tilings as a versioning mechanism for the triangular grids, so
that old game descriptions should still be valid, and new triangular-
grid game descriptions begin with an "0_" prefix to indicate that they
are based on the new-style construction.

[originally from svn r9824]
2013-04-11 12:51:05 +00:00
bce3f1bd26 Greg Hewgill points out a code path on which the angle parameter to
the Penrose grid generation function can fail to be initialised.

[originally from svn r9798]
2013-04-01 09:38:04 +00:00
4a172274f2 Apply the rotation in Penrose grid descriptions by rotating in the
4-vector representation, rather than mucking about with sines and
cosines after grid generation. _Should_ make no difference in the
generated grids (there's a theoretical risk of an unlucky rounding
error just about managing to push some point in or out of bounds, but
I think it's vanishingly small), but simplifies the coordinate-
flattening procedure, and in particular increases its chance of
getting vertical lines actually vertical.

(Prior to this change, the game ID
10x10t12:G2554,-31,108_a3b12h0a212a3d102b2a23a2e3b01b0a2c2a0c0 was
generating a not-quite-vertical edge at top left, in the Java port but
not on Linux; I suspect differences in sin and cos as the cause of the
discrepancy. With the rotation done like this, the points'
x-coordinates are now computed without reference to their
y-coordinates.)

[originally from svn r9168]
2011-05-06 17:09:03 +00:00
89bfecaa5a Portability fixes, mostly from James for Palm purposes. Mostly
additions of missing 'static' and explicit 'void' in parameter lists,
plus one or two other things like explicitly casting chars in variadic
argument lists to int and using DBL_MAX if HUGE_VAL isn't available.

[originally from svn r9166]
2011-05-04 18:41:21 +00:00
4bab5e531b Fix two memory leaks reported by Tiago Dionizio in recent Loopy
development.

[originally from svn r9163]
2011-04-26 13:44:27 +00:00
8266b71475 Forgot to set 'has_incentre' on triangular grids, which don't use
grid_face_add_new(). Oops.

[originally from svn r9161]
2011-04-25 22:41:54 +00:00
62c20496bf From James Harvey (via a period of collaborative polishing), a patch
to add two kinds of Penrose tiling to the grid types supported by
Loopy.

This has involved a certain amount of infrastructure work, because of
course the whole point of Penrose tilings is that they don't have to
be the same every time: so now grid.c has grown the capacity to
describe its grids as strings, and reconstitute them from those string
descriptions. Hence a Penrose Loopy game description consists of a
string identifying a particular piece of Penrose tiling, followed by
the normal Loopy clue encoding.

All the existing grid types decline to provide a grid description
string, so their Loopy game descriptions have not changed encoding.

[originally from svn r9159]
2011-04-24 09:10:52 +00:00
f390d0d7ff Oops: initialise that new 'has_incentre' flag to false, otherwise the
game will sometimes pick random incentres in place of the carefully
computed ones. Ahem.

[originally from svn r9158]
2011-04-23 13:03:38 +00:00
5e3de7d95b Move most of face_text_pos() into grid.c, leaving in loopy.c only the
part that converts from abstract grid coordinates into screen
coordinates. This should speed up window-resizing by eliminating
pointless reiteration of the complicated part of the algorithm: now
when a game_drawstate is renewed, only the conversion into screen
coordinates has to be redone.

[originally from svn r9157]
2011-04-23 11:44:43 +00:00
7b2b742be8 Another patch from Chris Moore implementing two more grid types, both
involving dodecagons.

[originally from svn r9109]
2011-02-24 19:06:49 +00:00
621649491d Retire the 'middle_face' field in 'struct grid', together with the
overly complicated algorithm that uses it to home in on the grid edge
closest to a mouse click. That algorithm is being stressed beyond its
limit by the new grid type, and it's unnecessary anyway given that no
sensibly sized puzzle grid is going to be big enough to make it
prohibitively expensive just to do the trivial approach of iterating
over all edges and finding the closest of the eligible ones.

[originally from svn r9108]
2011-02-24 19:06:48 +00:00
53f6e4c6cb Patch from Chris Moore to implement an extra grid type, the 'floret'
pentagonal tiling.

[originally from svn r9107]
2011-02-23 20:05:42 +00:00
1a628aebd8 Patch from Chris Moore to improve the generality of
grid_nearest_edge(), by having it search harder for a better dot to
move to in the first loop.

[originally from svn r9106]
2011-02-23 20:05:40 +00:00
fe1b91ac49 Since the lack of this has caused portability issues in the past:
add "-ansi -pedantic" to the main Unix makefile, and clean up a few
minor problems pointed out thereby.

[originally from svn r8175]
2008-09-13 18:25:19 +00:00
acf5c55d35 Patch from James H to make new-Loopy port more easily.
[originally from svn r8174]
2008-09-10 21:44:23 +00:00
4033458aff How did I manage to check this in without actually trying to build
on Windows at all?! Fix some departures from the C standard, mostly
declaring variables after a statement has already been issued in the
same block. MSVC is picky about this where gcc is forgiving, and TBH
I'd change the latter given the choice.

[originally from svn r8166]
2008-09-07 08:35:52 +00:00
f38b711c73 Completely re-engineered version of Loopy, courtesy of Lambros
Lambrou. Now capable of handling triangular and hexagonal grids as
well as square ones, and then a number of semiregular plane tilings
and duals of semiregular ones. In fact, most of the solver code
supports an _arbitrary_ planar graph (well, provided both the graph
and its dual have no self-edges), so it could easily be extended
further with only a little more effort.

[originally from svn r8162]
2008-09-06 15:19:47 +00:00