Author: Scott Gasch
Date: 12:19:45 02/22/05
Go up one level in this thread
What sense does it make to measure lines of C code? You can do it in one line! Anyway, two small refinements to Anthony's code are to put the board as a static global so that it is zeroed out by the loader (instead of your code) and to get rid of the fentable and just put 'n' and 'N' on the board. Might I suggest a better way to measure? g++ -O -S foo.c; wc -l foo.s. Also interestingly: [ scott@wannabe:~/tmp ] % g++34 -S foo.c ; wc -l foo.s 193 foo.s [ scott@wannabe:~/tmp ] % g++34 -O -S foo.c ; wc -l foo.s 161 foo.s [ scott@wannabe:~/tmp ] % g++34 -O2 -S foo.c ; wc -l foo.s 174 foo.s [ scott@wannabe:~/tmp ] % g++34 -O3 -S foo.c ; wc -l foo.s 174 foo.s [ scott@wannabe:~/tmp ] % g++34 -O4 -S foo.c ; wc -l foo.s 174 foo.s FWIW: #include "stdio.h" static char board[64]; int main(void) { for(int i = 0; i < 4096; i++) { int wn = i & 0x3F, bn = i >> 6; if(wn == bn) continue; board[wn] = 'n'; board[bn] = 'N'; for(int rank = 7; rank >= 0; rank--) { for(int file = 0, empty = 0; file < 8; file++) { if(empty && (board[rank*8+file] || file == 7)) { printf("%d", empty+!board[rank*8+file]); empty = 0; } else empty++; if(board[rank*8+file]) printf("%c", board[rank*8+file]); } if (rank>0) printf("/"); } printf(" - - 0 1\n"); board[wn] = board[bn] = 0; } return 0; }
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.