aboutsummaryrefslogtreecommitdiff
path: root/slant.c (follow)
Commit message (Collapse)AuthorAge
* New rule: interpret_move() is passed a pointer to the game_drawstateSimon Tatham2012-09-09
| | | | | | | | | | | | | | | | basically just so that it can divide mouse coordinates by the tile size, but is definitely not expected to _write_ to it, and it hadn't previously occurred to me that anyone might try. Therefore, interpret_move() now gets a pointer to a _const_ game_drawstate instead of a writable one. All existing puzzles cope fine with this API change (as long as the new const qualifier is also added to a couple of subfunctions to which interpret_move delegates work), except for the just-committed Undead, which somehow had ds->ascii and ui->ascii the wrong way round but is otherwise unproblematic. [originally from svn r9657]
* Changed my mind about midend_is_solved: I've now reprototyped it asSimon Tatham2011-06-19
| | | | | | | | | | | | | | | | midend_status(), and given it three return codes for win, (permanent) loss and game-still-in-play. Depending on what the front end wants to use it for, it may find any or all of these three states worth distinguishing from each other. (I suppose a further enhancement might be to add _non_-permanent loss as a fourth distinct status, to describe situations in which you can't play further without pressing Undo but doing so is not completely pointless. That might reasonably include dead-end situations in Same Game and Pegs, and blown-self-up situations in Mines and Inertia. However, I haven't done this at present.) [originally from svn r9179]
* Add a function to every game backend which indicates whether a gameSimon Tatham2011-04-02
| | | | | | | | | | | state is in a solved position, and a midend function wrapping it. (Or, at least, a situation in which further play is pointless. The point is, given that game state, would it be a good idea for a front end that does that sort of thing to proactively provide the option to start a fresh game?) [originally from svn r9140]
* Patch idea from Debian, but modified considerably in implementation:Simon Tatham2010-04-25
| | | | | | | | | | | | introduce a new colour in Slant (COL_FILLEDSQUARE) which is used for the background of any grid square that has a diagonal line in it. This makes it easier to spot the one square on a giant board you forgot to fill in, but on the other hand I found it to look very strange and disconcerting. So I've set the colour to be identical to COL_BACKGROUND by default, and users who like the idea can enable it by environment variable or by local patch. [originally from svn r8930]
* Keyboard control patch for Slant, from James H.Simon Tatham2009-01-16
| | | | [originally from svn r8417]
* Yet another complete rewrite of Slant's loop detection duringSimon Tatham2008-09-17
| | | | | | | | | | | | | | | | | | | | gameplay. Having tried methods based on using the slashes to define a dsf on grid vertices, and also methods based on tracing round the loops using conventional (non-dsf-based) graph theory, it occurred to me the other day that there's a far simpler technique involving connectivity. A loop is precisely that which causes the playing area to become disconnected; so what we do now is to go through and build a dsf describing connectedness of the _area_ of the grid rather than the vertices. That divides the area into its maximal connected components, and then we can trivially identify every edge that's part of a loop by noticing that it separates two nonequivalent pieces of space. The resulting algorithm is half the size of the old one, and it's much easier to be confident of its correctness. (Having said which, there will doubtless turn out to be an embarrassing bug in it, but I haven't found it yet.) [originally from svn r8187]
* Since the lack of this has caused portability issues in the past:Simon Tatham2008-09-13
| | | | | | | add "-ansi -pedantic" to the main Unix makefile, and clean up a few minor problems pointed out thereby. [originally from svn r8175]
* New infrastructure feature. Games are now permitted to beSimon Tatham2008-09-06
| | | | | | | | | | | | | | | | | | | | | | _conditionally_ able to format the current puzzle as text to be sent to the clipboard. For instance, if a game were to support playing on a square grid and on other kinds of grid such as hexagonal, then it might reasonably feel that only the former could be sensibly rendered in ASCII art; so it can now arrange for the "Copy" menu item to be greyed out depending on the game_params. To do this I've introduced a new backend function (can_format_as_text_now()), and renamed the existing static backend field "can_format_as_text" to "can_format_as_text_ever". The latter will cause compile errors for anyone maintaining a third-party front end; if any such person is reading this, I apologise to them for the inconvenience, but I did do it deliberately so that they'd know to update their front end. As yet, no checked-in game actually uses this feature; all current games can still either copy always or copy never. [originally from svn r8161]
* HTML Help support for Puzzles, with the same kind of automaticSimon Tatham2006-12-24
| | | | | | fallback behaviour as PuTTY's support. [originally from svn r7009]
* Mike's changes to dsf.c alter the internal storage format of dsfSimon Tatham2006-11-01
| | | | | | | | | structures, meaning that ad-hoc initialisation now doesn't work. Hence, this checkin converts all ad-hoc dsf initialisations into calls to dsf_init() or snew_dsf(). At least, I _hope_ I've caught all of them. [originally from svn r6888]
* Tidy up comments.Simon Tatham2006-03-12
| | | | [originally from svn r6601]
* Introduce a new deductive mode in Slant's Hard level, which is theSimon Tatham2006-03-06
| | | | | | | | | | | | | | | | | generalisation of the previous deduction involving two 3s or two 1s either adjacent or separated by a row of contiguous 2s. I always said that was an ugly loop and really ought to arise naturally as a special case of something more believable, and here it is. The practical upshot is that Hard mode has just become slightly harder: some grids generated by the new Slant will be unsolvable by the old one's solver. I don't think it's become _excessively_ more hard; I think I'm happy with the new difficulty level. (In particular, I don't think the new level is sufficiently harder than the old to make it worth preserving the old one as Medium or anything like that.) [originally from svn r6591]
* Cleanup: it was absolutely stupid for game_wants_statusbar() to be aSimon Tatham2005-10-22
| | | | | | | | | function, since it took no parameters by which to vary its decision, and in any case it's hard to imagine a game which only _conditionally_ wants a status bar. Changed it into a boolean data field in the backend structure. [originally from svn r6417]
* Cleanup: remove the game_state parameter to game_colours(). No gameSimon Tatham2005-10-22
| | | | | | | | | | | | was actually using it, and also it wasn't being called again for different game states or different game parameters, so it would have been a mistake to depend on anything in that game state. Games are now expected to commit in advance to a single fixed list of all the colours they will ever need, which was the case in practice already and simplifies any later port to a colour-poor platform. Also this change has removed a lot of unnecessary faff from midend_colours(). [originally from svn r6416]
* Cleanup: the `mouse_priorities' field in the back end has been aSimon Tatham2005-10-22
| | | | | | | more general-purpose flags word for some time now. Rename it to `flags'. [originally from svn r6414]
* Use game_set_size() to set up the temporary drawstate inSimon Tatham2005-09-23
| | | | | | | | | | | | | | | | | | game_print(), wherever feasible. This fixes a specific bug in Loopy (James H's new field ds->linewidth wasn't being set up, leading to corrupted print output), but I've made the change in all affected files because it also seems like a generally good idea to encourage it for future games, to prevent other problems of this type. There is one slight snag, which is that Map _can't_ do this because its game_set_size() also initialises a blitter. I could fix this by abstracting the common parts of Map's game_set_size() out into a subfunction called by game_set_size() and also called directly by game_print(); alternatively, I could introduce a means of determining whether a `drawing *' was for screen or printing use. Not sure which yet. [originally from svn r6340]
* Completely rewrite the loop-detection algorithm used to check gameSimon Tatham2005-09-10
| | | | | | | | | | | | | | | | | completion, _again_. In r6174 I changed it from dsf to conventional graph theory so that it could actually highlight loops as opposed to just discovering that one existed. Unfortunately, yesterday I discovered a fundamental graph-theoretic error in the latter algorithm: if you had two entirely separate loops connected by a single path, the path would be highlighted as well as the loops. Therefore, I've reverted to the original dsf technique, combined with a subsequent pass to trace around each loop discovered. This version seems to do a better job of only highlighting the actual loops. [originally from svn r6283] [r6174 == 2bd8e241a93165a99f5e2c4a2dd9c3b3b1e3c6f3]
* James H has implemented a new `Tricky' difficulty level in Light Up:Simon Tatham2005-09-01
| | | | | | | | | | | | | | | | | | a non-recursive level above Easy, which therefore moves the recursive Hard mode further up still. Play-testing suggests that in fact Tricky is often _harder_ than the old Hard mode, since the latter had limited depth of recursion and would therefore spot complex deductions only if it happened to start a recursion on the right square; Tricky may be limited in the sophistication of its complex deductions, but it never misses one, so its puzzles tend to be hard all over. Also in this checkin, a new source file `nullfe.c', containing all the annoying stub functions required to make command-line solvers link successfully. James wrote this for (the new) lightupsolver, and I've used it to simplify the other stand-alone solvers. [originally from svn r6254]
* Substantial infrastructure upheaval. I've separated the drawing APISimon Tatham2005-08-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as seen by the back ends from the one implemented by the front end, and shoved a piece of middleware (drawing.c) in between to permit interchange of multiple kinds of the latter. I've also added a number of functions to the drawing API to permit printing as well as on-screen drawing, and retired print.py in favour of integrated printing done by means of that API. The immediate visible change is that print.py is dead, and each puzzle now does its own printing: where you would previously have typed `print.py solo 2x3', you now type `solo --print 2x3' and it should work in much the same way. Advantages of the new mechanism available right now: - Map is now printable, because the new print function can make use of the output from the existing game ID decoder rather than me having to replicate all those fiddly algorithms in Python. - the new print functions can cope with non-initial game states, which means each puzzle supporting --print also supports --with-solutions. - there's also a --scale option permitting users to adjust the size of the printed puzzles. Advantages which will be available at some point: - the new API should permit me to implement native printing mechanisms on Windows and OS X. [originally from svn r6190]
* 16-bit-cleanness fixes from James H (again). It would be really niceSimon Tatham2005-08-11
| | | | | | | | | | to have some means of automatically spotting this sort of problem on a desktop platform, but I can't immediately think of one; building a trick compiler which thinks `int' is 16 bits would be the obvious option, but it would immediately break the ABIs to all the system functions. [originally from svn r6184]
* Very fiddly corrections to the loop highlighting. ERRSLASH means theSimon Tatham2005-08-09
| | | | | | | | | | | slash in this square is red, so it does indeed imply that some of the edge markings are also red; but it doesn't mean _all_ the edge markings must be red. So instead of assuming ERRSLASH implies all edge error markers, we set the correct set of edge error markers at the same time as setting ERRSLASH, at which point we know which kind of slash it is so we know which ones to set. [originally from svn r6175]
* Implement error checking in Slant. Clue points are now highlightedSimon Tatham2005-08-09
| | | | | | | | | | | | | | | in red if it's impossible to fulfill them (either through too many neighbours connecting to them, or too many not connecting to them), and edges are highlighted in red if they form part of a loop. In order to do this I've had to revamp the redraw function considerably. Each square is now drawn including its top and left grid edges, but _not_ its bottom or right ones - which means that I need to draw an extra strip of empty squares outside the actual grid in order to draw the few pixels which appear on the grid bottom and right borders and also to red-highlight border clues. [originally from svn r6174]
* Placate optimiser.Simon Tatham2005-08-07
| | | | [originally from svn r6171]
* Streamline `slantsolver' a bit (avoid showing advanced working onSimon Tatham2005-08-06
| | | | | | | easy puzzles, and stop having a second encoding of the difficulty levels). [originally from svn r6170]
* Document hard mode in Slant, and also fix an obvious memorySimon Tatham2005-08-06
| | | | | | management error in game_configure(). [originally from svn r6169]
* Introduce an environment variable setting (SLANT_SWAP_BUTTONS=yes)Simon Tatham2005-08-06
| | | | | | | | | | | to reverse the effect of the mouse buttons. Gareth has been complaining about this for days: apparently he finds precisely the opposite control system intuitive to me. This is a horrendous hack, and pushes me one step closer to losing my temper and designing a proper preferences architecture. [originally from svn r6168]
* A bunch of new reasoning techniques in the Slant solver, leading toSimon Tatham2005-08-06
| | | | | | | a new Hard mode. Also added a command-line `slantsolver' which can grade puzzles and show working. [originally from svn r6167]
* New puzzle: `Light Up', by James H.Simon Tatham2005-08-04
| | | | | | | | | | Also in this checkin (committed by mistake - I meant to do it separately), a behind-the-scenes change to Slant to colour the two non-touching classes of diagonals in different colours. Both colours are set to black by default, but configuration by way of SLANT_COLOUR_* can distinguish them if you want. [originally from svn r6164]
* Bug fix from James H: solve_game() was returning error messages inSimon Tatham2005-08-04
| | | | | | | | the return value rather than in *error. In the old days type- checking would have caught this, but now of course they're the same type. [originally from svn r6161]
* Cleanups from James H: a few missing statics, a precautionary castSimon Tatham2005-08-03
| | | | | | | | | or two, a debugging fix, a couple of explicit initialisations of variables that were previously read uninitialised, and a fix for a whopping great big memory leak in Slant owing to me having completely forgotten to write free_game(). [originally from svn r6159]
* Bah! There's _always_ one. Display glitch corrected.Simon Tatham2005-08-02
| | | | [originally from svn r6156]
* New puzzle: `Slant', picked from the Japanese-language section ofSimon Tatham2005-08-02
nikoli.co.jp (which has quite a few puzzles that they don't seem to have bothered to translate into English). Minor structural change: the disjoint set forest code used in the Net solver has come in handy again, so I've moved it out into its own module dsf.c. [originally from svn r6155]