Assisted by WARNS=6. At that level, there are several warnings about
type conversion between small integer types that would only clutter the
code, therefore stay at WARNS=5. Same for lint's -aa option.
No functional change.
Previously, when starting a new game, the user coordinate was kept at
the previously selected spot. Since playing in the center is common
sense, reset the coordinate.
Most calculations are done on the frame index, not the pointer. This
avoids dealing with ptrdiff_t conversion to int.
Changing the type of s_frame changes the size of struct spotstr, it is
now 56 bytes on LP64 and 48 bytes on ILP32, neither of which is a power
of two. Remove the dummy padding since compilers no longer generate
division instructions for divisions by small integer constants, so that
optimization is no longer necessary.
No functional change.
Previously, the name 's' was used for the index of a spot on the board,
as well as for the value of a combo, and for a few other purposes. Use
different names and mark the spot indexes using a custom type.
No binary change.
The comments about the "top border" and "bottom border" had been wrong
all the time. Mention the corners in the comments, to remove the magic
from the various '+ 1' in the code.
No functional change.
No functional change, not even the TIE that is wrongly announced when
the very last spot on the board is yet to be filled by Black. Even
without this off-by-one error, it could be that filling the very last
spot completes a frame, so that code has been wrong all the time.
In practical terms, this situation only arises when the human player is
unconcentrated or the computer player has a bad strategy. The latter
may well be, as the computer moves in the (boring) endgame are not
directed towards winning -- they fill irrelevant spots before relevant
ones.
I also tried converting other macros, but s_occ would use more memory
and the return values for makemove are special values, besides the usual
coordinates in the form PT(x, y), so turning the special values into an
enum would be confusing.
No functional change.
Modern compilers optimize linear integer arithmetic, so there is no
reason to use strange or misleading formulas.
Replace several magic numbers with proper formulas.
No binary change.
Since overlap_info is only used in pickmove.c, move it there.
No functional change. In particular, in the middle of a game, gomoku
still tends to fall into analysis paralysis, thinking about the best
move for more than 3 minutes on modern hardware. Since the algorithm is
basically unchanged since the 1990s, it must have been a long waiting
time back then, probably an hour per move.
Of the 19 macros, only 3 were actually used. Replace their uses with
expressions based on the board size. It's a small step to making the
board size adjustable. There are still other places using hard-coded
numbers.
No binary change.
There are still parts of the code that use an indentation level of 4
instead of the usual 8. Fixing that right now would introduce more
unnatural line breaks, so defer that until later.
No binary change.