Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ All directions are here...
https://github.com/accesscode-2-2/unit-0/tree/master/project

Instructions on forking and pull requests here... https://github.com/accesscode-2-2/how-to-pr

hi my name is eric

lololololol
43 changes: 43 additions & 0 deletions TicTacToe/TicTacToe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
objects = {

/* Begin PBXBuildFile section */
692E08551B533C8300A52FCC /* NSString+isNumeric.m in Sources */ = {isa = PBXBuildFile; fileRef = 692E08541B533C8300A52FCC /* NSString+isNumeric.m */; };
695078051B4C867600735A8D /* Game.m in Sources */ = {isa = PBXBuildFile; fileRef = 695078041B4C867600735A8D /* Game.m */; };
695078081B4C880600735A8D /* NSArray+LineChecker.m in Sources */ = {isa = PBXBuildFile; fileRef = 695078071B4C880600735A8D /* NSArray+LineChecker.m */; };
6950780B1B4C893600735A8D /* MyTicTacToeGame.m in Sources */ = {isa = PBXBuildFile; fileRef = 6950780A1B4C893600735A8D /* MyTicTacToeGame.m */; };
6950780E1B4C97FD00735A8D /* Player.m in Sources */ = {isa = PBXBuildFile; fileRef = 6950780D1B4C97FD00735A8D /* Player.m */; };
6965035B1B51B1CD00300B68 /* ComputerPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6965035A1B51B1CD00300B68 /* ComputerPlayer.m */; };
698005621B547295008F3E8A /* TicTacToeRowGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 698005611B547295008F3E8A /* TicTacToeRowGenerator.m */; };
8D9789E41B3C9A70007CF4CF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D9789E31B3C9A70007CF4CF /* main.m */; };
/* End PBXBuildFile section */

Expand All @@ -23,6 +30,20 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
692E08531B533C8300A52FCC /* NSString+isNumeric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+isNumeric.h"; sourceTree = "<group>"; };
692E08541B533C8300A52FCC /* NSString+isNumeric.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+isNumeric.m"; sourceTree = "<group>"; };
695078031B4C867600735A8D /* Game.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Game.h; sourceTree = "<group>"; };
695078041B4C867600735A8D /* Game.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Game.m; sourceTree = "<group>"; };
695078061B4C880600735A8D /* NSArray+LineChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+LineChecker.h"; sourceTree = "<group>"; };
695078071B4C880600735A8D /* NSArray+LineChecker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+LineChecker.m"; sourceTree = "<group>"; };
695078091B4C893600735A8D /* MyTicTacToeGame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyTicTacToeGame.h; sourceTree = "<group>"; };
6950780A1B4C893600735A8D /* MyTicTacToeGame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyTicTacToeGame.m; sourceTree = "<group>"; };
6950780C1B4C97FD00735A8D /* Player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Player.h; sourceTree = "<group>"; };
6950780D1B4C97FD00735A8D /* Player.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Player.m; sourceTree = "<group>"; };
696503591B51B1CD00300B68 /* ComputerPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComputerPlayer.h; sourceTree = "<group>"; };
6965035A1B51B1CD00300B68 /* ComputerPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComputerPlayer.m; sourceTree = "<group>"; };
698005601B547295008F3E8A /* TicTacToeRowGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TicTacToeRowGenerator.h; sourceTree = "<group>"; };
698005611B547295008F3E8A /* TicTacToeRowGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TicTacToeRowGenerator.m; sourceTree = "<group>"; };
8D9789E01B3C9A70007CF4CF /* TicTacToe */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TicTacToe; sourceTree = BUILT_PRODUCTS_DIR; };
8D9789E31B3C9A70007CF4CF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -58,6 +79,20 @@
isa = PBXGroup;
children = (
8D9789E31B3C9A70007CF4CF /* main.m */,
6950780C1B4C97FD00735A8D /* Player.h */,
6950780D1B4C97FD00735A8D /* Player.m */,
695078031B4C867600735A8D /* Game.h */,
695078041B4C867600735A8D /* Game.m */,
696503591B51B1CD00300B68 /* ComputerPlayer.h */,
6965035A1B51B1CD00300B68 /* ComputerPlayer.m */,
695078091B4C893600735A8D /* MyTicTacToeGame.h */,
6950780A1B4C893600735A8D /* MyTicTacToeGame.m */,
698005601B547295008F3E8A /* TicTacToeRowGenerator.h */,
698005611B547295008F3E8A /* TicTacToeRowGenerator.m */,
695078061B4C880600735A8D /* NSArray+LineChecker.h */,
695078071B4C880600735A8D /* NSArray+LineChecker.m */,
692E08531B533C8300A52FCC /* NSString+isNumeric.h */,
692E08541B533C8300A52FCC /* NSString+isNumeric.m */,
);
path = TicTacToe;
sourceTree = "<group>";
Expand Down Expand Up @@ -118,7 +153,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6950780B1B4C893600735A8D /* MyTicTacToeGame.m in Sources */,
698005621B547295008F3E8A /* TicTacToeRowGenerator.m in Sources */,
692E08551B533C8300A52FCC /* NSString+isNumeric.m in Sources */,
8D9789E41B3C9A70007CF4CF /* main.m in Sources */,
695078081B4C880600735A8D /* NSArray+LineChecker.m in Sources */,
6965035B1B51B1CD00300B68 /* ComputerPlayer.m in Sources */,
695078051B4C867600735A8D /* Game.m in Sources */,
6950780E1B4C97FD00735A8D /* Player.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -235,6 +277,7 @@
8D9789E91B3C9A70007CF4CF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
13 changes: 13 additions & 0 deletions TicTacToe/TicTacToe/ComputerPlayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// ComputerPlayer.h
// TicTacToe
//
// Created by Z on 7/11/15.
// Copyright (c) 2015 Mike Kavouras. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface ComputerPlayer : NSObject

@end
92 changes: 92 additions & 0 deletions TicTacToe/TicTacToe/ComputerPlayer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// ComputerPlayer.m
// TicTacToe
//
// Created by Z on 7/11/15.
// Copyright (c) 2015 Mike Kavouras. All rights reserved.
//

#import "ComputerPlayer.h"

@implementation ComputerPlayer


// //Easy Mode computer move
// if (_difficulty == 1) {
// int computerMove = arc4random_uniform(_maxIndex + 1);
// if ((![[_gameboard objectAtIndex:computerMove] isEqual: @"~X"]) && (![[_gameboard objectAtIndex:computerMove] isEqual: @"~O"])) {
// NSLog(@"Computer is making a move...");
// sleep(1.5);
// [_gameboard replaceObjectAtIndex:(NSUInteger)computerMove withObject:@"~O"];



//-(BOOL)checkWin{
//
// NSString *playerPiece;
//
// for (int i = 0; i < 2; i++) {
//
// //sets player piece for each of the two loops
// if (i == 1) {
// playerPiece = @"~X";
// _winner = @"Player 1";
// }
// else{
// playerPiece = @"~O";
// _winner = @"Player 2";
// }
//
// // |X|X|X|
// // | | | |
// // | | | |
// if (([_gameboard[0] isEqual:playerPiece]) && ([_gameboard[1] isEqual:playerPiece]) && ([_gameboard[2] isEqual:playerPiece])){
// return YES;
// }
// // | | | |
// // |X|X|X|
// // | | | |
// if (([_gameboard[3] isEqual:playerPiece]) && ([_gameboard[4] isEqual:playerPiece]) && ([_gameboard[5] isEqual:playerPiece])){
// return YES;
// }
// // | | | |
// // | | | |
// // |X|X|X|
// if (([_gameboard[6] isEqual:playerPiece]) && ([_gameboard[7] isEqual:playerPiece]) && ([_gameboard[8] isEqual:playerPiece])){
// return YES;
// }
// // |X| | |
// // |X| | |
// // |X| | |
// if (([_gameboard[0] isEqual:playerPiece]) && ([_gameboard[3] isEqual:playerPiece]) && ([_gameboard[6] isEqual:playerPiece])){
// return YES;
// }
// // | |X| |
// // | |X| |
// // | |X| |
// if (([_gameboard[1] isEqual:playerPiece]) && ([_gameboard[4] isEqual:playerPiece]) && ([_gameboard[7] isEqual:playerPiece])){
// return YES;
// }
// // | | |X|
// // | | |X|
// // | | |X|
// if (([_gameboard[2] isEqual:playerPiece]) && ([_gameboard[5] isEqual:playerPiece]) && ([_gameboard[8] isEqual:playerPiece])){
// return YES;
// }
// // |X| | |
// // | |X| |
// // | | |X|
// if (([_gameboard[0] isEqual:playerPiece]) && ([_gameboard[4] isEqual:playerPiece]) && ([_gameboard[8] isEqual:playerPiece])){
// return YES;
// }
// // | | |X|
// // | |X| |
// // |X| | |
// if (([_gameboard[2] isEqual:playerPiece]) && ([_gameboard[4] isEqual:playerPiece]) && ([_gameboard[6] isEqual:playerPiece])){
// return YES;
// }
//
// }
// return NO;
//}
@end
62 changes: 62 additions & 0 deletions TicTacToe/TicTacToe/Game.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// Game.h
// TicTacToe
//
// Created by Z on 7/7/15.
// Copyright (c) 2015 Mike Kavouras. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, PossibleWinner) {
PlayerX,
PlayerO,
ComputerX,
ComputerO,
noWinNextMove
};

typedef NS_ENUM(NSUInteger, Difficulty) {
Easy = 1,
Medium = 2,
Hard =3
};

typedef NS_ENUM(NSUInteger, Mode) {
PlayerVsPlayer = 1,
PlayerVsComputer = 2,
ComputerVsComputer =3
};

@interface Game : NSObject

-(BOOL)checkWin;
-(BOOL)getWin;

-(BOOL)checkDraw;

-(void)setupGame;

- (NSMutableArray *)getGameBoard;

-(void)printBoard;
-(void)printTutorialBoard;

-(void)turn;
-(int)getTurnCount;

-(void)setGameSize:(int)size;
-(int)getGameSize;

- (void)getGameBoard:(NSArray *)gameBoard;

//Easy, Medium, Hard
-(void)setDifficulty:(int)level;
-(int)getDifficulty;

//Player vs. Player OR Player vs. Computer
-(void)setMode:(int)mode;
-(int)getMode;


@end
Loading