Commit Graph

2310 Commits

Author SHA1 Message Date
andvar 5a58ccfbec fix various typos in comments, documentation and messages.
mainly s/paramater/parameter/ and s/reduntant/redundant/.
2022-08-07 11:06:18 +00:00
rillig f1e042b8d2 fix references in manual pages to the reference documentation 2022-06-28 20:12:52 +00:00
andvar 0e5bc969e0 fix various typos in comments. 2022-06-27 22:41:28 +00:00
christos 02e7c0b99a Enable FANCY mode for debugging purposes:
- To enable stand still mode (robot is not moving but waiting in place),
    specify a scorefile on the command line called <directory>/stand_still
  - To enable pattern roll mode (robot is changing which move to look first)
    specify a scorefile on the command line called <directory>/pattern_roll
2022-06-27 18:48:49 +00:00
rillig a37d11d413 gomoku: remove redundant parentheses
No binary change.
2022-06-19 10:33:17 +00:00
rillig 3dd0208726 gomoku: reduce usage of magic numbers in the code
No binary change.
2022-06-19 10:23:48 +00:00
rillig 158db354d4 cgram: allow cursor navigation with KEY_BEG as well 2022-06-12 14:59:44 +00:00
christos 780fb67fe8 Elide vax breakage 2022-05-31 19:11:58 +00:00
rillig 2309756cc1 gomoku: clean up variable names, add empty lines
No binary change.
2022-05-29 22:03:29 +00:00
rillig b29fe38f22 gomoku: clean up color handling in 'pickmove'
Instead of searching for the best black and white moves, search instead
for our and their best moves. This makes the code simpler and more
uniform, as the strategy is the same for Black and White.

No functional change.
2022-05-29 21:47:12 +00:00
rillig e17d9875fe gomoku: clean up 'pickmove' stylistically
No functional change.
2022-05-29 21:38:36 +00:00
rillig a9ff97e44e gomoku: migrate remaining functions to type player_color
No functional change.
2022-05-29 21:02:37 +00:00
rillig 2a44525455 gomoku: make parsing of the debug command 'o' robust
Previously, the (invalid) debug command 'o,' succeeded to parse and led
to out-of-bounds memory access. Add proper parsing for the arguments of
that debug command. Add a short usage for that debug command, as
guessing the usage from the previous code was time-consuming due to the
large amount of ad-hoc low-level parsing code.

When leaving debug mode, clear the debug prompt.
2022-05-29 20:21:28 +00:00
rillig 6084941245 gomoku: clean up overlap info in 'checkframes'
In 2009, GCC had complained that the overlap_info might only be
partially filled. All possible code paths are sane though, so that was
probably a bug in GCC.

Remove the comment and the unnecessary initialization, rename the
variable since it doesn't match its behavior anymore. Sync nearby
comments with reality; there is no array anywhere near.

No functional change.
2022-05-29 18:25:39 +00:00
rillig 388688984b gomoku: do not scan the upper border for combos
Adding the '+ 1' to the row coordinate added an offset of 20, while the
intended offset was 1.

No functional change, just a bit faster.
2022-05-29 18:05:25 +00:00
rillig fe75e7f249 gomoku: refine the type of some functions and variables
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.
2022-05-29 17:01:42 +00:00
rillig 1f981c0ac1 gomoku: when starting a new game, start in the middle of the board
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.
2022-05-29 16:30:44 +00:00
rillig 28df150fd1 gomoku: after accepting a spot via the mouse, clear current coordinate 2022-05-29 16:19:52 +00:00
rillig 6b2dc434d3 gomoku: add type player_color
No functional change.
2022-05-29 15:31:12 +00:00
rillig d48c60b1a6 gomoku: use unsigned integers for bit sets
As all access to the bit sets happens through the unsigned spot_index
type, drop the type casts in the macros.

No functional change on 2s complement machines.
2022-05-29 15:16:11 +00:00
rillig e3d95fb4b0 gomoku: provide a more gentle introduction to the code
No binary change.
2022-05-29 14:50:37 +00:00
rillig 7167cb1f23 gomoku: don't use 'i' as special-purpose variable name
No binary change.
2022-05-29 14:37:44 +00:00
rillig 5a52a51bdb gomoku: consistently name the offset of a spot in a frame 'off'
Leave 'i' for general purpose loops.

No functional change.
2022-05-29 14:01:57 +00:00
rillig 5e10e7e916 gomoku: add data type for one of the 4 directions of a frame
No functional change.
2022-05-29 13:49:10 +00:00
rillig fd3d36cfc1 gomoku: clean up four_in_a_row
No functional change.
2022-05-29 12:44:17 +00:00
rillig 08fc57d214 gomoku: extract quick_check from scanframes
No functional change.
2022-05-29 12:20:07 +00:00
rillig dad5fc9eee gomoku: use proper types when indexing 'board' and 'frames'
No functional change.
2022-05-29 11:36:12 +00:00
rillig fca58dfea5 gomoku: turn spotstr.s_frame into a frame index
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.
2022-05-29 10:37:21 +00:00
rillig ec29facc23 gomoku: document where to fix the unnecessarily long thinking time 2022-05-29 10:06:43 +00:00
rillig 14ba68e228 gomoku: migrate 'makemove' to using spot_index instead of pointer
No functional change.
2022-05-29 01:34:49 +00:00
rillig 8a094c33c3 gomoku: migrate pickmove to use spot_index instead of pointers
Using spot_index instead of pointers leads to simpler code since there
is no need to deal with conversion from ptrdiff_t to spot_index.

No functional change.
2022-05-29 01:17:55 +00:00
rillig 355e963e40 gomoku: migrate spot_index from int to unsigned short
This matches the type of 'intersect'.

No functional change.
2022-05-29 00:38:26 +00:00
rillig 76069dc145 gomoku: use consistent variable names
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.
2022-05-29 00:12:11 +00:00
rillig cc51471792 gomoku: use custom magic value for end of file input
This allows the type for a spot index to be changed to an unsigned type.

No functional change.
2022-05-28 23:05:45 +00:00
rillig d9395f0376 gomoku: use unsigned arithmetic for bitboard
No functional change.
2022-05-28 21:48:21 +00:00
rillig ffd3ec5309 gomoku: document that 'whatsup' is called on ^C as well 2022-05-28 21:31:41 +00:00
rillig f8dbe39b74 gomoku: allow saving a finished game without pressing Shift 2022-05-28 20:57:26 +00:00
rillig 5f9b935517 gomoku: remove redundant parentheses, braces, newlines, clean up get_key
No functional change.
2022-05-28 20:54:31 +00:00
rillig 60c448cea2 gomoku: clean up initialization of overlap information
Fix variable names 'ia' and 'ib', which I forgot in the previous commit.

Move the documentation in the right places.

Split off another part of init_overlap, to make each function fit on a
single screen. Reducing the number of nested 'for' loops allows the
indentation to follow the NetBSD style.

No functional change.
2022-05-28 19:47:24 +00:00
rillig 463eec3668 gomoku: clean up local variable names in init_overlap
By clearly associating each variable to either frame A or frame B,
suddenly the code becomes understandable. For the benefit of future
readers, explain the naming scheme.

No functional change.
2022-05-28 18:55:16 +00:00
rillig 14facc424c gomoku: split initialization of the board into smaller functions
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.
2022-05-28 17:51:27 +00:00
rillig 8fc3223a93 gomoku: highlight the winning frame 2022-05-28 08:32:55 +00:00
rillig a347aeb809 gomoku: group movelog and nmoves into a game struct
No functional change.
2022-05-28 08:19:18 +00:00
rillig b45d205818 gomoku: split makemove into smaller functions
No functional change.
2022-05-28 08:09:22 +00:00
rillig 408da2c120 gomoku: announce tie as early as possible 2022-05-28 07:58:35 +00:00
rillig 3a536c56b8 gomoku: extract update_overlap_different_direction
No functional change.
2022-05-28 06:25:35 +00:00
rillig f2e0424f1c gomoku: extract separate function update_overlap_same_direction
No functional change.
2022-05-28 05:44:41 +00:00
rillig 5685a50629 gomoku: reduce number of variables in update_overlap
No functional change.
2022-05-28 05:14:34 +00:00
rillig a94d789129 gomoku: reduce scope of local variable
No functional change.
2022-05-28 04:52:23 +00:00
rillig 256d3e3c22 gomoku: reduce variable reuse, make code more uniform
No functional change.
2022-05-27 23:29:15 +00:00