From a5c70261fa1fde3ce0f268145850d508157d02a9 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Fri, 21 Oct 2016 03:24:45 +0000 Subject: [PATCH 01/25] removed Donald's work --- Sources/KonaneColor.swift | 3 - Sources/KonaneGame.swift | 96 ------------------------ Sources/KonaneGameState.swift | 88 ---------------------- Sources/KonaneMove.swift | 14 ---- Sources/KonaneMoveInputSource.swift | 19 ----- Sources/KonaneMoveInputSourceHuman.swift | 42 ----------- 6 files changed, 262 deletions(-) delete mode 100644 Sources/KonaneColor.swift delete mode 100644 Sources/KonaneGame.swift delete mode 100644 Sources/KonaneGameState.swift delete mode 100644 Sources/KonaneMove.swift delete mode 100644 Sources/KonaneMoveInputSource.swift delete mode 100644 Sources/KonaneMoveInputSourceHuman.swift diff --git a/Sources/KonaneColor.swift b/Sources/KonaneColor.swift deleted file mode 100644 index 9e9cfcb..0000000 --- a/Sources/KonaneColor.swift +++ /dev/null @@ -1,3 +0,0 @@ -enum KonaneColor { - case black, white, empty -} diff --git a/Sources/KonaneGame.swift b/Sources/KonaneGame.swift deleted file mode 100644 index ac4d205..0000000 --- a/Sources/KonaneGame.swift +++ /dev/null @@ -1,96 +0,0 @@ -class KonaneGame { - private let gameState: KonaneGameState = KonaneGameState() - private let blackInputSource: KonaneMoveInputSource - private let whiteInputSource: KonaneMoveInputSource - - init(blackIsHuman: Bool, whiteIsHuman: Bool) { - if blackIsHuman { - blackInputSource = KonaneMoveInputSourceHuman(isBlack: true) - } else { - fatalError("Doesn't work yet!") - } - - if whiteIsHuman { - whiteInputSource = KonaneMoveInputSourceHuman(isBlack: false) - } else { - fatalError("Doesn't work yet!") - } - } - - func play() -> Bool { - // Remove Phase - print("Black starts by removing a middle or corner black piece") - displayBoard() - - let blackRemovePoint = blackInputSource.removeFirstPiece(gameState: gameState.copy()) - gameState.perform(blackRemove: blackRemovePoint) - - print("Now white removes an adjacent white piece") - displayBoard() - - let whiteRemovePoint = whiteInputSource.removeSecondPiece(gameState: gameState.copy()) - gameState.perform(whiteRemove: whiteRemovePoint) - - // Now, main game loop - while gameState.didBlackWin() == false && gameState.didWhiteWin() == false { - - let move: KonaneMove - if gameState.getIsBlackTurn() { - print("It is black's turn to jump") - displayBoard() - move = blackInputSource.nextMove(gameState: gameState.copy()) - } else { - print("It is white's turn to jump") - displayBoard() - move = whiteInputSource.nextMove(gameState: gameState.copy()) - } - - gameState.perform(move: move) - } - - let blackWins = gameState.didBlackWin() - if blackWins { - print("Black wins!") - } else { - print("White wins!") - } - return blackWins - } - - private func displayBoard() { - displayASCIIBoard() - } - - private func displayASCIIBoard() { - for y in (0.. KonaneGameState { - let c = KonaneGameState() - c.board = board - c.isBlackTurn = isBlackTurn - return c - } - - func getIsBlackTurn() -> Bool { - return isBlackTurn - } - - func color(atX: Int, atY: Int) -> KonaneColor { - return board[atX][atY] - } - - func isValid(move: KonaneMove) -> Bool { - print("Doesn't work yet") - return true - } - - func isValid(blackRemove: (x: Int, y: Int)) -> Bool { - print("Doesn't work yet") - return true - } - - func isValid(whiteRemove: (x: Int, y: Int)) -> Bool { - print("Doesn't work yet") - return true - } - - func perform(move: KonaneMove) { - print("Doesn't work yet!") - - isBlackTurn = !isBlackTurn - } - - func perform(blackRemove: (x: Int, y: Int)) { - var remove = blackRemove - if !isValid(blackRemove: remove) { - fatalError("Invalid black remove: \(remove)") - } - - board[remove.x][remove.y] = KonaneColor.empty - } - - func perform(whiteRemove: (x: Int, y: Int)) { - var remove = whiteRemove - if !isValid(whiteRemove: remove) { - fatalError("Invalid white remove: \(remove)") - } - - board[remove.x][remove.y] = KonaneColor.empty - } - - func didBlackWin() -> Bool { - print("Doesn't work yet!") - return false - } - - func didWhiteWin() -> Bool { - print("Doesn't work yet!") - return false - } -} diff --git a/Sources/KonaneMove.swift b/Sources/KonaneMove.swift deleted file mode 100644 index 610e0f9..0000000 --- a/Sources/KonaneMove.swift +++ /dev/null @@ -1,14 +0,0 @@ -class KonaneMove { - let fromX: Int - let fromY: Int - let toX: Int - let toY: Int - - init(fromX: Int, fromY: Int, toX: Int, toY: Int) { - self.fromX = fromX - self.fromY = fromY - self.toX = toX - self.toY = toY - } - -} diff --git a/Sources/KonaneMoveInputSource.swift b/Sources/KonaneMoveInputSource.swift deleted file mode 100644 index a2554b4..0000000 --- a/Sources/KonaneMoveInputSource.swift +++ /dev/null @@ -1,19 +0,0 @@ -class KonaneMoveInputSource { - let isBlack: Bool - - init(isBlack: Bool) { - self.isBlack = isBlack - } - - func removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { - fatalError("Override me!") - } - - func removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { - fatalError("Override me!") - } - - func nextMove(gameState: KonaneGameState) -> KonaneMove { - fatalError("Override me!") - } -} diff --git a/Sources/KonaneMoveInputSourceHuman.swift b/Sources/KonaneMoveInputSourceHuman.swift deleted file mode 100644 index f933529..0000000 --- a/Sources/KonaneMoveInputSourceHuman.swift +++ /dev/null @@ -1,42 +0,0 @@ -class KonaneMoveInputSourceHuman : KonaneMoveInputSource { - override func removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { - while true { - print("Input x coord to remove black piece:") - let x = Int(readLine()!)! - print("Input y coord to remove black piece:") - let y = Int(readLine()!)! - - if gameState.isValid(blackRemove: (x, y)) { - return (x, y) - } - } - } - - override func removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { - while true { - print("Input x coord to remove white piece:") - let x = Int(readLine()!)! - print("Input y coord to remove white piece:") - let y = Int(readLine()!)! - - if gameState.isValid(whiteRemove: (x, y)) { - return (x, y) - } - } - } - - override func nextMove(gameState: KonaneGameState) -> KonaneMove { - print("Input x coord to move from:") - let fx = Int(readLine()!)! - print("Input y coord to move from:") - let fy = Int(readLine()!)! - - print("Input x coord to move to:") - let tx = Int(readLine()!)! - print("Input y coord to move to:") - let ty = Int(readLine()!)! - - - return KonaneMove(fromX: fx, fromY: fy, toX: tx, toY: ty) - } -} From 430e87cbbc7eebb34e95cf16a731f2c8055c74c1 Mon Sep 17 00:00:00 2001 From: Astha Sahoo Date: Sun, 23 Oct 2016 12:40:51 -0700 Subject: [PATCH 02/25] I made a couple of changes, mainly just testing it out, btw this is Astha :) --- Sources/main.swift | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index eddd5e8..861231d 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,2 +1,16 @@ -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win? \(game.play())") +class KonaneGame { + let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) + print("Did black win? \(game.play())") + init() { + var BlackIsHuman = Bool + var WhiteIsHuman = Bool + if BlackIsHuman == false { + WhiteIsHuman == true + } else { + BlackIsHuman == true + } + } + var private.gameState: KonaneGameState + let private.blackInputSource: KonaneMoveInputSource + let private.whiteInputSource: KonaneMoveInputSource +} From 3b09ea86457bc1728413579220bfaf38ddbf7c18 Mon Sep 17 00:00:00 2001 From: Astha Sahoo Date: Sun, 23 Oct 2016 14:16:59 -0700 Subject: [PATCH 03/25] I added a couple more properties to the file, I'm commiting it so I don't lose my work and don't trust my computer --- Sources/main.swift | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Sources/main.swift b/Sources/main.swift index 861231d..7ba5311 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -14,3 +14,42 @@ class KonaneGame { let private.blackInputSource: KonaneMoveInputSource let private.whiteInputSource: KonaneMoveInputSource } +class Konane { + width: Int = 16 + height: Int = 16 + init() {} + private.internalboarddatastorage: + private.isBlackTurn: Bool + var getIsBlackTurn: Bool + let color: atX: Int, atY: Int) -> KonaneColor +//Are the following functions? The ones that I pointed out down in the list???? + func isValid(move: KonaneMove) -> Bool + func isValid(blackRemove: (x: Int, y: Int)) -> Bool { + if IsValid == false { + print(x, y + "is not valid") + } else { + print("The move is valid") + } + } + + +} + +KonaneGameState + - width: Int = 16 + - height: Int = 16 + - init() + - private internal board data storage + - private isBlackTurn: Bool + - getIsBlackTurn() -> Bool + - color(atX: Int, atY: Int) -> KonaneColor // Bottom left, 0-indexed + //Are the following properties functions, cuz I'm not really sure... + - isValid(move: KonaneMove) -> Bool + - isValid(blackRemove: (x: Int, y: Int)) -> Bool + - isValid(whiteRemove: (x: Int, y: Int)) -> Bool + - perform(move: KonaneMove) + - perform(blackRemove: (x: Int, y: Int)) + - perform(whiteRemove: (x: Int, y: Int)) + - didBlackWin() -> Bool + - didWhiteWin() -> Bool + From 0cd73873c1727dea7f9981186c76b6059b4e7d49 Mon Sep 17 00:00:00 2001 From: Astha Sahoo Date: Sun, 23 Oct 2016 18:43:39 -0700 Subject: [PATCH 04/25] I mite be doing something wrong, care to help out? :) --- Sources/main.swift | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 7ba5311..0c7306a 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -34,8 +34,19 @@ class Konane { } - -KonaneGameState +enum KonaneColor { + case black + case white + case empty +} +class KonaneMove { + init(fromX: Int, fromY: Int, toX: Int, toY: Int) + var fromX = Int + var fromY + var toX + var toY +} +//KonaneGameState - width: Int = 16 - height: Int = 16 - init() @@ -43,7 +54,7 @@ KonaneGameState - private isBlackTurn: Bool - getIsBlackTurn() -> Bool - color(atX: Int, atY: Int) -> KonaneColor // Bottom left, 0-indexed - //Are the following properties functions, cuz I'm not really sure... + Are the following properties functions, cuz I'm not really sure... - isValid(move: KonaneMove) -> Bool - isValid(blackRemove: (x: Int, y: Int)) -> Bool - isValid(whiteRemove: (x: Int, y: Int)) -> Bool From f9ea3357e0a098edcf858f9bb3ee3959d720ba66 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Tue, 25 Oct 2016 02:45:13 +0000 Subject: [PATCH 05/25] wrote skeleton code for KonaneGame as a class and all of it's states --- Sources/KonaneGame.swift | 10 ++++++++++ Sources/KonaneGameState.swift | 0 Sources/KonaneMoveInputSource.swift | 0 3 files changed, 10 insertions(+) create mode 100644 Sources/KonaneGame.swift create mode 100644 Sources/KonaneGameState.swift create mode 100644 Sources/KonaneMoveInputSource.swift diff --git a/Sources/KonaneGame.swift b/Sources/KonaneGame.swift new file mode 100644 index 0000000..bb60dbd --- /dev/null +++ b/Sources/KonaneGame.swift @@ -0,0 +1,10 @@ +class KonaneGame { + init(blackIsHuman: Bool, whiteIsHuman: Bool) + private gameState: KonaneGameState + private blackInputSource: KonaneMoveInputSource + private whiteInputSource: KonaneMoveInputSource + play() -> Bool // returns true if black wins + private displayBoard() +} + + diff --git a/Sources/KonaneGameState.swift b/Sources/KonaneGameState.swift new file mode 100644 index 0000000..e69de29 diff --git a/Sources/KonaneMoveInputSource.swift b/Sources/KonaneMoveInputSource.swift new file mode 100644 index 0000000..e69de29 From b1661c6a9e2e907afd584e2a245a8317aa90cb17 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Tue, 25 Oct 2016 02:48:32 +0000 Subject: [PATCH 06/25] added skeleton for KonaneGame and created files for other classes --- Sources/main.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index eddd5e8..8b13789 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,2 +1 @@ -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win? \(game.play())") + From 7cf7fb3219ce6661ed2a3cf1562192a426d2840e Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Tue, 25 Oct 2016 04:21:29 +0000 Subject: [PATCH 07/25] I tried to turn some of the list of KonaneGameState into code --- Sources/main.swift | 62 +++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 8735b29..c80721d 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -28,10 +28,11 @@ class Konane { //Are the following functions? The ones that I pointed out down in the list???? func isValid(move: KonaneMove) -> Bool func isValid(blackRemove: (x: Int, y: Int)) -> Bool { - if IsValid == false { - print(x, y + "is not valid") - } else { - print("The move is valid") + if IsValid == false { + print(x, y + "is not valid") + } + else { + print("The move is valid") } } @@ -48,23 +49,38 @@ class KonaneMove { var fromY var toX var toY -} -//KonaneGameState - - width: Int = 16 - - height: Int = 16 - - init() - - private internal board data storage - - private isBlackTurn: Bool - - getIsBlackTurn() -> Bool - - color(atX: Int, atY: Int) -> KonaneColor // Bottom left, 0-indexed - Are the following properties functions, cuz I'm not really sure... - - isValid(move: KonaneMove) -> Bool - - isValid(blackRemove: (x: Int, y: Int)) -> Bool - - isValid(whiteRemove: (x: Int, y: Int)) -> Bool - - perform(move: KonaneMove) - - perform(blackRemove: (x: Int, y: Int)) - - perform(whiteRemove: (x: Int, y: Int)) - - didBlackWin() -> Bool - - didWhiteWin() -> Bool - +class KonaneGameState + let width: Int = 16 + let height: Int = 16 + var init() + private InternalBoardDataStorage + /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ + private var isBlackTurn: Bool + print(getIsBlackTurn) + + /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY: Int)) */ + + /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ + + /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ + + isValid(move: KonaneMove) + isValid(blackRemove: (x: Int, y: Int)) + isValid(whiteRemove: (x: Int, y: Int)) + perform(move: KonaneMove) + perform(blackRemove: (x: Int, y: Int)) + perform(whiteRemove: (x: Int, y: Int)) + didBlackWin() + didWhiteWin() + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ + + + + + + + + + + >>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 From b42b1238932f6506384c588866e0eaf845caa2e1 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Thu, 27 Oct 2016 02:38:58 +0000 Subject: [PATCH 08/25] copied from Xcode and fixed (?) some of the errors --- Sources/main.swift | 139 +++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 79 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index c80721d..28ba58a 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,86 +1,67 @@ -<<<<<<< HEAD - -======= class KonaneGame { - let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) - print("Did black win? \(game.play())") - init() { - var BlackIsHuman = Bool - var WhiteIsHuman = Bool - if BlackIsHuman == false { - WhiteIsHuman == true - } else { - BlackIsHuman == true - } - } - var private.gameState: KonaneGameState - let private.blackInputSource: KonaneMoveInputSource - let private.whiteInputSource: KonaneMoveInputSource + let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) + print("Did black win? \(game.play()")) + init() { + var BlackIsHuman = Bool + var WhiteIsHuman = Bool + if BlackIsHuman == false { + WhiteIsHuman == true + } else { + BlackIsHuman == true + } + } + var gameState: KonaneGameState + private let blackInputSource: KonaneMoveInputSource + private let whiteInputSource: KonaneMoveInputSource } class Konane { - width: Int = 16 - height: Int = 16 - init() {} - private.internalboarddatastorage: - private.isBlackTurn: Bool - var getIsBlackTurn: Bool - let color: atX: Int, atY: Int) -> KonaneColor -//Are the following functions? The ones that I pointed out down in the list???? - func isValid(move: KonaneMove) -> Bool - func isValid(blackRemove: (x: Int, y: Int)) -> Bool { - if IsValid == false { - print(x, y + "is not valid") - } - else { - print("The move is valid") - } - } - - + let width: Int = 16 + let height: Int = 16 + init() {} + internalboarddatastorage: + private let isBlackTurn = Bool + var getIsBlackTurn: Bool + let color: (atX: Int, atY: Int) -> KonaneColor + //Are the following functions? The ones that I pointed out down in the list???? + func isValid(move: KonaneMove) -> Bool + func isValid(blackRemove: (x: Int, y: Int)) -> Bool { + if isValid == false { + print(x, y + "is not valid") + } + else { + print("The move is valid + } +} + + } enum KonaneColor { - case black - case white - case empty + case black + case white + case empty } class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int) - var fromX = Int - var fromY - var toX - var toY -class KonaneGameState - let width: Int = 16 - let height: Int = 16 - var init() - private InternalBoardDataStorage - /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ - private var isBlackTurn: Bool - print(getIsBlackTurn) - - /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY: Int)) */ - - /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ - - /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - - isValid(move: KonaneMove) - isValid(blackRemove: (x: Int, y: Int)) - isValid(whiteRemove: (x: Int, y: Int)) - perform(move: KonaneMove) - perform(blackRemove: (x: Int, y: Int)) - perform(whiteRemove: (x: Int, y: Int)) - didBlackWin() - didWhiteWin() - /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ - - - - - - - - - - ->>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 + init(fromX: Int, fromY: Int, toX: Int, toY: Int) + var fromX = Int + var fromY + var toX + var toY + class KonaneGameState { + let width: Int = 16 + let height: Int = 16 + init (KonaneGameStateWidth: Int, KonaneGameStateHeight: Int) + private let InternalBoardDataStorage = [] + /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ + private var isBlackTurn: Bool + print(is it blacks turn? /(getIsBlackTurn())) + /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY:Int))*/ + /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ + isValid(move: KonaneMove) + isValid(blackRemove: (x: Int, y: Int)) + isValid(whiteRemove: (x: Int, y: Int)) + perform(move: KonaneMove) + perform(blackRemove: (x: Int, y: Int)) + perform(whiteRemove: (x: Int, y: Int)) + didBlckWin() + didWhiteWin() + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ } From 37d56844c804ff00351d661dd9b5123c8c33f386 Mon Sep 17 00:00:00 2001 From: asthasahoo Date: Thu, 27 Oct 2016 02:45:29 +0000 Subject: [PATCH 09/25] Random --- Sources/main.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index eddd5e8..1c36503 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,2 +1,13 @@ -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win? \(game.play())") +class KonaneGame { + let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) + print("Did black win? \(game.play())") + var private gameState: String + let private blackInputSource: Int + let private whiteInputSource: Int + + + + +print("Did black win?\(game.play())") +git --add + From 723e7f279ad41641828e1238d38ffb41209383dd Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Thu, 27 Oct 2016 03:29:37 +0000 Subject: [PATCH 10/25] I tried to fix some errors, but not a lot got done --- Sources/main.swift | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 28ba58a..65de9d8 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,9 +1,10 @@ class KonaneGame { let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) - print("Did black win? \(game.play()")) - init() { - var BlackIsHuman = Bool - var WhiteIsHuman = Bool + var BlackIsHuman: Bool + var WhiteIsHuman: Bool + init(blackIsHuman: Bool, whiteIsHuman: Bool) { + BlackIsHuman = blackIsHuman + WhiteIsHuman = whiteIsHuman if BlackIsHuman == false { WhiteIsHuman == true } else { @@ -14,14 +15,15 @@ class KonaneGame { private let blackInputSource: KonaneMoveInputSource private let whiteInputSource: KonaneMoveInputSource } +print("is black human? /(game.play())") class Konane { let width: Int = 16 let height: Int = 16 init() {} - internalboarddatastorage: + let internalboarddatastorage: Int private let isBlackTurn = Bool var getIsBlackTurn: Bool - let color: (atX: Int, atY: Int) -> KonaneColor + let color: (_: Int, _: Int) //Are the following functions? The ones that I pointed out down in the list???? func isValid(move: KonaneMove) -> Bool func isValid(blackRemove: (x: Int, y: Int)) -> Bool { @@ -29,11 +31,9 @@ class Konane { print(x, y + "is not valid") } else { - print("The move is valid + print("The move is valid") } -} - - +} } enum KonaneColor { case black @@ -46,22 +46,22 @@ class KonaneMove { var fromY var toX var toY - class KonaneGameState { - let width: Int = 16 - let height: Int = 16 - init (KonaneGameStateWidth: Int, KonaneGameStateHeight: Int) - private let InternalBoardDataStorage = [] - /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ - private var isBlackTurn: Bool - print(is it blacks turn? /(getIsBlackTurn())) - /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY:Int))*/ - /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - isValid(move: KonaneMove) - isValid(blackRemove: (x: Int, y: Int)) - isValid(whiteRemove: (x: Int, y: Int)) - perform(move: KonaneMove) - perform(blackRemove: (x: Int, y: Int)) - perform(whiteRemove: (x: Int, y: Int)) - didBlckWin() - didWhiteWin() +class KonaneGameState { + let width: Int = 16 + let height: Int = 16 + init (KonaneGameStateWidth: Int, KonaneGameStateHeight: Int) + private let InternalBoardDataStorage = [] + /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ + private var isBlackTurn: Bool + print("is it blacks turn? /(getIsBlackTurn())") + /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY:Int))*/ + /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ + isValid(move: KonaneMove) + isValid(blackRemove: (x: Int, y: Int)) + isValid(whiteRemove: (x: Int, y: Int)) + perform(move: KonaneMove) + perform(blackRemove: (x: Int, y: Int)) + perform(whiteRemove: (x: Int, y: Int)) + didBlckWin() + didWhiteWin() /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ } From ed38d0e9bb48cbe06d3952a2385cd5c158492d78 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Thu, 27 Oct 2016 04:03:44 +0000 Subject: [PATCH 11/25] I think most if not all of the errors should be gone --- Sources/main.swift | 78 ++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index d90b5de..f8f6309 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,19 +1,14 @@ -class KonaneGame { -<<<<<<< HEAD - let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) - print("Did black win? \(game.play())") - var private gameState: String - let private blackInputSource: Int - let private whiteInputSource: Int +let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) +print("Did black win? \(game.play())") +class KonaneGame { + private var gameState: KonaneGameState + private let blackInputSource: KonaneMoveInputSource + private let whiteInputSource: KonaneMoveInputSource -print("Did black win?\(game.play())") -git --add -======= - let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) var BlackIsHuman: Bool var WhiteIsHuman: Bool init(blackIsHuman: Bool, whiteIsHuman: Bool) { @@ -25,29 +20,6 @@ git --add BlackIsHuman == true } } - var gameState: KonaneGameState - private let blackInputSource: KonaneMoveInputSource - private let whiteInputSource: KonaneMoveInputSource -} -print("is black human? /(game.play())") -class Konane { - let width: Int = 16 - let height: Int = 16 - init() {} - let internalboarddatastorage: Int - private let isBlackTurn = Bool - var getIsBlackTurn: Bool - let color: (_: Int, _: Int) - //Are the following functions? The ones that I pointed out down in the list???? - func isValid(move: KonaneMove) -> Bool - func isValid(blackRemove: (x: Int, y: Int)) -> Bool { - if isValid == false { - print(x, y + "is not valid") - } - else { - print("The move is valid") - } -} } enum KonaneColor { case black @@ -55,19 +27,36 @@ enum KonaneColor { case empty } class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int) - var fromX = Int - var fromY - var toX - var toY + init(fromX: Int, fromY: Int, toX: Int, toY: Int){ + self.fromX = fromX + self.fromY = fromY + self.toX = toX + self.toY = toY + } + var fromX: Int + var fromY: Int + var toX: Int + var toY: Int +} class KonaneGameState { - let width: Int = 16 - let height: Int = 16 - init (KonaneGameStateWidth: Int, KonaneGameStateHeight: Int) - private let InternalBoardDataStorage = [] + var width: Int = 16 + var height: Int = 16 + private let InternalBoardDataStorage: [[KonaneColor]] = [[KonaneColor]](repeating: [KonaneColor](repeating: KonaneColor.empty, count: height), count: width) /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ private var isBlackTurn: Bool - print("is it blacks turn? /(getIsBlackTurn())") + + init() { + for x in 0.. Bool) but I could be wrong*/ } ->>>>>>> b42b1238932f6506384c588866e0eaf845caa2e1 From 0241ea206ae88d967bd55268bed801c2110b4c48 Mon Sep 17 00:00:00 2001 From: asthasahoo Date: Fri, 28 Oct 2016 03:13:46 +0000 Subject: [PATCH 12/25] Hope this works --- Sources/main.swift | 172 ++++++++++++++++++++++----------------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index c80721d..2a66480 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,86 +1,86 @@ -<<<<<<< HEAD - -======= -class KonaneGame { - let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) - print("Did black win? \(game.play())") - init() { - var BlackIsHuman = Bool - var WhiteIsHuman = Bool - if BlackIsHuman == false { - WhiteIsHuman == true - } else { - BlackIsHuman == true - } - } - var private.gameState: KonaneGameState - let private.blackInputSource: KonaneMoveInputSource - let private.whiteInputSource: KonaneMoveInputSource -} -class Konane { - width: Int = 16 - height: Int = 16 - init() {} - private.internalboarddatastorage: - private.isBlackTurn: Bool - var getIsBlackTurn: Bool - let color: atX: Int, atY: Int) -> KonaneColor -//Are the following functions? The ones that I pointed out down in the list???? - func isValid(move: KonaneMove) -> Bool - func isValid(blackRemove: (x: Int, y: Int)) -> Bool { - if IsValid == false { - print(x, y + "is not valid") - } - else { - print("The move is valid") - } - } - - -} -enum KonaneColor { - case black - case white - case empty -} -class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int) - var fromX = Int - var fromY - var toX - var toY -class KonaneGameState - let width: Int = 16 - let height: Int = 16 - var init() - private InternalBoardDataStorage - /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ - private var isBlackTurn: Bool - print(getIsBlackTurn) - - /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY: Int)) */ - - /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ - - /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - - isValid(move: KonaneMove) - isValid(blackRemove: (x: Int, y: Int)) - isValid(whiteRemove: (x: Int, y: Int)) - perform(move: KonaneMove) - perform(blackRemove: (x: Int, y: Int)) - perform(whiteRemove: (x: Int, y: Int)) - didBlackWin() - didWhiteWin() - /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ - - - - - - - - - - ->>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 +<<<<<<< HEAD +//Do we need the HEAD thing? +======= +class KonaneGame { + let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) + print("Did black win? \(game.play())") + init() { + var BlackIsHuman = Bool + var WhiteIsHuman = Bool + if BlackIsHuman == false { + WhiteIsHuman == true + } else { + BlackIsHuman == true + } + } + var private.gameState: KonaneGameState + let private.blackInputSource: KonaneMoveInputSource + let private.whiteInputSource: KonaneMoveInputSource +} +class Konane { + width: Int = 16 + height: Int = 16 + init() {} + private.internalboarddatastorage: + private.isBlackTurn: Bool + var getIsBlackTurn: Bool + let color: atX: Int, atY: Int) -> KonaneColor +//Are the following functions? The ones that I pointed out down in the list???? + func isValid(move: KonaneMove) -> Bool + func isValid(blackRemove: (x: Int, y: Int)) -> Bool { + if IsValid == false { + print(x, y + "is not valid") + } + else { + print("The move is valid") + } + } + + +} +enum KonaneColor { + case black + case white + case empty +} +class KonaneMove { + init(fromX: Int, fromY: Int, toX: Int, toY: Int) + var fromX = Int + var fromY + var toX + var toY +class KonaneGameState + let width: Int = 16 + let height: Int = 16 + var init() + private InternalBoardDataStorage + /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ + private var isBlackTurn: Bool + print(getIsBlackTurn) + + /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY: Int)) */ + + /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ + + /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ + + isValid(move: KonaneMove) + isValid(blackRemove: (x: Int, y: Int)) + isValid(whiteRemove: (x: Int, y: Int)) + perform(move: KonaneMove) + perform(blackRemove: (x: Int, y: Int)) + perform(whiteRemove: (x: Int, y: Int)) + didBlackWin() + didWhiteWin() + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ + + + + + + + + + + +>>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 From 7871944e87d7c7c24b7306a3e0f724ac4249d2f6 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Fri, 28 Oct 2016 03:31:06 +0000 Subject: [PATCH 13/25] i just fixed one error because of a curly brace --- Sources/main.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index f8f6309..bd8973f 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -15,9 +15,9 @@ class KonaneGame { BlackIsHuman = blackIsHuman WhiteIsHuman = whiteIsHuman if BlackIsHuman == false { - WhiteIsHuman == true + WhiteIsHuman = true } else { - BlackIsHuman == true + BlackIsHuman = true } } } @@ -47,7 +47,7 @@ class KonaneGameState { init() { for x in 0.. Bool) but I could be wrong*/ } + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ From 1a27d8a3980d37f4b4a245fa9b4daa3accf09782 Mon Sep 17 00:00:00 2001 From: asthasahoo Date: Sat, 29 Oct 2016 16:58:26 +0000 Subject: [PATCH 14/25] I'm having trouble with some things,but I fixed and made a couple of errors :) --- Sources/main.swift | 213 +++++++++++++++------------------------------ 1 file changed, 68 insertions(+), 145 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 93fcc3b..7927f5a 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,156 +1,79 @@ - -class KonaneGame { - let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) - print("Did black win? \(game.play())") - init() { - var BlackIsHuman = Bool - var WhiteIsHuman = Bool - if BlackIsHuman == false { - WhiteIsHuman == true - } else { - BlackIsHuman == true - } - } - var private.gameState: KonaneGameState - let private.blackInputSource: KonaneMoveInputSource - let private.whiteInputSource: KonaneMoveInputSource -} -class Konane { - width: Int = 16 - height: Int = 16 - init() {} - private.internalboarddatastorage: - private.isBlackTurn: Bool - var getIsBlackTurn: Bool - let color: atX: Int, atY: Int) -> KonaneColor -//Are the following functions? The ones that I pointed out down in the list???? - func isValid(move: KonaneMove) -> Bool - func isValid(blackRemove: (x: Int, y: Int)) -> Bool { - if IsValid == false { - print(x, y + "is not valid") - } - else { - print("The move is valid") - } - } +class KonaneGame { + + private var gameState: KonaneGameState + private let blackInputSource: KonaneMoveInputSource + private let whiteInputSource: KonaneMoveInputSource + init(blackIsHuman: Bool, whiteIsHuman: Bool) { + if blackIsHuman == false { + blackInputSource = KonaneMoveInputSourceAI(isBlack: true) + } else { + blackInputSource = KonaneMoveInputSourceHuman(isBlack: true) + } + if whiteIsHuman == false { + whiteInputSource = KonaneMoveInputSourceAI(isWhite: true) + } else { + whiteInputSource = KonaneMoveInputSourceHuman(isWhite: true) + } } +let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) +print("Did black win?\(game.play())") + enum KonaneColor { - case black - case white - case empty + case black + case white + case empty } class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int) - var fromX = Int - var fromY - var toX - var toY -class KonaneGameState + init(fromX: Int, fromY: Int, toX: Int, toY: Int){ + self.fromX = fromX + self.fromY = fromY + self.toX = toX + self.toY = toY + } + var fromX: Int + var fromY: Int + var toX: Int + var toY: Int +} +class KonaneMoveInputSource { + init(isBlack: Bool) + var isBlack + removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int) + init(removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int)) + nextMove(gameState: KonaneGameState) -> KonaneMove +} +class KonaneGameState { let width: Int = 16 let height: Int = 16 - var init() - private InternalBoardDataStorage + private let InternalBoardDataStorage: [[KonaneColor]] = [[KonaneColor]](repeating: [KonaneColor](repeating: KonaneColor.empty, count: height), count: width) /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ private var isBlackTurn: Bool - print(getIsBlackTurn) - - /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY: Int)) */ - /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ - - /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - - isValid(move: KonaneMove) - isValid(blackRemove: (x: Int, y: Int)) - isValid(whiteRemove: (x: Int, y: Int)) - perform(move: KonaneMove) - perform(blackRemove: (x: Int, y: Int)) - perform(whiteRemove: (x: Int, y: Int)) - didBlackWin() - didWhiteWin() - /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ - - - - - - - - - - ->>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 -======= -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win? \(game.play())") - -class KonaneGame { - - private var gameState: KonaneGameState - private let blackInputSource: KonaneMoveInputSource - private let whiteInputSource: KonaneMoveInputSource - - - - var BlackIsHuman: Bool - var WhiteIsHuman: Bool - init(blackIsHuman: Bool, whiteIsHuman: Bool) { - BlackIsHuman = blackIsHuman - WhiteIsHuman = whiteIsHuman - if BlackIsHuman == false { - WhiteIsHuman == true - } else { - BlackIsHuman == true - } - } -} -enum KonaneColor { - case black - case white - case empty -} -class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int){ - self.fromX = fromX - self.fromY = fromY - self.toX = toX - self.toY = toY - } - var fromX: Int - var fromY: Int - var toX: Int - var toY: Int -} -class KonaneGameState { - var width: Int = 16 - var height: Int = 16 - private let InternalBoardDataStorage: [[KonaneColor]] = [[KonaneColor]](repeating: [KonaneColor](repeating: KonaneColor.empty, count: height), count: width) - /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ - private var isBlackTurn: Bool - - init() { - for x in 0.. Bool) but I could be wrong*/ } ->>>>>>> ed38d0e9bb48cbe06d3952a2385cd5c158492d78 + init() { + for x in 0.. Bool) but I could be wrong*/ } From d12587624ddbceed2f4ba2acd360871ee6b3a899 Mon Sep 17 00:00:00 2001 From: asthasahoo Date: Sat, 29 Oct 2016 21:45:23 +0000 Subject: [PATCH 15/25] U guys, I can't fix lines 41-44, help! --- Sources/main.swift | 172 +++++++++++---------------------------------- 1 file changed, 42 insertions(+), 130 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 2621568..9cc6c4c 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,132 +1,23 @@ - - -class KonaneGame { - - private var gameState: KonaneGameState - private let blackInputSource: KonaneMoveInputSource - private let whiteInputSource: KonaneMoveInputSource - init(blackIsHuman: Bool, whiteIsHuman: Bool) { - if blackIsHuman == false { - blackInputSource = KonaneMoveInputSourceAI(isBlack: true) - } else { - blackInputSource = KonaneMoveInputSourceHuman(isBlack: true) - } - if whiteIsHuman == false { - whiteInputSource = KonaneMoveInputSourceAI(isWhite: true) - } else { - whiteInputSource = KonaneMoveInputSourceHuman(isWhite: true) - } -} -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win?\(game.play())") - -enum KonaneColor { - case black - case white - case empty -} -class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int){ - self.fromX = fromX - self.fromY = fromY - self.toX = toX - self.toY = toY - } - var fromX: Int - var fromY: Int - var toX: Int - var toY: Int -} -class KonaneMoveInputSource { - init(isBlack: Bool) - var isBlack - removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int) - init(removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int)) - nextMove(gameState: KonaneGameState) -> KonaneMove -} -class KonaneGameState { - let width: Int = 16 - let height: Int = 16 - private let InternalBoardDataStorage: [[KonaneColor]] = [[KonaneColor]](repeating: [KonaneColor](repeating: KonaneColor.empty, count: height), count: width) - /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ - private var isBlackTurn: Bool - -<<<<<<< HEAD - init() { - for x in 0.. Bool) but I could be wrong*/ } -======= - /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ - - /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - - isValid(move: KonaneMove) - isValid(blackRemove: (x: Int, y: Int)) - isValid(whiteRemove: (x: Int, y: Int)) - perform(move: KonaneMove) - perform(blackRemove: (x: Int, y: Int)) - perform(whiteRemove: (x: Int, y: Int)) - didBlackWin() - didWhiteWin() - /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ - - - - - - - - - - ->>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 -======= -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win? \(game.play())") class KonaneGame { private var gameState: KonaneGameState private let blackInputSource: KonaneMoveInputSource private let whiteInputSource: KonaneMoveInputSource - - - - var BlackIsHuman: Bool - var WhiteIsHuman: Bool - init(blackIsHuman: Bool, whiteIsHuman: Bool) { - BlackIsHuman = blackIsHuman - WhiteIsHuman = whiteIsHuman - if BlackIsHuman == false { - WhiteIsHuman = true + init(blackIsHuman: Bool, whiteIsHuman: Bool) { + if blackIsHuman == false { + blackInputSource = KonaneMoveInputSourceAI(isBlack: true) } else { - BlackIsHuman = true + blackInputSource = KonaneMoveInputSourceHuman(isBlack: true) } - } + if whiteIsHuman == false { + whiteInputSource = KonaneMoveInputSourceAI(isWhite: true) + } else { + whiteInputSource = KonaneMoveInputSourceHuman(isWhite: true) + } +let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) +print("Did black win?\(game.play())") enum KonaneColor { case black case white @@ -144,16 +35,24 @@ class KonaneMove { var toX: Int var toY: Int } +class KonaneMoveInputSource { + init(isBlack: Bool) + var isBlack + init(removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int)) + init(removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int)) + let removeFirstPiece + let removeSecondPiece + nextMove(gameState: KonaneGameState) -> KonaneMove +} class KonaneGameState { - var width: Int = 16 - var height: Int = 16 + let width: Int = 16 + let height: Int = 16 private let InternalBoardDataStorage: [[KonaneColor]] = [[KonaneColor]](repeating: [KonaneColor](repeating: KonaneColor.empty, count: height), count: width) /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ private var isBlackTurn: Bool - init() { for x in 0.. Bool) but I could be wrong*/ -======= + */ +} /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ } ->>>>>>> ed38d0e9bb48cbe06d3952a2385cd5c158492d78 ->>>>>>> a9c8022ef363a3064d37be64745c0098b06b3c35 ->>>>>>> 047d0efeeb85789fc8245198a8cc850cc473a93b +======= + /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ + + /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ + + isValid(move: KonaneMove) + isValid(blackRemove: (x: Int, y: Int)) + isValid(whiteRemove: (x: Int, y: Int)) + perform(move: KonaneMove) + perform(blackRemove: (x: Int, y: Int)) + perform(whiteRemove: (x: Int, y: Int)) + didBlackWin() + didWhiteWin() + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ + + From 7c4a6705775396e5faf44458339af773ae55e7f8 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Mon, 31 Oct 2016 03:51:13 +0000 Subject: [PATCH 16/25] I didn't change anything but I needed to update what code I see, so I think this will update it. --- Sources/main.swift | 166 ++++++++++++++++++++++----------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 3b2da58..c5ddb40 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,87 +1,87 @@ -class KonaneGame { - let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) - print("Did black win? \(game.play())") - init() { - var BlackIsHuman = Bool - var WhiteIsHuman = Bool - if BlackIsHuman == false { - WhiteIsHuman == true - } else { - BlackIsHuman == true - } - } - var private.gameState: KonaneGameState - let private.blackInputSource: KonaneMoveInputSource - let private.whiteInputSource: KonaneMoveInputSource -} -class Konane { - width: Int = 16 - height: Int = 16 - init() {} - private.internalboarddatastorage: - private.isBlackTurn: Bool - var getIsBlackTurn: Bool - let color: atX: Int, atY: Int) -> KonaneColor -//Are the following functions? The ones that I pointed out down in the list???? - func isValid(move: KonaneMove) -> Bool - func isValid(blackRemove: (x: Int, y: Int)) -> Bool { - if IsValid == false { - print(x, y + "is not valid") - } - else { - print("The move is valid") - } - } - - -} -enum KonaneColor { - case black - case white - case empty -} -class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int) - var fromX = Int - var fromY - var toX - var toY -class KonaneGameState - let width: Int = 16 - let height: Int = 16 - var init() - private InternalBoardDataStorage - /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ - private var isBlackTurn: Bool - print(getIsBlackTurn) - - /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY: Int)) */ - - /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ - - /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - - isValid(move: KonaneMove) - isValid(blackRemove: (x: Int, y: Int)) - isValid(whiteRemove: (x: Int, y: Int)) - perform(move: KonaneMove) - perform(blackRemove: (x: Int, y: Int)) - perform(whiteRemove: (x: Int, y: Int)) - didBlackWin() - didWhiteWin() - /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ - - - - - - - - - - ->>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 +class KonaneGame { + let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) + print("Did black win? \(game.play())") + init() { + var BlackIsHuman = Bool + var WhiteIsHuman = Bool + if BlackIsHuman == false { + WhiteIsHuman == true + } else { + BlackIsHuman == true + } + } + var private.gameState: KonaneGameState + let private.blackInputSource: KonaneMoveInputSource + let private.whiteInputSource: KonaneMoveInputSource +} +class Konane { + width: Int = 16 + height: Int = 16 + init() {} + private.internalboarddatastorage: + private.isBlackTurn: Bool + var getIsBlackTurn: Bool + let color: atX: Int, atY: Int) -> KonaneColor +//Are the following functions? The ones that I pointed out down in the list???? + func isValid(move: KonaneMove) -> Bool + func isValid(blackRemove: (x: Int, y: Int)) -> Bool { + if IsValid == false { + print(x, y + "is not valid") + } + else { + print("The move is valid") + } + } + + +} +enum KonaneColor { + case black + case white + case empty +} +class KonaneMove { + init(fromX: Int, fromY: Int, toX: Int, toY: Int) + var fromX = Int + var fromY + var toX + var toY +class KonaneGameState + let width: Int = 16 + let height: Int = 16 + var init() + private InternalBoardDataStorage + /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ + private var isBlackTurn: Bool + print(getIsBlackTurn) + + /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY: Int)) */ + + /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ + + /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ + + isValid(move: KonaneMove) + isValid(blackRemove: (x: Int, y: Int)) + isValid(whiteRemove: (x: Int, y: Int)) + perform(move: KonaneMove) + perform(blackRemove: (x: Int, y: Int)) + perform(whiteRemove: (x: Int, y: Int)) + didBlackWin() + didWhiteWin() + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ + + + + + + + + + + +>>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 ======= let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) print("Did black win? \(game.play())") From 7c7dc214a0dc1acdf9b939f9c0c23217e14c9b13 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Mon, 31 Oct 2016 04:24:22 +0000 Subject: [PATCH 17/25] I don't know if I fixed anything, or if I just ended up adding more errors --- Sources/main.swift | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index e230895..264b570 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,5 +1,4 @@ -<<<<<<< HEAD class KonaneGame { let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) print("Did black win? \(game.play())") @@ -10,6 +9,7 @@ class KonaneGame { WhiteIsHuman == true } else { BlackIsHuman == true + WhiteIsHuman == false } } var private.gameState: KonaneGameState @@ -17,13 +17,13 @@ class KonaneGame { let private.whiteInputSource: KonaneMoveInputSource } class Konane { - width: Int = 16 - height: Int = 16 + let width: Int = 16 + let height: Int = 16 init() {} private.internalboarddatastorage: private.isBlackTurn: Bool - var getIsBlackTurn: Bool - let color: atX: Int, atY: Int) -> KonaneColor + let getIsBlackTurn: Bool + func color(atX: Int, atY: Int) -> KonaneColor //Are the following functions? The ones that I pointed out down in the list???? func isValid(move: KonaneMove) -> Bool func isValid(blackRemove: (x: Int, y: Int)) -> Bool { @@ -82,13 +82,9 @@ class KonaneGameState ->>>>>>> 0cd73873c1727dea7f9981186c76b6059b4e7d49 -======= let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) print("Did black win? \(game.play())") -======= ->>>>>>> d12587624ddbceed2f4ba2acd360871ee6b3a899 class KonaneGame { private var gameState: KonaneGameState @@ -128,8 +124,8 @@ class KonaneMove { class KonaneMoveInputSource { init(isBlack: Bool) var isBlack - init(removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int)) - init(removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int)) + init(_:removeFirstPiece(gameState: KonaneGameState)) -> (x: Int, y: Int) + init(_:removeSecondPiece(gameState: KonaneGameState)) -> (x: Int, y: Int) let removeFirstPiece let removeSecondPiece nextMove(gameState: KonaneGameState) -> KonaneMove @@ -166,7 +162,6 @@ class KonaneGameState { */ } /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ } -======= /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ From 74782798cd4a2ccf864cd2043c9aec805348c3b1 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Wed, 2 Nov 2016 05:13:48 +0000 Subject: [PATCH 18/25] I fixed a couple syntax errors but nothing too substantial --- Sources/main.swift | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 264b570..6c73ab2 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -12,16 +12,16 @@ class KonaneGame { WhiteIsHuman == false } } - var private.gameState: KonaneGameState - let private.blackInputSource: KonaneMoveInputSource - let private.whiteInputSource: KonaneMoveInputSource + private var gameState: KonaneGameState + private let blackInputSource: KonaneMoveInputSource + private let whiteInputSource: KonaneMoveInputSource } class Konane { let width: Int = 16 let height: Int = 16 init() {} - private.internalboarddatastorage: - private.isBlackTurn: Bool + internalboarddatastorage () + private isBlackTurn: Bool let getIsBlackTurn: Bool func color(atX: Int, atY: Int) -> KonaneColor //Are the following functions? The ones that I pointed out down in the list???? @@ -48,11 +48,11 @@ class KonaneMove { var fromY var toX var toY -class KonaneGameState +class KonaneGameState { let width: Int = 16 let height: Int = 16 var init() - private InternalBoardDataStorage + private InternalBoardDataStorage /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ private var isBlackTurn: Bool print(getIsBlackTurn) @@ -72,15 +72,7 @@ class KonaneGameState didBlackWin() didWhiteWin() /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ - - - - - - - - - +} let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) print("Did black win? \(game.play())") @@ -174,6 +166,4 @@ class KonaneGameState { perform(whiteRemove: (x: Int, y: Int)) didBlackWin() didWhiteWin() - /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ - - + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ From 86c9fd7213f997dca5d5e76872c382af30b4c81f Mon Sep 17 00:00:00 2001 From: asthasahoo Date: Thu, 3 Nov 2016 01:53:15 +0000 Subject: [PATCH 19/25] Need to tdo this --- Sources/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/main.swift b/Sources/main.swift index 9cc6c4c..2750051 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -17,7 +17,7 @@ class KonaneGame { } let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win?\(game.play())") +print("Did black win? (game.play()) enum KonaneColor { case black case white From a6492cca495256cb096952bbcaa17b45fa4cd2c3 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Thu, 3 Nov 2016 02:56:25 +0000 Subject: [PATCH 20/25] Help on Wednesday meeting, fixed(?) a lot of stuff --- Sources/main.swift | 165 +++++++++++++++------------------------------ 1 file changed, 55 insertions(+), 110 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 6c73ab2..9d3029c 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,126 +1,80 @@ +import Foundation + +let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) +print("Did black win? \(game.play())") class KonaneGame { - let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) - print("Did black win? \(game.play())") - init() { - var BlackIsHuman = Bool - var WhiteIsHuman = Bool - if BlackIsHuman == false { - WhiteIsHuman == true - } else { - BlackIsHuman == true - WhiteIsHuman == false - } + init(blackIsHuman: Bool, whiteIsHuman: Bool) { + if blackIsHuman == false { + // Set input to AI source + fatalError("No AI yet") + } else { + blackInputSource = KonaneMoveInputSourceHuman(isBlack: true) + } + + if whiteIsHuman == false { + fatalError("No AI yet") + } else { + whiteInputSource = KonaneMoveInputSourceHuman(isBlack: false) + } + + } - private var gameState: KonaneGameState + private var gameState: KonaneGameState = KonaneGameState() private let blackInputSource: KonaneMoveInputSource private let whiteInputSource: KonaneMoveInputSource -} -class Konane { - let width: Int = 16 - let height: Int = 16 - init() {} - internalboarddatastorage () - private isBlackTurn: Bool - let getIsBlackTurn: Bool - func color(atX: Int, atY: Int) -> KonaneColor -//Are the following functions? The ones that I pointed out down in the list???? - func isValid(move: KonaneMove) -> Bool - func isValid(blackRemove: (x: Int, y: Int)) -> Bool { - if IsValid == false { - print(x, y + "is not valid") - } - else { - print("The move is valid") - } - } + func play() -> Bool { + + } + + private func displayBoard() { + + } } + + enum KonaneColor { case black case white case empty } -class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int) - var fromX = Int - var fromY - var toX - var toY -class KonaneGameState { - let width: Int = 16 - let height: Int = 16 - var init() - private InternalBoardDataStorage - /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ - private var isBlackTurn: Bool - print(getIsBlackTurn) - - /*getIsBlackTurn is a function that I'm calling print(color(atX: Int, atY: Int)) */ - - /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ - - /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - - isValid(move: KonaneMove) - isValid(blackRemove: (x: Int, y: Int)) - isValid(whiteRemove: (x: Int, y: Int)) - perform(move: KonaneMove) - perform(blackRemove: (x: Int, y: Int)) - perform(whiteRemove: (x: Int, y: Int)) - didBlackWin() - didWhiteWin() - /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ -} - -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win? \(game.play())") - -class KonaneGame { - private var gameState: KonaneGameState - private let blackInputSource: KonaneMoveInputSource - private let whiteInputSource: KonaneMoveInputSource - init(blackIsHuman: Bool, whiteIsHuman: Bool) { - if blackIsHuman == false { - blackInputSource = KonaneMoveInputSourceAI(isBlack: true) - } else { - blackInputSource = KonaneMoveInputSourceHuman(isBlack: true) - } - if whiteIsHuman == false { - whiteInputSource = KonaneMoveInputSourceAI(isWhite: true) - } else { - whiteInputSource = KonaneMoveInputSourceHuman(isWhite: true) - -} -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win?\(game.play())") -enum KonaneColor { - case black - case white - case empty -} class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int){ + init(fromX: Int, fromY: Int, toX: Int, toY: Int) { self.fromX = fromX self.fromY = fromY self.toX = toX self.toY = toY } - var fromX: Int - var fromY: Int - var toX: Int - var toY: Int + + var fromX: Int + var fromY: Int + var toX: Int + var toY: Int } + + class KonaneMoveInputSource { - init(isBlack: Bool) - var isBlack - init(_:removeFirstPiece(gameState: KonaneGameState)) -> (x: Int, y: Int) - init(_:removeSecondPiece(gameState: KonaneGameState)) -> (x: Int, y: Int) - let removeFirstPiece - let removeSecondPiece - nextMove(gameState: KonaneGameState) -> KonaneMove + init(isBlack: Bool) { + self.isBlack = isBlack + } + var isBlack: Bool + + + + func removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { + fatalError("Override this function") + } + + func removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { + fatalError("Override this function") + } + + func nextMove(gameState: KonaneGameState) -> KonaneMove { + fatalError("Override this function") + } } class KonaneGameState { let width: Int = 16 @@ -158,12 +112,3 @@ class KonaneGameState { /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - isValid(move: KonaneMove) - isValid(blackRemove: (x: Int, y: Int)) - isValid(whiteRemove: (x: Int, y: Int)) - perform(move: KonaneMove) - perform(blackRemove: (x: Int, y: Int)) - perform(whiteRemove: (x: Int, y: Int)) - didBlackWin() - didWhiteWin() - /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ From 089c80ac020ed240d3d78c580316e1eef5f37cbb Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Fri, 4 Nov 2016 03:20:19 +0000 Subject: [PATCH 21/25] I kinda fucked around... not a lot done --- Sources/main.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sources/main.swift b/Sources/main.swift index 9d3029c..01dd33c 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,7 +1,5 @@ import Foundation -let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) -print("Did black win? \(game.play())") class KonaneGame { init(blackIsHuman: Bool, whiteIsHuman: Bool) { @@ -33,7 +31,8 @@ class KonaneGame { } } - +let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) +print("Did black win? \(game.play())") enum KonaneColor { case black @@ -57,10 +56,10 @@ class KonaneMove { class KonaneMoveInputSource { + var isBlack: Bool init(isBlack: Bool) { self.isBlack = isBlack } - var isBlack: Bool @@ -79,10 +78,9 @@ class KonaneMoveInputSource { class KonaneGameState { let width: Int = 16 let height: Int = 16 - private let InternalBoardDataStorage: [[KonaneColor]] = [[KonaneColor]](repeating: [KonaneColor](repeating: KonaneColor.empty, count: height), count: width) /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ private var isBlackTurn: Bool - init() { + init(_ height: Int,_ width: Int, InternalBoardDataStorage: [[KonaneColor]]) { for x in 0.. Bool) but I could be wrong*/ } + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ From d9cdd485759822e5c4ced837da57169394d2e465 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Wed, 9 Nov 2016 01:20:43 +0000 Subject: [PATCH 22/25] Put the classes into their own folders and there is a error because donald moved it into the documents folder, but I was talk to him about it on Wednesday --- Sources/KonaneColor.swift | 5 +++++ Sources/KonaneMove.swift | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 Sources/KonaneColor.swift create mode 100644 Sources/KonaneMove.swift diff --git a/Sources/KonaneColor.swift b/Sources/KonaneColor.swift new file mode 100644 index 0000000..c35d493 --- /dev/null +++ b/Sources/KonaneColor.swift @@ -0,0 +1,5 @@ +enum KonaneColor { + case black + case white + case empty +} diff --git a/Sources/KonaneMove.swift b/Sources/KonaneMove.swift new file mode 100644 index 0000000..15862fc --- /dev/null +++ b/Sources/KonaneMove.swift @@ -0,0 +1,13 @@ +class KonaneMove { + init(fromX: Int, fromY: Int, toX: Int, toY: Int) { + self.fromX = fromX + self.fromY = fromY + self.toX = toX + self.toY = toY + } + + var fromX: Int + var fromY: Int + var toX: Int + var toY: Int +} From c1749f2baf2cb117cbab2f0a74ea653b691926f6 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Thu, 10 Nov 2016 03:01:04 +0000 Subject: [PATCH 23/25] updated stuff, @ a meeting so astha can help --- README.md | 2 +- Sources/KonaneGame.swift | 38 +++++++--- Sources/KonaneGameState.swift | 54 ++++++++++++++ Sources/KonaneMoveInputSource.swift | 27 +++++++ Sources/main.swift | 109 +--------------------------- 5 files changed, 112 insertions(+), 118 deletions(-) diff --git a/README.md b/README.md index e2f276b..9165558 100644 --- a/README.md +++ b/README.md @@ -43,4 +43,4 @@ This will take a while (~ 20 minutes) to setup. Then, you can run the command: 8. At the due date, your fork will be cloned, and will be tested and looked through manually to ensure it is legit, and to give some human feedback on code structure. -Alex wuz here \ No newline at end of file +Alex wuz here diff --git a/Sources/KonaneGame.swift b/Sources/KonaneGame.swift index 6221912..33fde64 100644 --- a/Sources/KonaneGame.swift +++ b/Sources/KonaneGame.swift @@ -1,10 +1,30 @@ -//class KonaneGame { - init(blackIsHuman: Bool, whiteIsHuman: Bool) - private gameState: KonaneGameState - private blackInputSource: KonaneMoveInputSource - private whiteInputSource: KonaneMoveInputSource - play() -> Bool // returns true if black wins - private displayBoard() +class KonaneGame { + init(blackIsHuman: Bool, whiteIsHuman: Bool) { + if blackIsHuman == false { + // Set input to AI source + fatalError("No AI yet") + } else { + blackInputSource = KonaneMoveInputSourceHuman(isBlack: true) + } + + if whiteIsHuman == false { + fatalError("No AI yet") + } else { + whiteInputSource = KonaneMoveInputSourceHuman(isBlack: false) + } + + + } + private var gameState = KonaneGameState() + private let blackInputSource: KonaneMoveInputSource + private let whiteInputSource: KonaneMoveInputSource + + func play() -> Bool { + // a bool saying `if its time to play or not + } + + private func displayBoard() { + // an array of columns inside an array of rows, I think. Or vice-versa + } + } - - diff --git a/Sources/KonaneGameState.swift b/Sources/KonaneGameState.swift index e69de29..c98585b 100644 --- a/Sources/KonaneGameState.swift +++ b/Sources/KonaneGameState.swift @@ -0,0 +1,54 @@ +class KonaneGameState { + let width: Int = 16 + let height: Int = 16 + // the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together + private var isBlackTurn: Bool + init(_ height: Int,_ width: Int) { + self.width = width + self.height = height + InternalBoardDataStorage = [[KonaneColor]](repeating: [KonaneColor](repeating: KonaneColor.empty, count: height), count: width) + for x in 0.. Bool{ + //check all rules to see if the move is valid. Also maybe change Bool to another type + return true + } + func isValid(blackRemove: (x: Int, y: Int)) -> Bool{ + // I think check rules to see if you can remove the piece and check if Bool is the right type to return + return true + } + func isValid(whiteRemove: (x: Int, y: Int)) -> Bool { + return true + } + func perform(move: KonaneMove) -> Int { + //CHANGE YOUR FUKING RETURN TYPE!!!!!! + let placeHolder = 5 + // GET RID OF THIS VARIABLE!!!!! ITS WORTHLESS! + return placeHolder + } + func perform(blackRemove: (x: Int, y: Int)) -> { + } + func perform(whiteRemove: (x: Int, y: Int)) { + } + func didBlckWin() -> Bool { + } + func didWhiteWin() -> Bool { + } + +} diff --git a/Sources/KonaneMoveInputSource.swift b/Sources/KonaneMoveInputSource.swift index e69de29..882b742 100644 --- a/Sources/KonaneMoveInputSource.swift +++ b/Sources/KonaneMoveInputSource.swift @@ -0,0 +1,27 @@ +class KonaneMoveInputSource { + var isBlack: Bool + init(isBlack: Bool) { + self.isBlack = isBlack + } + + + + func removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { + fatalError("Override this function") + } + + func removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { + fatalError("Override this function") + } + + func nextMove(gameState: KonaneGameState) -> KonaneMove { + fatalError("Override this function") + } +} + +/*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ +/* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ + +/* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ + + diff --git a/Sources/main.swift b/Sources/main.swift index 01dd33c..61b2d1b 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,115 +1,8 @@ import Foundation - -class KonaneGame { - init(blackIsHuman: Bool, whiteIsHuman: Bool) { - if blackIsHuman == false { - // Set input to AI source - fatalError("No AI yet") - } else { - blackInputSource = KonaneMoveInputSourceHuman(isBlack: true) - } - - if whiteIsHuman == false { - fatalError("No AI yet") - } else { - whiteInputSource = KonaneMoveInputSourceHuman(isBlack: false) - } - - - } - private var gameState: KonaneGameState = KonaneGameState() - private let blackInputSource: KonaneMoveInputSource - private let whiteInputSource: KonaneMoveInputSource - - func play() -> Bool { - - } - - private func displayBoard() { - - } - -} let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) print("Did black win? \(game.play())") +isValid(move: KonaneMove) -enum KonaneColor { - case black - case white - case empty -} - -class KonaneMove { - init(fromX: Int, fromY: Int, toX: Int, toY: Int) { - self.fromX = fromX - self.fromY = fromY - self.toX = toX - self.toY = toY - } - - var fromX: Int - var fromY: Int - var toX: Int - var toY: Int -} - - -class KonaneMoveInputSource { - var isBlack: Bool - init(isBlack: Bool) { - self.isBlack = isBlack - } - - - - func removeFirstPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { - fatalError("Override this function") - } - func removeSecondPiece(gameState: KonaneGameState) -> (x: Int, y: Int) { - fatalError("Override this function") - } - func nextMove(gameState: KonaneGameState) -> KonaneMove { - fatalError("Override this function") - } -} -class KonaneGameState { - let width: Int = 16 - let height: Int = 16 - /* the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together */ - private var isBlackTurn: Bool - init(_ height: Int,_ width: Int, InternalBoardDataStorage: [[KonaneColor]]) { - for x in 0.. Bool) but I could be wrong*/ - /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */ - - /* Bottom left, 0-indexed are the following properties functions, cuz I'm not really sure... */ - From 9c4726a69587f5bf1be2422233f94ea7a04019c4 Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Thu, 10 Nov 2016 04:48:35 +0000 Subject: [PATCH 24/25] I tried to fix some errors, but could you ask Donald, like on piazza, how to fix some of them? --- Sources/KonaneGame.swift | 4 ++-- Sources/KonaneGameState.swift | 29 +++++++++++++++++++---------- Sources/main.swift | 2 +- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Sources/KonaneGame.swift b/Sources/KonaneGame.swift index 33fde64..0077cdb 100644 --- a/Sources/KonaneGame.swift +++ b/Sources/KonaneGame.swift @@ -15,10 +15,10 @@ class KonaneGame { } - private var gameState = KonaneGameState() + private var gameState = KonaneGameState(height: 16, width: 16, isBlackTurn: true) private let blackInputSource: KonaneMoveInputSource private let whiteInputSource: KonaneMoveInputSource - + func play() -> Bool { // a bool saying `if its time to play or not } diff --git a/Sources/KonaneGameState.swift b/Sources/KonaneGameState.swift index c98585b..dd72076 100644 --- a/Sources/KonaneGameState.swift +++ b/Sources/KonaneGameState.swift @@ -1,9 +1,10 @@ class KonaneGameState { - let width: Int = 16 - let height: Int = 16 + var width: Int = 16 + var height: Int = 16 // the InternalBoardDataStorage wasn't working because I think internal by itself is a command so I changed it to be a name all together private var isBlackTurn: Bool - init(_ height: Int,_ width: Int) { + init(_ height: Int,_ width: Int,_ isBlackTurn: Bool ) { + self.isBlackTurn = isBlackTurn self.width = width self.height = height InternalBoardDataStorage = [[KonaneColor]](repeating: [KonaneColor](repeating: KonaneColor.empty, count: height), count: width) @@ -36,19 +37,27 @@ class KonaneGameState { func isValid(whiteRemove: (x: Int, y: Int)) -> Bool { return true } - func perform(move: KonaneMove) -> Int { - //CHANGE YOUR FUKING RETURN TYPE!!!!!! - let placeHolder = 5 - // GET RID OF THIS VARIABLE!!!!! ITS WORTHLESS! - return placeHolder + func perform(move: KonaneMove){ + } - func perform(blackRemove: (x: Int, y: Int)) -> { + func perform(blackRemove: (x: Int, y: Int)) -> Int { + //YOU MIGHT HAVE TO RETURN A TUPLE ( is that what its called? when you return multiple return values) + let holdMyPlace = 6 + return holdMyPlace + //BOI THIS VALUE HAS NO VALUE SO GET RID OF IT!!! } - func perform(whiteRemove: (x: Int, y: Int)) { + func perform(whiteRemove: (x: Int, y: Int)) -> Int { + // SAME DEAL AS PREFORM(BLACKREMOVE) YOU GOTTA REPLACE EVERYTHING!!!!!! + let placeMyHold = 7 + return placeMyHold } func didBlckWin() -> Bool { + // IS THIS RETURNED AS TRUE? I DONT KNOW YET SO FIX IT!!!! + return true } func didWhiteWin() -> Bool { + // I DONT KNOW DID WHITE WIN? YOU DECIDE, BUT FIRST FIX THE CODE!!!! + return true } } diff --git a/Sources/main.swift b/Sources/main.swift index 61b2d1b..a3780d5 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -2,7 +2,7 @@ import Foundation let game = KonaneGame(blackIsHuman: true, whiteIsHuman: true) print("Did black win? \(game.play())") -isValid(move: KonaneMove) +game.isValid(move: KonaneMove) From 31a53350aea7e9749bd8ea503c1cc7ffd2170bee Mon Sep 17 00:00:00 2001 From: Gemma-B Date: Tue, 15 Nov 2016 03:02:05 +0000 Subject: [PATCH 25/25] I fixed like 2 errors, and I'm gonna have dinner and try to see if there are any more i could fix --- Sources/KonaneMoveInputSource.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/KonaneMoveInputSource.swift b/Sources/KonaneMoveInputSource.swift index 882b742..fa0304b 100644 --- a/Sources/KonaneMoveInputSource.swift +++ b/Sources/KonaneMoveInputSource.swift @@ -18,6 +18,10 @@ class KonaneMoveInputSource { fatalError("Override this function") } } +func KonaneMoveInputSourceHuman(isBlack: Bool) -> Bool { + return true +} + /*I don't think you need to add what the function returns as ( ex. -> Bool) but I could be wrong*/ /* I think this is how to call a function with either print(function) or just saying the function with parameters but I'm not entirely sure */