960pos.c: small codestyle improvements - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit b8b2cc59aa85a43f6d7e9a8ce4b1c7627e4fa264
(DIR) parent f9e923c7dc9c8cc10a71d9f305961a0ccd0287a6
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 23 Jan 2024 21:09:33 +0100
960pos.c: small codestyle improvements
Diffstat:
M 960pos.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
---
(DIR) diff --git a/960pos.c b/960pos.c
@@ -9,10 +9,11 @@ ranktofen(char *buf, size_t bufsiz, const char *rank)
{
int i;
- snprintf(buf, bufsiz, "%s/pppppppp/8/8/8/8/PPPPPPPP/%s w KQkq - 0 1", rank, rank);
+ snprintf(buf, bufsiz, "%s/pppppppp/8/8/8/8/PPPPPPPP/%s w KQkq - 0 1",
+ rank, rank);
for (i = 0; i < 8; i++)
- buf[i] = ((buf[i] - 'A') + 'a'); /* lower-case */
+ buf[i] = (buf[i] - 'A') + 'a'; /* to lower-case */
}
/* simpler method, using 2 tables */
@@ -32,13 +33,11 @@ postab(int n, char *rank)
"QRKNRN", "RQKNRN", "RKQNRN", "RKNQRN", "RKNRQN", "RKNRNQ",
"QRKRNN", "RQKRNN", "RKQRNN", "RKRQNN", "RKRNQN", "RKRNNQ"
};
-
/* Bishop's table: encoded squares between them */
unsigned char btab[] = {
0, 0, 0, 2, 0, 4, 0, 6, 1, 0, 2, 0, 2, 2, 2, 4,
1, 2, 3, 0, 4, 0, 4, 2, 1, 4, 3, 2, 5, 0, 6, 0
};
-
char *s;
int i, t1, t2;
@@ -71,15 +70,15 @@ poscomp(int n, char *rank)
/* knights table: encoded squares between them */
unsigned char ntab[] = { 0, 0, 0, 1, 0, 2, 0, 3, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 3, 0 };
- for (q = 0; q < 8; q++)
- rank[q] = 0;
+ for (i = 0; i < 8; i++)
+ rank[i] = 0;
/* bishop (white square) */
b1 = n % 4;
n2 = (n - b1) / 4;
/* b, d, f, h */
- rank[b1 * 2 + 1] = 'B'; /* b */
+ rank[b1 * 2 + 1] = 'B';
/* bishop (dark square) */
b2 = n2 % 4;