[comp.sources.games] v09i034: tttt - tic-tac-toc-toe with wraparound edges, Patch1

billr@saab.CNA.TEK.COM (Bill Randle) (03/10/90)

Submitted-by: Eric Lechner <lechner@ucscb.ucsc.edu>
Posting-number: Volume 9, Issue 34
Archive-name: tttt/Patch1
Patch-To: tttt: Volume 9, Issue 33

	[Copied from comp.sources.games.bugs so it will get archived.
	 if you already applied this patch, don't do it again.  -br]

[[This patch for "tttt" allows the player to scroll the tic-tac-toc-toe
board around, so that "wraparound" wins are easier to spot.

It also includes a more graceful exit from a control-c exit, and
a "make shar" option in the Makefile.

-Eric Lechner, 7 March 1990]]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  patches01
# Wrapped by billr@saab on Fri Mar  9 15:40:34 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'patches01' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patches01'\"
else
echo shar: Extracting \"'patches01'\" \(3977 characters\)
sed "s/^X//" >'patches01' <<'END_OF_FILE'
Xdiff -c ../tttt.old/Makefile ./Makefile
X*** ../tttt.old/Makefile	Thu Mar  8 11:05:41 1990
X--- ./Makefile	Thu Mar  8 10:35:16 1990
X***************
X*** 27,30 ****
X  	nroff -man tttt.6 > tttt.man
X  
X  clean:
X! 	rm -f tttt *.o tttt.man
X--- 27,33 ----
X  	nroff -man tttt.6 > tttt.man
X  
X  clean:
X! 	rm -f tttt *.o tttt.man tttt.shar
X! 
X! shar:
X! 	shar README Makefile tttt.6 tttt.c > tttt.shar
Xdiff -c ../tttt.old/tttt.6 ./tttt.6
X*** ../tttt.old/tttt.6	Thu Mar  8 11:05:44 1990
X--- ./tttt.6	Thu Mar  8 10:21:15 1990
X***************
X*** 18,23 ****
X--- 18,40 ----
X  .PP
X  The first player to connect four squares in a row wins.  If
X  the board becomes filled without a winner, it is a tie game.
X+ .SH COMMANDS
X+ .RS
X+ .IP "a-d, 0-4"
X+ Select the row and column for your move.
X+ .IP h
X+ Scroll the board left.
X+ .IP l
X+ Scroll the board right.
X+ .IP k
X+ Scroll the board up.
X+ .IP j
X+ Scroll the board down.
X+ .IP ctrl-L
X+ Redraw the screen.
X+ .IP q
X+ Quit the game.
X+ .RE
X  .SH HISTORY
X  This program was originally written for an Advanced Logic
X  Design class, as a high level version of the program to
Xdiff -c ../tttt.old/tttt.c ./tttt.c
X*** ../tttt.old/tttt.c	Thu Mar  8 11:05:55 1990
X--- ./tttt.c	Thu Mar  8 02:46:53 1990
X***************
X*** 14,19 ****
X--- 14,20 ----
X  
X  #include <stdio.h>
X  #include <curses.h>
X+ #include <signal.h>
X  
X  #define EMPTY	0
X  #define X	1
X***************
X*** 22,27 ****
X--- 23,32 ----
X  #define TIE	-1		/* for ending when the board is full */
X  #define QUIT	-2
X  
X+ #define UP	1		/* definitions for board scrolling routine */
X+ #define DOWN	2
X+ #define LEFT	3
X+ #define RIGHT	4
X  #define WIN	100		/* for position rank scoring */
X  
X  #ifndef TRUE
X***************
X*** 32,44 ****
X  char board [4][4];		/* this is the playing board */
X  int pieces;
X  
X! void	initboard(),
X! 	printboard();
X  
X! int	check_win(),
X! 	getrank(),
X  	x_move(),		/* "our" move */
X! 	o_move();		/* the computer player's move */
X  
X  main()
X  {
X--- 37,51 ----
X  char board [4][4];		/* this is the playing board */
X  int pieces;
X  
X! void	initboard(),		/* initialize the board */
X! 	printboard(),		/* print the board */
X! 	shift();		/* board shifter */
X  
X! int	check_win(),		/* check for a win */
X! 	getrank(),		/* move ranking */
X  	x_move(),		/* "our" move */
X! 	o_move(),		/* the computer player's move */
X! 	quit();			/* control-c signal exit */
X  
X  main()
X  {
X***************
X*** 52,57 ****
X--- 59,66 ----
X  	cbreak();
X  	noecho();
X  
X+ 	signal(SIGINT,quit);
X+ 
X  	initboard();
X  
X  	clear();
X***************
X*** 168,173 ****
X--- 177,202 ----
X  			case 'Q' :
X  				return(QUIT);
X  				break;
X+ 			case 'j' :
X+ 			case 'J' :
X+ 				shift(DOWN);
X+ 				printboard();
X+ 				goto GetX;
X+ 			case 'k' :
X+ 			case 'K' :
X+ 				shift(UP);
X+ 				printboard();
X+ 				goto GetX;
X+ 			case 'l' :
X+ 			case 'L' :
X+ 				shift(RIGHT);
X+ 				printboard();
X+ 				goto GetX;
X+ 			case 'h' :
X+ 			case 'H' :
X+ 				shift(LEFT);
X+ 				printboard();
X+ 				goto GetX;
X  			case 0x12 :
X  			case 0x0c :
X  				clear();
X***************
X*** 347,349 ****
X--- 376,427 ----
X  	return (0);
X  }
X  
X+ /*
X+ 	this is the board shifter.  it's so you can move the
X+ 	board around to look at wraparound edges better...
X+ */
X+ void shift(type)
X+ int type;
X+ {
X+ 	int i, j, tmp;
X+ 
X+ 	for (i=0; i<4; i++) {
X+ 		switch (type) {
X+ 			case UP:
X+ 				tmp = board[0][i];
X+ 				for (j=0; j<3; j++)
X+ 					board[j][i] = board[j+1][i];
X+ 				board[3][i] = tmp;
X+ 				break;
X+ 			case DOWN:
X+ 				tmp = board[3][i];
X+ 				for (j=3; j>0; j--)
X+ 					board[j][i] = board[j-1][i];
X+ 				board[0][i] = tmp;
X+ 				break;
X+ 			case LEFT:
X+ 				tmp = board[i][0];
X+ 				for (j=0; j<3; j++)
X+ 					board[i][j] = board[i][j+1];
X+ 				board[i][3] = tmp;
X+ 				break;
X+ 			case RIGHT:
X+ 				tmp = board[i][3];
X+ 				for (j=3; j>0; j--)
X+ 					board[i][j] = board[i][j-1];
X+ 				board[i][0] = tmp;
X+ 				break;
X+ 		}
X+ 	}
X+ }
X+ 
X+ int quit()
X+ {
X+ 	move(21,0);
X+ 	refresh();
X+ 	sleep(2);
X+ 	resetty();
X+ 	endwin();
X+ 
X+ 	exit(0);
X+ }
END_OF_FILE
if test 3977 -ne `wc -c <'patches01'`; then
    echo shar: \"'patches01'\" unpacked with wrong size!
fi
# end of 'patches01'
fi
echo shar: End of shell archive.
exit 0