From d996eb73bc3b493e69d07a481f167702156b733a Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sat, 27 Jun 2015 12:38:00 -0400 Subject: [PATCH 01/16] First commit, created printBoard method --- TicTacToe/TicTacToe/main.m | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 3a713ee..0c2cd91 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -8,10 +8,30 @@ #import +@interface tictactoe : NSObject + +- (void) printBoard; + +@end + +@implementation tictactoe + +- (void) printBoard { + + // top mid bottom + printf(" | | \n-----\n | | \n-----\n | | \n"); + +} + +@end + + int main(int argc, const char * argv[]) { @autoreleasepool { - // insert code here... - NSLog(@"Hello, World!"); + + tictactoe *game1 = [[tictactoe alloc] init]; + [game1 printBoard]; + } return 0; } From 51b42b58293ce9f8ca41ad9224c499d2ce15ecbe Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sat, 27 Jun 2015 13:05:12 -0400 Subject: [PATCH 02/16] Added formatters to printBoard --- TicTacToe/TicTacToe/main.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 0c2cd91..4e07202 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -18,8 +18,23 @@ @implementation tictactoe - (void) printBoard { + NSString *spaceTopLeft = @" "; + NSString *spaceTopMid = @" "; + NSString *spaceTopRight = @" "; + + NSString *spaceMidLeft = @" "; + NSString *spaceMidMid = @" "; + NSString *spaceMidRight = @" "; + + NSString *spaceBottomLeft = @" "; + NSString *spaceBottomMid = @" "; + NSString *spaceBottomRight = @" "; + // top mid bottom - printf(" | | \n-----\n | | \n-----\n | | \n"); + printf("%s|%s|%s\n-----\n%s|%s|%s\n-----\n%s|%s|%s\n", [spaceTopLeft UTF8String], [spaceTopMid UTF8String], [spaceTopRight UTF8String], [spaceMidLeft UTF8String], [spaceMidMid UTF8String], [spaceMidRight UTF8String], [spaceBottomLeft UTF8String], [spaceBottomMid UTF8String], [spaceBottomRight UTF8String]); + + + } @@ -32,6 +47,8 @@ int main(int argc, const char * argv[]) { tictactoe *game1 = [[tictactoe alloc] init]; [game1 printBoard]; +// NSString *emptySpace = @" "; +// printf("this is where the empty spa%sce goes:", [emptySpace UTF8String]); } return 0; } From 84393d263fb6d38577657990e9698153edb9ed7a Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sat, 27 Jun 2015 15:20:23 -0400 Subject: [PATCH 03/16] Trying to add spaces to spaces array --- TicTacToe/TicTacToe/main.m | 55 +++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 4e07202..b5b5dcc 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -10,30 +10,54 @@ @interface tictactoe : NSObject -- (void) printBoard; +- (void) printBoard(tictactoe *)spaces; + +- (void) printLabel; + +@property (nonatomic) NSMutableArray *spaces; @end @implementation tictactoe -- (void) printBoard { +- (void) printLabel { - NSString *spaceTopLeft = @" "; - NSString *spaceTopMid = @" "; - NSString *spaceTopRight = @" "; + printf("**********************************\n"); + printf("* TIC *\n"); + printf("* *\n"); + printf("* TAC *\n"); + printf("* *\n"); + printf("* *\n"); + printf("* TOE *\n"); + printf("**********************************\n"); +} + +- (void) printBoard(tictactoe *)spaces { - NSString *spaceMidLeft = @" "; - NSString *spaceMidMid = @" "; - NSString *spaceMidRight = @" "; + if (self.spaces == nil) { + self.spaces = [[NSMutableArray alloc] initWithObjects:@" ", @" ", @" ", @" ", @" ", @" ", @" ", @" ", @" ", nil]; + } - NSString *spaceBottomLeft = @" "; - NSString *spaceBottomMid = @" "; - NSString *spaceBottomRight = @" "; + [self.spaces addObject: nil]; - // top mid bottom - printf("%s|%s|%s\n-----\n%s|%s|%s\n-----\n%s|%s|%s\n", [spaceTopLeft UTF8String], [spaceTopMid UTF8String], [spaceTopRight UTF8String], [spaceMidLeft UTF8String], [spaceMidMid UTF8String], [spaceMidRight UTF8String], [spaceBottomLeft UTF8String], [spaceBottomMid UTF8String], [spaceBottomRight UTF8String]); - + printf("\n\n"); + printf("%s| | \n-----\n | | \n-----\n | | \n", [_spaces[0] UTF8String]); +} + +@end + + +@interface player : NSObject + +- (void) setMove; + +@end + + +@implementation player + +- (void) setMove { } @@ -45,10 +69,9 @@ int main(int argc, const char * argv[]) { @autoreleasepool { tictactoe *game1 = [[tictactoe alloc] init]; + [game1 printLabel]; [game1 printBoard]; -// NSString *emptySpace = @" "; -// printf("this is where the empty spa%sce goes:", [emptySpace UTF8String]); } return 0; } From 49a6dd7593ca429ce80958137901ff06884e2bbb Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sat, 27 Jun 2015 16:09:30 -0400 Subject: [PATCH 04/16] Revamp, starting on setMove method --- TicTacToe/TicTacToe/main.m | 48 +++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index b5b5dcc..c15ca83 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -8,17 +8,32 @@ #import -@interface tictactoe : NSObject +@interface Player : NSObject -- (void) printBoard(tictactoe *)spaces; + +@end + + +@implementation Player + +@end + +@interface Tictactoe : NSObject - (void) printLabel; +- (void) printBoard; + +- (void) setMove; + + @property (nonatomic) NSMutableArray *spaces; +@property (nonatomic) Player * player1; + @end -@implementation tictactoe +@implementation Tictactoe - (void) printLabel { @@ -32,34 +47,25 @@ - (void) printLabel { printf("**********************************\n"); } -- (void) printBoard(tictactoe *)spaces { +- (void) printBoard { if (self.spaces == nil) { - self.spaces = [[NSMutableArray alloc] initWithObjects:@" ", @" ", @" ", @" ", @" ", @" ", @" ", @" ", @" ", nil]; + self.spaces = [[NSMutableArray alloc] initWithObjects:@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", nil]; } - [self.spaces addObject: nil]; - printf("\n\n"); - printf("%s| | \n-----\n | | \n-----\n | | \n", [_spaces[0] UTF8String]); + printf("%s|%s|%s\n-----\n%s|%s|%s\n-----\n%s|%s|%s\n", [_spaces[0] UTF8String], [_spaces[1] UTF8String], [_spaces[2] UTF8String], [_spaces[3] UTF8String], [_spaces[4] UTF8String],[_spaces[5] UTF8String],[_spaces[6] UTF8String], [_spaces[7] UTF8String], [_spaces[8] UTF8String]); } -@end - - -@interface player : NSObject - -- (void) setMove; - -@end - - -@implementation player - - (void) setMove { + int i; + if ([_spaces[i] isEqualToString:_spaces[i]]) { + + + } } @end @@ -68,7 +74,7 @@ - (void) setMove { int main(int argc, const char * argv[]) { @autoreleasepool { - tictactoe *game1 = [[tictactoe alloc] init]; + Tictactoe *game1 = [[Tictactoe alloc] init]; [game1 printLabel]; [game1 printBoard]; From 2575a14cc9c3bd2cf89b0830d8960c6a8f9f998a Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sat, 27 Jun 2015 16:33:37 -0400 Subject: [PATCH 05/16] Working on setMove method --- TicTacToe/TicTacToe/main.m | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index c15ca83..3d72f4b 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -10,7 +10,6 @@ @interface Player : NSObject - @end @@ -18,18 +17,27 @@ @implementation Player @end +@interface Computer : NSObject + +@end + + +@implementation Computer + +@end + @interface Tictactoe : NSObject - (void) printLabel; - (void) printBoard; -- (void) setMove; +- (void) setMove:(int)move; @property (nonatomic) NSMutableArray *spaces; -@property (nonatomic) Player * player1; +@property (nonatomic) Player * playerX; @end @@ -58,13 +66,11 @@ - (void) printBoard { printf("%s|%s|%s\n-----\n%s|%s|%s\n-----\n%s|%s|%s\n", [_spaces[0] UTF8String], [_spaces[1] UTF8String], [_spaces[2] UTF8String], [_spaces[3] UTF8String], [_spaces[4] UTF8String],[_spaces[5] UTF8String],[_spaces[6] UTF8String], [_spaces[7] UTF8String], [_spaces[8] UTF8String]); } -- (void) setMove { - - int i; +- (void) setMove:(int)i { if ([_spaces[i] isEqualToString:_spaces[i]]) { - + [_spaces replaceObjectAtIndex:_spaces[i] withObject: 0]; } } @@ -74,9 +80,17 @@ - (void) setMove { int main(int argc, const char * argv[]) { @autoreleasepool { + int userInput; + Tictactoe *game1 = [[Tictactoe alloc] init]; [game1 printLabel]; + printf("\nHello Player 'X'\nWhere would you like to play: "); [game1 printBoard]; + scanf("\n%d",&userInput); + + [game1 setMove:3]; + + } return 0; From 861ddef85970fdbc99ef0af9e07de22ca9227462 Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sat, 27 Jun 2015 17:01:33 -0400 Subject: [PATCH 06/16] Finished chooseMove method, vigorously high-fived --- TicTacToe/TicTacToe/main.m | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 3d72f4b..e7a9883 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -37,6 +37,8 @@ - (void) setMove:(int)move; @property (nonatomic) NSMutableArray *spaces; +@property (nonatomic) NSMutableArray *startingSpaces; + @property (nonatomic) Player * playerX; @end @@ -59,6 +61,7 @@ - (void) printBoard { if (self.spaces == nil) { self.spaces = [[NSMutableArray alloc] initWithObjects:@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", nil]; + self.startingSpaces = [[NSMutableArray alloc] initWithObjects:@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", nil]; } printf("\n\n"); @@ -66,12 +69,14 @@ - (void) printBoard { printf("%s|%s|%s\n-----\n%s|%s|%s\n-----\n%s|%s|%s\n", [_spaces[0] UTF8String], [_spaces[1] UTF8String], [_spaces[2] UTF8String], [_spaces[3] UTF8String], [_spaces[4] UTF8String],[_spaces[5] UTF8String],[_spaces[6] UTF8String], [_spaces[7] UTF8String], [_spaces[8] UTF8String]); } -- (void) setMove:(int)i { +- (void) chooseMove:(int)i { - if ([_spaces[i] isEqualToString:_spaces[i]]) { + if ([_spaces[i] isEqualToString:_startingSpaces[i]]) { - [_spaces replaceObjectAtIndex:_spaces[i] withObject: 0]; + [_spaces replaceObjectAtIndex: i withObject: @"x"]; } + + [self printBoard]; } @end @@ -84,11 +89,12 @@ int main(int argc, const char * argv[]) { Tictactoe *game1 = [[Tictactoe alloc] init]; [game1 printLabel]; - printf("\nHello Player 'X'\nWhere would you like to play: "); [game1 printBoard]; + printf("\nHello Player 'X'\nWhere would you like to play: "); + scanf("\n%d",&userInput); - [game1 setMove:3]; + [game1 chooseMove:userInput]; From 3a51882b0af77590d92c22594ac002ad9badae0b Mon Sep 17 00:00:00 2001 From: Chrisrdavid7 Date: Sat, 27 Jun 2015 17:30:52 -0400 Subject: [PATCH 07/16] Add Second Pleyer --- TicTacToe/TicTacToe/main.m | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index e7a9883..dcebb89 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -8,7 +8,7 @@ #import -@interface Player : NSObject +@interface Player : NSObject // Player One Starts with X @end @@ -17,7 +17,7 @@ @implementation Player @end -@interface Computer : NSObject +@interface Computer : NSObject // Computer automatic plays in one player mode @end @@ -32,7 +32,7 @@ - (void) printLabel; - (void) printBoard; -- (void) setMove:(int)move; +- (void) chooseMove:(int)move; @property (nonatomic) NSMutableArray *spaces; @@ -66,17 +66,32 @@ - (void) printBoard { printf("\n\n"); + //Tic Tac Toe Board + printf("%s|%s|%s\n-----\n%s|%s|%s\n-----\n%s|%s|%s\n", [_spaces[0] UTF8String], [_spaces[1] UTF8String], [_spaces[2] UTF8String], [_spaces[3] UTF8String], [_spaces[4] UTF8String],[_spaces[5] UTF8String],[_spaces[6] UTF8String], [_spaces[7] UTF8String], [_spaces[8] UTF8String]); } +//First Player "X" if statement - (void) chooseMove:(int)i { if ([_spaces[i] isEqualToString:_startingSpaces[i]]) { - [_spaces replaceObjectAtIndex: i withObject: @"x"]; + [_spaces replaceObjectAtIndex: i withObject: @"X"]; + } + + [self printBoard]; +} +//Second Player "O" if statement + +- (void) chooseMove2:(int)a { + + if ([_spaces[a] isEqualToString:_startingSpaces[a]]) { + + [_spaces replaceObjectAtIndex: a withObject: @"O"]; } [self printBoard]; + } @end @@ -86,17 +101,23 @@ int main(int argc, const char * argv[]) { @autoreleasepool { int userInput; - Tictactoe *game1 = [[Tictactoe alloc] init]; + [game1 printLabel]; + + //While loop for repeat + + while (game1) { [game1 printBoard]; printf("\nHello Player 'X'\nWhere would you like to play: "); - scanf("\n%d",&userInput); - [game1 chooseMove:userInput]; - + [game1 printBoard]; + printf("\nHello Player 'O'\nWhere would you like to play: "); + scanf("\n%d", &userInput); + [game1 chooseMove2:userInput]; + } } return 0; From 6bdcf765edf607671020c6a127cb9c3c5468ca9e Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sat, 27 Jun 2015 17:31:42 -0400 Subject: [PATCH 08/16] Working on winOrLose method --- TicTacToe/TicTacToe/main.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index e7a9883..ca935ef 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -32,7 +32,9 @@ - (void) printLabel; - (void) printBoard; -- (void) setMove:(int)move; +- (void) chooseMove:(int)move; + +- (BOOL) winOrLose; @property (nonatomic) NSMutableArray *spaces; @@ -79,6 +81,12 @@ - (void) chooseMove:(int)i { [self printBoard]; } +- (BOOL)winOrLose { + + + return: YES; +} + @end From 5d9c8612bc9e0f0f49ed575c6e3a268c703d8c67 Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sun, 28 Jun 2015 11:35:28 -0400 Subject: [PATCH 09/16] Added computer player, working on proper randomizer --- TicTacToe/TicTacToe/main.m | 90 +++++++++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 15 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index b82f031..0aab4a1 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -8,7 +8,7 @@ #import -@interface Player : NSObject // Player One Starts with X +@interface Player : NSObject // Player X uses 'x' @end @@ -17,13 +17,19 @@ @implementation Player @end -@interface Computer : NSObject // Computer automatic plays in one player mode +@interface Computer : Player // Computer uses 'o' + +- (void) computerChooseMove:(int)c; @end @implementation Computer +- (void) computerChooseMove:(int)c { + +} + @end @interface Tictactoe : NSObject @@ -32,14 +38,20 @@ - (void) printLabel; - (void) printBoard; +- (void) playerSelect; + - (void) chooseMove:(int)move; +- (void) computerChooseMove:(int)c; + @property (nonatomic) NSMutableArray *spaces; @property (nonatomic) NSMutableArray *startingSpaces; @property (nonatomic) Player * playerX; +@property (nonatomic) Computer *computer; + @end @implementation Tictactoe @@ -56,6 +68,25 @@ - (void) printLabel { printf("**********************************\n"); } +- (void) playerSelect { + + printf("**********************************\n"); + printf("* *\n"); + printf("* 0) Play computer *\n"); + printf("* *\n"); + printf("* *\n"); + printf("* 1) 2-player mode *\n"); + printf("* *\n"); + printf("**********************************\n"); + + int userInput; + + if (userInput == 1) { + + } + +} + - (void) printBoard { if (self.spaces == nil) { @@ -75,7 +106,7 @@ - (void) chooseMove:(int)i { if ([_spaces[i] isEqualToString:_startingSpaces[i]]) { - [_spaces replaceObjectAtIndex: i withObject: @"X"]; + [_spaces replaceObjectAtIndex: i withObject: @"x"]; } [self printBoard]; @@ -86,17 +117,41 @@ - (void) chooseMove2:(int)a { if ([_spaces[a] isEqualToString:_startingSpaces[a]]) { - [_spaces replaceObjectAtIndex: a withObject: @"O"]; + [_spaces replaceObjectAtIndex: a withObject: @"o"]; } [self printBoard]; } -- (BOOL)winOrLose { +- (void) computerChooseMove:(int)c { + + BOOL moveChosen = NO; + while (!moveChosen) { + + if ([_spaces[c] isEqualToString:_startingSpaces[c]]) { + + [_spaces replaceObjectAtIndex: c withObject: @"o"]; + + [self printBoard]; + + moveChosen = YES; + + } else { + + printf("Hmmm....."); + + [self.computer computerChooseMove:arc4random_uniform(9)]; + + [self printBoard]; + + break; + + } + + } - return: YES; } @end @@ -109,19 +164,24 @@ int main(int argc, const char * argv[]) { Tictactoe *game1 = [[Tictactoe alloc] init]; [game1 printLabel]; + [game1 playerSelect]; + [game1 printBoard]; //While loop for repeat while (game1) { - [game1 printBoard]; - printf("\nHello Player 'X'\nWhere would you like to play: "); - scanf("\n%d",&userInput); - [game1 chooseMove:userInput]; - - [game1 printBoard]; - printf("\nHello Player 'O'\nWhere would you like to play: "); - scanf("\n%d", &userInput); - [game1 chooseMove2:userInput]; + + printf("\nHello Player 'X'\nWhere would you like to play: "); + scanf("\n%d",&userInput); + [game1 chooseMove:userInput]; + +// printf("\nHello Player 'O'\nWhere would you like to play: "); +// scanf("\n%d", &userInput); +// [game1 chooseMove2:userInput]; + + printf("\nHello Computer\nWhere would you like to play: "); + sleep(3); + [game1 computerChooseMove:arc4random_uniform(9)]; } } From efd8a02b6fa550f95e3d5f9c3912fe199e5caeb6 Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sun, 28 Jun 2015 12:57:40 -0400 Subject: [PATCH 10/16] Computer player fixed --- TicTacToe/TicTacToe/main.m | 40 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 0aab4a1..46fdb34 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -19,14 +19,14 @@ @implementation Player @interface Computer : Player // Computer uses 'o' -- (void) computerChooseMove:(int)c; +- (void) computerChooseMove; @end @implementation Computer -- (void) computerChooseMove:(int)c { +- (void) computerChooseMove { } @@ -42,11 +42,15 @@ - (void) playerSelect; - (void) chooseMove:(int)move; -- (void) computerChooseMove:(int)c; +- (void) computerChooseMove; + +- (BOOL) endGame; @property (nonatomic) NSMutableArray *spaces; -@property (nonatomic) NSMutableArray *startingSpaces; +@property (nonatomic) NSArray *startingSpaces; + +@property (nonatomic) NSMutableArray *computerSpaces; @property (nonatomic) Player * playerX; @@ -91,7 +95,7 @@ - (void) printBoard { if (self.spaces == nil) { self.spaces = [[NSMutableArray alloc] initWithObjects:@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", nil]; - self.startingSpaces = [[NSMutableArray alloc] initWithObjects:@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", nil]; + self.startingSpaces = [[NSArray alloc] initWithObjects:@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", nil]; } printf("\n\n"); @@ -124,12 +128,16 @@ - (void) chooseMove2:(int)a { } -- (void) computerChooseMove:(int)c { +- (void) computerChooseMove { + + int c; BOOL moveChosen = NO; while (!moveChosen) { + c = arc4random_uniform(9); + if ([_spaces[c] isEqualToString:_startingSpaces[c]]) { [_spaces replaceObjectAtIndex: c withObject: @"o"]; @@ -142,18 +150,22 @@ - (void) computerChooseMove:(int)c { printf("Hmmm....."); - [self.computer computerChooseMove:arc4random_uniform(9)]; - - [self printBoard]; - - break; } - + printf("\n%s", moveChosen ? "yes":"no"); } } +-(BOOL) endGame { + for (int i =0; i < [_spaces count]; i++) { + + + } + return YES; +} + + @end @@ -180,8 +192,8 @@ int main(int argc, const char * argv[]) { // [game1 chooseMove2:userInput]; printf("\nHello Computer\nWhere would you like to play: "); - sleep(3); - [game1 computerChooseMove:arc4random_uniform(9)]; + sleep(2); + [game1 computerChooseMove]; } } From 83936b8362dff7ec52c3fc6e54a61f0990f958d0 Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sun, 28 Jun 2015 14:58:45 -0400 Subject: [PATCH 11/16] Finished computer, working on endGame --- TicTacToe/TicTacToe/main.m | 41 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 46fdb34..085957e 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -83,11 +83,9 @@ - (void) playerSelect { printf("* *\n"); printf("**********************************\n"); - int userInput; + int select; - if (userInput == 1) { - - } + scanf("%d", &select); } @@ -148,21 +146,24 @@ - (void) computerChooseMove { } else { - printf("Hmmm....."); - + printf("Hmmm ... "); + sleep(1); } - printf("\n%s", moveChosen ? "yes":"no"); } } --(BOOL) endGame { - for (int i =0; i < [_spaces count]; i++) { +-(void) endGame { + for (int i = 0; i < [_spaces count]; i++) { + + //012 345 678 258 036 147 048 246 + // } - return YES; + + } @@ -181,21 +182,29 @@ int main(int argc, const char * argv[]) { //While loop for repeat - while (game1) { + while (true) { printf("\nHello Player 'X'\nWhere would you like to play: "); scanf("\n%d",&userInput); [game1 chooseMove:userInput]; -// printf("\nHello Player 'O'\nWhere would you like to play: "); -// scanf("\n%d", &userInput); -// [game1 chooseMove2:userInput]; + if (select == 1) { - printf("\nHello Computer\nWhere would you like to play: "); - sleep(2); + printf("\nHello Player 'O'\nWhere would you like to play: "); + scanf("\n%d", &userInput); + [game1 chooseMove2:userInput]; + + } else { + + printf("\nComputer is thinking ... "); [game1 computerChooseMove]; + [game1 endGame]; + + } } + arryRandomNumber + } return 0; } From d2b2cf09d3347243f084393ec16c3cea815e80af Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sun, 28 Jun 2015 15:39:21 -0400 Subject: [PATCH 12/16] endGame complete, still bugs present --- TicTacToe/TicTacToe/main.m | 141 ++++++++++++++++++++++++++++++++++--- 1 file changed, 130 insertions(+), 11 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 085957e..b338976 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -44,7 +44,7 @@ - (void) chooseMove:(int)move; - (void) computerChooseMove; -- (BOOL) endGame; +-(BOOL) endGame:(NSString *)x; @property (nonatomic) NSMutableArray *spaces; @@ -154,16 +154,134 @@ - (void) computerChooseMove { } --(void) endGame { - for (int i = 0; i < [_spaces count]; i++) { +-(BOOL) endGame:(NSString *)x { + + if (_spaces[0] == x && _spaces[1] == x && _spaces[2] == x) { + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_spaces[3] == x && _spaces[4] == x && _spaces[5] == x) { + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_spaces[6] == x && _spaces[7] == x && _spaces[8] == x) { + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_spaces[2] == x && _spaces[5] == x && _spaces[8] == x) { + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_spaces[0] == x && _spaces[3] == x && _spaces[6] == x) { + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_spaces[1] == x && _spaces[4] == x && _spaces[7] == x) { + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_spaces[0] == x && _spaces[4] == x && _spaces[8] == x) { + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_spaces[2] == x && _spaces[4] == x && _spaces[6] == x) { + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); - //012 345 678 258 036 147 048 246 + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else { + + return NO; - // } - - + //win conditions -- 012 345 678 258 036 147 048 246 } @@ -182,29 +300,30 @@ int main(int argc, const char * argv[]) { //While loop for repeat - while (true) { + while ([game1 endGame:@"x"] == NO && [game1 endGame:@"o"] == NO) { printf("\nHello Player 'X'\nWhere would you like to play: "); scanf("\n%d",&userInput); [game1 chooseMove:userInput]; + [game1 endGame:@"x"]; + if (select == 1) { printf("\nHello Player 'O'\nWhere would you like to play: "); scanf("\n%d", &userInput); [game1 chooseMove2:userInput]; + [game1 endGame:@"o"]; } else { printf("\nComputer is thinking ... "); [game1 computerChooseMove]; - [game1 endGame]; + [game1 endGame:@"o"]; } } - arryRandomNumber - } return 0; } From 175cffa4fd398d21f781e6345abe14fcadcea5b0 Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sun, 28 Jun 2015 17:05:01 -0400 Subject: [PATCH 13/16] Fixed playerSelect --- TicTacToe/TicTacToe/main.m | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index b338976..d4ca30a 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -38,9 +38,11 @@ - (void) printLabel; - (void) printBoard; -- (void) playerSelect; +- (int) playerSelect; -- (void) chooseMove:(int)move; +- (void) chooseMove:(int)i; + +- (void) chooseMove2:(int)a; - (void) computerChooseMove; @@ -72,7 +74,7 @@ - (void) printLabel { printf("**********************************\n"); } -- (void) playerSelect { +- (int) playerSelect { printf("**********************************\n"); printf("* *\n"); @@ -83,9 +85,9 @@ - (void) playerSelect { printf("* *\n"); printf("**********************************\n"); - int select; - - scanf("%d", &select); + int s; + scanf("%d", &s); + return s; } @@ -295,7 +297,7 @@ int main(int argc, const char * argv[]) { Tictactoe *game1 = [[Tictactoe alloc] init]; [game1 printLabel]; - [game1 playerSelect]; + int gameMode = [game1 playerSelect]; [game1 printBoard]; //While loop for repeat @@ -308,7 +310,7 @@ int main(int argc, const char * argv[]) { [game1 endGame:@"x"]; - if (select == 1) { + if (gameMode == 1) { printf("\nHello Player 'O'\nWhere would you like to play: "); scanf("\n%d", &userInput); From 5b05292c6923734611083f5c4c2a0b33ff196270 Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Sun, 28 Jun 2015 17:54:54 -0400 Subject: [PATCH 14/16] working on bugfixes if user picks same space twice --- TicTacToe/TicTacToe/main.m | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index d4ca30a..0c05018 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -111,6 +111,12 @@ - (void) chooseMove:(int)i { if ([_spaces[i] isEqualToString:_startingSpaces[i]]) { [_spaces replaceObjectAtIndex: i withObject: @"x"]; + + } else { + + printf("\nThat space isn't empty! Try again!"); + + [self chooseMove:i]; } [self printBoard]; @@ -122,6 +128,12 @@ - (void) chooseMove2:(int)a { if ([_spaces[a] isEqualToString:_startingSpaces[a]]) { [_spaces replaceObjectAtIndex: a withObject: @"o"]; + + } else { + + printf("\nThat space isn't empty! Try again!"); + + [self chooseMove2:a]; } [self printBoard]; @@ -146,11 +158,14 @@ - (void) computerChooseMove { moveChosen = YES; + } else if (_spaces[0] != _startingSpaces[0] && _spaces[1] != _startingSpaces[1] && _spaces[2] != _startingSpaces[2] && _spaces[3] != _startingSpaces[3] && _spaces[4] != _startingSpaces[4] && _spaces[5] != _startingSpaces[5] && _spaces[6] != _startingSpaces[6] && _spaces[7] != _startingSpaces[7] && _spaces[8] != _startingSpaces[8]) { + + break; + } else { printf("Hmmm ... "); sleep(1); - } } @@ -158,11 +173,17 @@ - (void) computerChooseMove { -(BOOL) endGame:(NSString *)x { - if (_spaces[0] == x && _spaces[1] == x && _spaces[2] == x) { + if (_spaces[0] != _startingSpaces[0] && _spaces[1] != _startingSpaces[1] && _spaces[2] != _startingSpaces[2] && _spaces[3] != _startingSpaces[3] && _spaces[4] != _startingSpaces[4] && _spaces[5] != _startingSpaces[5] && _spaces[6] != _startingSpaces[6] && _spaces[7] != _startingSpaces[7] && _spaces[8] != _startingSpaces[8]) { - if ([x isEqualToString: @"x"]) { + printf("\nTWO-WAY TIE!!!!"); - printf("\nPlayer X WINS!!!!!!!!!"); + return YES; + + } else if (_spaces[0] == x && _spaces[1] == x && _spaces[2] == x) { + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); return YES; @@ -278,8 +299,14 @@ -(BOOL) endGame:(NSString *)x { return YES; } - } else { + } else if (_spaces[0] != _startingSpaces[0] && _spaces[1] != _startingSpaces[1] && _spaces[2] != _startingSpaces[2] && _spaces[3] != _startingSpaces[3] && _spaces[4] != _startingSpaces[4] && _spaces[5] != _startingSpaces[5] && _spaces[6] != _startingSpaces[6] && _spaces[7] != _startingSpaces[7] && _spaces[8] != _startingSpaces[8]) { + printf("\nTWO-WAY TIE!!!!"); + + return YES; + + } else { + return NO; } @@ -308,6 +335,7 @@ int main(int argc, const char * argv[]) { scanf("\n%d",&userInput); [game1 chooseMove:userInput]; [game1 endGame:@"x"]; + [game1 endGame:@"o"]; if (gameMode == 1) { From fe75a11c274156b7ac9ae13eb4bd2fc86cb7f4bb Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Mon, 29 Jun 2015 18:27:12 -0400 Subject: [PATCH 15/16] fixed same place twice bug, working on win print twice bug --- TicTacToe/TicTacToe/main.m | 55 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 0c05018..7b505e1 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -40,9 +40,9 @@ - (void) printBoard; - (int) playerSelect; -- (void) chooseMove:(int)i; +- (void) chooseMove; -- (void) chooseMove2:(int)a; +- (void) chooseMove2; - (void) computerChooseMove; @@ -71,7 +71,7 @@ - (void) printLabel { printf("* *\n"); printf("* *\n"); printf("* TOE *\n"); - printf("**********************************\n"); + printf("**********************************\n\n"); } - (int) playerSelect { @@ -106,37 +106,55 @@ - (void) printBoard { } //First Player "X" if statement -- (void) chooseMove:(int)i { +- (void) chooseMove; { + + while (true) { + + int i; + + scanf("\n%d", &i); if ([_spaces[i] isEqualToString:_startingSpaces[i]]) { [_spaces replaceObjectAtIndex: i withObject: @"x"]; + break; + } else { - printf("\nThat space isn't empty! Try again!"); + printf("\nThat space isn't empty! Try again! "); + + } - [self chooseMove:i]; } [self printBoard]; } //Second Player "O" if statement -- (void) chooseMove2:(int)a { +- (void) chooseMove2 { + + while (true) { + + int a; + + scanf("\n%d", &a); if ([_spaces[a] isEqualToString:_startingSpaces[a]]) { [_spaces replaceObjectAtIndex: a withObject: @"o"]; + break; + } else { - printf("\nThat space isn't empty! Try again!"); + printf("\nThat space isn't empty! Try again! "); + } - [self chooseMove2:a]; } [self printBoard]; + } @@ -320,7 +338,6 @@ -(BOOL) endGame:(NSString *)x { int main(int argc, const char * argv[]) { @autoreleasepool { - int userInput; Tictactoe *game1 = [[Tictactoe alloc] init]; [game1 printLabel]; @@ -332,24 +349,22 @@ int main(int argc, const char * argv[]) { while ([game1 endGame:@"x"] == NO && [game1 endGame:@"o"] == NO) { printf("\nHello Player 'X'\nWhere would you like to play: "); - scanf("\n%d",&userInput); - [game1 chooseMove:userInput]; + [game1 chooseMove]; [game1 endGame:@"x"]; [game1 endGame:@"o"]; if (gameMode == 1) { - printf("\nHello Player 'O'\nWhere would you like to play: "); - scanf("\n%d", &userInput); - [game1 chooseMove2:userInput]; - [game1 endGame:@"o"]; + printf("\nHello Player 'O'\nWhere would you like to play: "); + [game1 chooseMove2]; + [game1 endGame:@"o"]; } else { - - printf("\nComputer is thinking ... "); - [game1 computerChooseMove]; - [game1 endGame:@"o"]; + + printf("\nComputer is thinking ... "); + [game1 computerChooseMove]; + [game1 endGame:@"o"]; } } From d608c1e9971c6879b06a4fcdf582dcae4fbf7ec5 Mon Sep 17 00:00:00 2001 From: Daniel Distant Date: Wed, 1 Jul 2015 21:57:59 -0400 Subject: [PATCH 16/16] Ran out of time to implement 4x4 mode --- TicTacToe/TicTacToe/main.m | 232 ++++++++++++++++++++++++++++++++----- 1 file changed, 204 insertions(+), 28 deletions(-) diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 7b505e1..c818d41 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -40,6 +40,8 @@ - (void) printBoard; - (int) playerSelect; +- (int) gameSelect; + - (void) chooseMove; - (void) chooseMove2; @@ -48,11 +50,15 @@ - (void) computerChooseMove; -(BOOL) endGame:(NSString *)x; +-(BOOL) endFourGame:(NSString *)x; + @property (nonatomic) NSMutableArray *spaces; @property (nonatomic) NSArray *startingSpaces; -@property (nonatomic) NSMutableArray *computerSpaces; +@property (nonatomic) NSMutableArray *fourSpaces; + +@property (nonatomic) NSArray *fourStartingSpaces; @property (nonatomic) Player * playerX; @@ -91,6 +97,23 @@ - (int) playerSelect { } +- (int) gameSelect { + + printf("**********************************\n"); + printf("* *\n"); + printf("* 0) 3-by-3 *\n"); + printf("* *\n"); + printf("* *\n"); + printf("* 1) 4-by-4 *\n"); + printf("* *\n"); + printf("**********************************\n"); + + int g; + scanf("%d", &g); + return g; + +} + - (void) printBoard { if (self.spaces == nil) { @@ -104,27 +127,43 @@ - (void) printBoard { printf("%s|%s|%s\n-----\n%s|%s|%s\n-----\n%s|%s|%s\n", [_spaces[0] UTF8String], [_spaces[1] UTF8String], [_spaces[2] UTF8String], [_spaces[3] UTF8String], [_spaces[4] UTF8String],[_spaces[5] UTF8String],[_spaces[6] UTF8String], [_spaces[7] UTF8String], [_spaces[8] UTF8String]); } -//First Player "X" if statement -- (void) chooseMove; { +- (void) printFourBoard { - while (true) { + if (self.fourSpaces == nil) { + self.fourSpaces = [[NSMutableArray alloc] initWithObjects:@"00", @"01", @"02", @"03", @"04", @"05", @"06", @"07", @"08", @"09", @"10", @"11", @"12", @"13", @"14", @"15", nil]; + self.fourStartingSpaces = [[NSArray alloc] initWithObjects:@"00", @"01", @"02", @"03", @"04", @"05", @"06", @"07", @"08",@"09", @"10", @"11", @"12", @"13", @"14", @"15", nil]; + } - int i; + printf("\n\n"); - scanf("\n%d", &i); + //4x4 Tic Tac Toe Board - if ([_spaces[i] isEqualToString:_startingSpaces[i]]) { - - [_spaces replaceObjectAtIndex: i withObject: @"x"]; - - break; + //Tic Tac Toe Board + + printf("%s|%s|%s|%s\n--------\n%s|%s|%s|%s\n--------\n%s|%s|%s|%s\n--------\n%s|%s|%s|%s\n", [_spaces[0] UTF8String], [_spaces[1] UTF8String], [_spaces[2] UTF8String], [_spaces[3] UTF8String], [_spaces[4] UTF8String],[_spaces[5] UTF8String],[_spaces[6] UTF8String], [_spaces[7] UTF8String], [_spaces[8] UTF8String],[_spaces[9] UTF8String], [_spaces[10] UTF8String], [_spaces[11] UTF8String], [_spaces[12] UTF8String], [_spaces[13] UTF8String], [_spaces[14] UTF8String], [_spaces[15] UTF8String]); +} +//First Player "X" if statement + +- (void) chooseMove; { + + while (true) { - } else { + int i; - printf("\nThat space isn't empty! Try again! "); + scanf("\n%d", &i); - } + if ([_spaces[i] isEqualToString:_startingSpaces[i]]) { + + [_spaces replaceObjectAtIndex: i withObject: @"x"]; + + break; + + } else { + + printf("\nThat space isn't empty! Try again! "); + + } } @@ -135,26 +174,25 @@ - (void) chooseMove; { - (void) chooseMove2 { while (true) { - - int a; - - scanf("\n%d", &a); - - if ([_spaces[a] isEqualToString:_startingSpaces[a]]) { - - [_spaces replaceObjectAtIndex: a withObject: @"o"]; - break; + int a; - } else { + scanf("\n%d", &a); - printf("\nThat space isn't empty! Try again! "); - } + if ([_spaces[a] isEqualToString:_startingSpaces[a]]) { + + [_spaces replaceObjectAtIndex: a withObject: @"o"]; + + break; + + } else { + + printf("\nThat space isn't empty! Try again! "); + } } [self printBoard]; - } @@ -329,8 +367,147 @@ -(BOOL) endGame:(NSString *)x { } //win conditions -- 012 345 678 258 036 147 048 246 + + } +-(BOOL) endFourGame:(NSString *)x { + + if (_fourSpaces[0] == x && _fourSpaces[1] == x && _fourSpaces[2] == x && _fourSpaces[3] == x) { //Top/First Row + + if ([x isEqualToString: @"X"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_fourSpaces[3] == x && _fourSpaces[7] == x && _fourSpaces[11] == x &&_fourSpaces[15] == x) { //Right Going down + + if ([x isEqualToString: @"X"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_fourSpaces[4] == x && _fourSpaces[5] == x && _fourSpaces[6] == x &&_fourSpaces [7] == x) { // Second Row + + if ([x isEqualToString: @"X"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_fourSpaces[3] == x && _fourSpaces[6] == x && _fourSpaces[9] == x &&_fourSpaces[12] == x) { // Top Right to Bottom Left + + if ([x isEqualToString: @"X"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_fourSpaces[0] == x && _fourSpaces[4] == x && _fourSpaces[8] == x && _fourSpaces[12] == x) { //Left going down + + if ([x isEqualToString: @"X"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_fourSpaces[8] == x && _fourSpaces[9] == x && _fourSpaces[10] == x &&_fourSpaces[11] == x) { //Third Row + + if ([x isEqualToString: @"X"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_fourSpaces[1] == x && _fourSpaces[5] == x && _fourSpaces[9] == x &&_fourSpaces[13] == x) { //Second Row Down + + if ([x isEqualToString: @"X"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + + } else if (_fourSpaces[2] == x && _fourSpaces[6] == x && _fourSpaces[10] == x &&_fourSpaces[14] == x) { //Third row down + + if ([x isEqualToString: @"x"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } else { + + printf("\nComputer WINS!!!!!!!"); + + return YES; + } + } else if (_fourSpaces[0] == x && _fourSpaces[5] == x && _fourSpaces[10] == x &&_fourSpaces[15] == x) { //Top Left to Bottom Right + + if ([x isEqualToString: @"X"]) { + + printf("\nPlayer X WINS!!!!!!!!!"); + + return YES; + + } + + } else if (_fourSpaces[0] != _fourStartingSpaces[0] && _fourSpaces[1] != _fourStartingSpaces[1] && _fourSpaces[2] != _fourStartingSpaces[2] && _fourSpaces[3] != _fourStartingSpaces[3] && _fourSpaces[4] != _fourStartingSpaces[4] && _fourSpaces[5] != _fourStartingSpaces[5] && _fourSpaces[6] != _fourStartingSpaces[6] && _fourSpaces[7] != _fourStartingSpaces[7] && _fourSpaces[8] != _fourStartingSpaces[8] && _fourSpaces[9] != _fourStartingSpaces[9] && _fourSpaces[10] != _fourStartingSpaces[10] && _fourSpaces[11] != _fourStartingSpaces[11] && _fourSpaces[12] != _fourStartingSpaces[12] && _fourSpaces[13] != _fourStartingSpaces[13] && _fourSpaces[14] != _fourStartingSpaces[14] && _fourSpaces[15] != _fourStartingSpaces[15]) + + printf("\nTWO-WAY TIE!!!!"); + + return YES; +} @end @@ -351,7 +528,6 @@ int main(int argc, const char * argv[]) { printf("\nHello Player 'X'\nWhere would you like to play: "); [game1 chooseMove]; [game1 endGame:@"x"]; - [game1 endGame:@"o"]; if (gameMode == 1) {