fixed things

master
Kanken 2 years ago
parent 5678efbe22
commit 3ad121a76a

@ -280,8 +280,8 @@
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "94"
endingLineNumber = "94"
startingLineNumber = "97"
endingLineNumber = "97"
landmarkName = "isFull()"
landmarkType = "7">
</BreakpointContent>
@ -296,8 +296,8 @@
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "47"
endingLineNumber = "47"
startingLineNumber = "52"
endingLineNumber = "52"
landmarkName = "init(_:printer:reader:)"
landmarkType = "7">
</BreakpointContent>
@ -312,8 +312,8 @@
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "46"
endingLineNumber = "46"
startingLineNumber = "51"
endingLineNumber = "51"
landmarkName = "init(_:printer:reader:)"
landmarkType = "7">
</BreakpointContent>
@ -328,8 +328,8 @@
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "32"
endingLineNumber = "32"
startingLineNumber = "37"
endingLineNumber = "37"
landmarkName = "init(printer:reader:)"
landmarkType = "7">
</BreakpointContent>
@ -344,8 +344,8 @@
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "30"
endingLineNumber = "30"
startingLineNumber = "35"
endingLineNumber = "35"
landmarkName = "init(printer:reader:)"
landmarkType = "7">
</BreakpointContent>
@ -360,8 +360,8 @@
filePath = "forcesPack/Tests/forcesPackTests/boardRulesTests.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "37"
endingLineNumber = "37"
startingLineNumber = "42"
endingLineNumber = "42"
landmarkName = "testRules()"
landmarkType = "7">
</BreakpointContent>
@ -376,8 +376,8 @@
filePath = "forcesPack/Tests/forcesPackTests/boardRulesTests.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "43"
endingLineNumber = "43"
startingLineNumber = "48"
endingLineNumber = "48"
landmarkName = "testRules()"
landmarkType = "7">
</BreakpointContent>
@ -392,8 +392,8 @@
filePath = "forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "17"
endingLineNumber = "17"
startingLineNumber = "18"
endingLineNumber = "18"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
<Locations>
@ -485,8 +485,8 @@
filePath = "forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "20"
endingLineNumber = "20"
startingLineNumber = "21"
endingLineNumber = "21"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
</BreakpointContent>
@ -501,8 +501,8 @@
filePath = "forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "19"
endingLineNumber = "19"
startingLineNumber = "20"
endingLineNumber = "20"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
<Locations>
@ -579,8 +579,8 @@
filePath = "forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
startingLineNumber = "17"
endingLineNumber = "17"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
</BreakpointContent>
@ -595,8 +595,8 @@
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "65"
endingLineNumber = "65"
startingLineNumber = "70"
endingLineNumber = "70"
landmarkName = "doGameLoop()"
landmarkType = "7">
</BreakpointContent>
@ -723,8 +723,8 @@
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "70"
endingLineNumber = "70"
startingLineNumber = "75"
endingLineNumber = "75"
landmarkName = "doGameLoop()"
landmarkType = "7">
</BreakpointContent>
@ -739,8 +739,8 @@
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "89"
endingLineNumber = "89"
startingLineNumber = "92"
endingLineNumber = "92"
landmarkName = "isFull()"
landmarkType = "7">
</BreakpointContent>
@ -755,8 +755,8 @@
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "64"
endingLineNumber = "64"
startingLineNumber = "66"
endingLineNumber = "66"
landmarkName = "insertPeice(id:row:)"
landmarkType = "7">
</BreakpointContent>
@ -771,8 +771,8 @@
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "95"
endingLineNumber = "95"
startingLineNumber = "98"
endingLineNumber = "98"
landmarkName = "isFull()"
landmarkType = "7">
</BreakpointContent>
@ -787,8 +787,8 @@
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "86"
endingLineNumber = "86"
startingLineNumber = "89"
endingLineNumber = "89"
landmarkName = "isFull()"
landmarkType = "7">
</BreakpointContent>
@ -803,8 +803,8 @@
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "76"
endingLineNumber = "76"
startingLineNumber = "79"
endingLineNumber = "79"
landmarkName = "insertPeice(id:row:)"
landmarkType = "7">
</BreakpointContent>
@ -819,8 +819,8 @@
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "75"
endingLineNumber = "75"
startingLineNumber = "78"
endingLineNumber = "78"
landmarkName = "insertPeice(id:row:)"
landmarkType = "7">
</BreakpointContent>
@ -835,8 +835,8 @@
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "63"
endingLineNumber = "63"
startingLineNumber = "65"
endingLineNumber = "65"
landmarkName = "insertPeice(id:row:)"
landmarkType = "7">
</BreakpointContent>
@ -851,8 +851,8 @@
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "58"
endingLineNumber = "58"
startingLineNumber = "63"
endingLineNumber = "63"
landmarkName = "doGameLoop()"
landmarkType = "7">
</BreakpointContent>
@ -871,51 +871,213 @@
endingLineNumber = "15"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B23E4265-3B48-4BC0-A364-9C39EB958E83"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Rules/AreCols4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "1B4AD684-B1F9-4537-9D8D-F076E6AB7396"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "29"
endingLineNumber = "29"
landmarkName = "init(printer:reader:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "49AF879C-C559-439E-A179-9D31D88B4C88"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Board.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "75"
endingLineNumber = "75"
landmarkName = "insertPeice(id:row:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B1AA1A5E-8953-448E-84BC-7728CE11AFDF"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "62"
endingLineNumber = "62"
landmarkName = "doGameLoop()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "462A6BA0-4EAC-4386-A8B9-47C969632E7C"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "65"
endingLineNumber = "65"
landmarkName = "doGameLoop()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "5344EF47-AF5B-44C2-AE97-D2D94BABF457"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Game.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "69"
endingLineNumber = "69"
landmarkName = "doGameLoop()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "3F1CBC4F-7097-4A02-BCEC-28A8FF8E47CC"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Tests/forcesPackTests/boardRulesTests.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "58"
endingLineNumber = "58"
landmarkName = "testRules()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "A9FBCBE9-2856-4B7D-819A-89FF0A6C90A5"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Tests/forcesPackTests/boardRulesTests.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "59"
endingLineNumber = "59"
landmarkName = "testRules()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "73A09D9B-4A07-4B84-93FF-17294066F6FE"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Tests/forcesPackTests/boardRulesTests.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "78"
endingLineNumber = "78"
landmarkName = "testRules()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "8BACE176-F770-4EB3-8035-85154215B163"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Tests/forcesPackTests/boardRulesTests.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "77"
endingLineNumber = "77"
landmarkName = "testRules()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "ED89C2BE-5DA1-45B9-954B-C64D3635AC83"
shouldBeEnabled = "No"
condition = "index == 6"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
<Locations>
<Location
uuid = "8BCF5C14-DCCF-4939-9693-39220C46B433 - 2c501b284e01d3a0"
uuid = "ED89C2BE-5DA1-45B9-954B-C64D3635AC83 - 2c2c4a58e0aac7ef"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "forcesPack.AreCols4xL.isRuleMet(grid: Swift.Array&lt;Swift.Array&lt;Swift.Optional&lt;Swift.Int&gt;&gt;&gt;, targetedRow: Swift.Int, targetedCol: Swift.Int) -&gt; Swift.Bool"
symbolName = "forcesPack.AreRows4xL.isRuleMet(grid: Swift.Array&lt;Swift.Array&lt;Swift.Optional&lt;Swift.Int&gt;&gt;&gt;, targetedRow: Swift.Int, targetedCol: Swift.Int, lastPlayedId: Swift.Int) -&gt; Swift.Bool"
moduleName = "4forces"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/yorickgeoffre/swift/4forces/forcesPack/Sources/forcesPack/Rules/AreCols4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "15"
endingLineNumber = "15"
offsetFromSymbolStart = "433">
</Location>
<Location
uuid = "8BCF5C14-DCCF-4939-9693-39220C46B433 - 75a93932461f4bbe"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "forcesPack.AreCols4xL.isRuleMet(grid: Swift.Array&lt;Swift.Array&lt;Swift.Optional&lt;Swift.Int&gt;&gt;&gt;, targetedRow: Swift.Int, targetedCol: Swift.Int) -&gt; Swift.Bool"
moduleName = "forcesPackTests"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/yorickgeoffre/swift/4forces/forcesPack/Sources/forcesPack/Rules/AreCols4xL.swift"
urlString = "file:///Users/yorickgeoffre/swift/4forces/forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "15"
endingLineNumber = "15"
offsetFromSymbolStart = "433">
startingLineNumber = "16"
endingLineNumber = "16"
offsetFromSymbolStart = "353">
</Location>
<Location
uuid = "8BCF5C14-DCCF-4939-9693-39220C46B433 - 943c983c060e688e"
uuid = "ED89C2BE-5DA1-45B9-954B-C64D3635AC83 - 75d56842e8b45ff1"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "forcesPack.AreCols4xL.isRuleMet(grid: Swift.Array&lt;Swift.Array&lt;Swift.Optional&lt;Swift.Int&gt;&gt;&gt;, targetedRow: Swift.Int, targetedCol: Swift.Int, lastPlayedId: Swift.Int) -&gt; Swift.Bool"
symbolName = "forcesPack.AreRows4xL.isRuleMet(grid: Swift.Array&lt;Swift.Array&lt;Swift.Optional&lt;Swift.Int&gt;&gt;&gt;, targetedRow: Swift.Int, targetedCol: Swift.Int, lastPlayedId: Swift.Int) -&gt; Swift.Bool"
moduleName = "forcesPackTests"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/yorickgeoffre/swift/4forces/forcesPack/Sources/forcesPack/Rules/AreCols4xL.swift"
urlString = "file:///Users/yorickgeoffre/swift/4forces/forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "15"
endingLineNumber = "15"
offsetFromSymbolStart = "323">
startingLineNumber = "16"
endingLineNumber = "16"
offsetFromSymbolStart = "353">
</Location>
</Locations>
</BreakpointContent>
@ -923,15 +1085,15 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B23E4265-3B48-4BC0-A364-9C39EB958E83"
uuid = "630017D1-AEE1-43BB-9E30-0AA0073077B9"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Rules/AreCols4xL.swift"
filePath = "forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
startingLineNumber = "15"
endingLineNumber = "15"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
</BreakpointContent>
@ -939,16 +1101,16 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "1B4AD684-B1F9-4537-9D8D-F076E6AB7396"
uuid = "3F2D8AD6-292E-4408-8904-CCD47EBE419E"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "forcesPack/Sources/forcesPack/Game.swift"
filePath = "forcesPack/Sources/forcesPack/Rules/AreRows4xL.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "24"
endingLineNumber = "24"
landmarkName = "init(printer:reader:)"
startingLineNumber = "28"
endingLineNumber = "28"
landmarkName = "isRuleMet(grid:targetedRow:targetedCol:lastPlayedId:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>

@ -22,6 +22,8 @@ public struct Board : CustomStringConvertible{
private var nbColumn = 4
private var grid: [[Int?]]
public var nbRow: Int {get{return nbRows}}
public var nbCols : Int {
get{nbColumn}
}
@ -38,7 +40,7 @@ public struct Board : CustomStringConvertible{
}
self.nbColumn = nbRows
self.nbRows = nbCol
grid = Array(repeating: Array( repeating: nil, count: nbRows), count: nbColumn)
grid = Array(repeating: Array( repeating: nil, count: nbRows), count: nbCol)
}
public init?(input: [[Int?]]){
@ -54,14 +56,14 @@ public struct Board : CustomStringConvertible{
print("insert not nil err")
return false;
}
lastInsertIndex = row
lastInsertIndex = col
grid[row][col] = id
//print(grid)
return true;
}
public mutating func insertPeice(id: Int, row: Int) -> Bool{
guard !isFull() && row >= 0 && row < grid[0].capacity else{ return false }
guard !isFull() && row >= 0 && row < grid.capacity else{ return false }
var colToInsert: Int = nbColumn-1
@ -69,6 +71,7 @@ public struct Board : CustomStringConvertible{
for cellNum in 0...nbColumn-1{ //parcours de la grille du haut vers le bas
// print("for in: ", cellNum)
let nbC = nbColumn
if(grid[row][(nbColumn-1)-cellNum] == nil){colToInsert = (nbColumn-1)-cellNum; break}
}
@ -104,31 +107,31 @@ public struct Board : CustomStringConvertible{
private func toString() -> String{
var str: String = ""
str += ""
str += String(repeating: "═╦", count: (nbColumn)-1) + "═╗\n"
for collNum in 0...nbRows-1{ //parcours de la grille du bas vers le haut
for rowNum in 0...nbColumn-1{
str += String(repeating: "═╦", count: (nbRows)-1) + "═╗\n"
for collNum in 0...nbColumn-1{ //parcours de la grille du bas vers le haut
for rowNum in 0...nbRows-1{
str += String(""+((grid[rowNum][collNum] == nil) ? "" : String((grid[rowNum][collNum] ?? 0))))
}
str += String("\n")
}
str += ""
str += String(repeating: "═╩", count: (nbColumn)-1) + "═╝\n"
str += String(repeating: "═╩", count: (nbRows)-1) + "═╝\n"
return str
}
public func coalesceWonBoard(winningAlignementGrid: [[Int?]]) -> String{
var str: String = ""
str += ""
str += String(repeating: "═╦", count: (nbColumn)-1) + "═╗\n"
for collNum in 0...nbRows-1{ //parcours de la grille du bas vers le haut
for rowNum in 0...nbColumn-1{
str += String(repeating: "═╦", count: (nbRows)-1) + "═╗\n"
for collNum in 0...nbColumn-1{ //parcours de la grille du bas vers le haut
for rowNum in 0...nbRows-1{
str += ""
str += String(winningAlignementGrid[rowNum][collNum] != nil ? "@" : " ")
}
str += String("\n")
}
str += ""
str += String(repeating: "═╩", count: (nbColumn)-1) + "═╝\n"
str += String(repeating: "═╩", count: (nbRows)-1) + "═╝\n"
return str
}
}

@ -15,12 +15,17 @@ public class Game{
private var printerFunc: (String)->()
private var readerFunc: (Bool)-> String?
private var rows: Int = 6
private var cols: Int = 7
public init(printer: @escaping (String)->(),reader: @escaping (Bool)->String?) {
readerFunc = reader
printerFunc = printer
board = Board()
board = Board(nbRows: rows,nbCol: cols)!
players = []
winRules = [AreCols4xL(), AreRows4xL(), AreDiags4xL()]
//createBoard()
//board = Board(nbRows: rows,nbCol: cols)!
while(!CreatePlayers()){}
while(true){
@ -29,10 +34,10 @@ public class Game{
if(winner != nil){ break }
sleep(1)
winner = nil
board = Board()
board = Board(nbRows: rows,nbCol: cols)!
}
}
//test constructor
public init(_ pl: [Player], printer: @escaping (String)->(),reader: @escaping (Bool)->String?){
readerFunc = reader
printerFunc = printer
@ -54,10 +59,10 @@ public class Game{
private func doGameLoop() -> Bool{
for p in players{
var played: Int = p.play(board.nbCols-1)
var played: Int = p.play(board.nbRow-1)
while(!board.insertPeice(id: p.id, row: played)){
printerFunc("Incorrect choice, pick another:\n")
played = p.play(board.nbCols-1)
played = p.play(board.nbRow-1)
}
printerFunc(board.description)
for gRule in winRules {
@ -106,4 +111,11 @@ public class Game{
printerFunc(players.description)
return humans+AI > 0
}
private func createBoard(){
printerFunc("Création du tableau, combien de colonnes?\n>")
if let typed = readerFunc(true) {if let num = Int(typed) {cols = num}}
printerFunc("\ncombien de lignes?\n>")
if let typed = readerFunc(true) {if let num = Int(typed) {rows = num}}
}
}

@ -12,17 +12,17 @@ public class AreCols4xL: gridRule, Rule{
var old: Int? = lastPlayedId
var count: Int = 0
var index: Int = 0
for cell in grid[targetedRow]{
for cell in grid[targetedCol]{
if(cell == old && old != nil){
count += 1
}else{
count = 0
}
old = cell
old = cell ?? old
if count >= 4{
prepareGrid(grid)
for idx in index-3...index{
resultsGrid?[targetedRow][idx] = old
resultsGrid?[targetedCol][idx] = old
}
return true;
}

@ -15,7 +15,7 @@ public class AreDiags4xL: gridRule, Rule{
let rowsize = grid[0].capacity-1
for index in -3...3{ // comme /
if((0...grid.capacity-1).contains(targetedRow + index) && (0...rowsize).contains(targetedCol + index)){
if((0...grid.count-1).contains(targetedRow + index) && (0...rowsize).contains(targetedCol + index)){
if(old == grid[targetedRow+index][targetedCol+index] && old != nil){
count += 1
}else{
@ -35,9 +35,9 @@ public class AreDiags4xL: gridRule, Rule{
}
//---------------------------------------------------------------
count = 0
old = grid[targetedRow][targetedCol]
old = grid[targetedCol][targetedRow]
for index in -3...3{ // comme \
if((0...grid.capacity-1).contains(targetedRow - index) && (0...rowsize).contains(targetedCol + index)){
if((0...grid.count-1).contains(targetedRow - index) && (0...rowsize).contains(targetedCol + index)){
if(old == grid[targetedRow-index][targetedCol+index] && old != nil){
count += 1
}else{

@ -12,17 +12,18 @@ public class AreRows4xL: gridRule, Rule{
public func isRuleMet(grid: [[Int?]], targetedRow: Int, targetedCol: Int, lastPlayedId: Int) -> Bool {
var old: Int? = lastPlayedId
var count: Int = 0
for index in 0...grid[0].capacity-1{
if(grid[index][targetedCol] == old && old != nil){
let cap = grid.count
for index in 0...cap-1{
if(grid[index][targetedRow] == old && old != nil){
count += 1
}else{
count = 0
}
old = grid[index][targetedCol]
old = grid[index][targetedRow] ?? old
if count >= 4{
prepareGrid(grid)
for idx in index-3...index{
resultsGrid?[idx][targetedCol] = old
resultsGrid?[idx][targetedRow] = old
}
return true;
}

@ -16,6 +16,11 @@ final class BoardRulesTests: XCTestCase {
private var boardDiag: [[Int?]] = [[0,nil,nil,nil],[nil,0,nil,nil],[nil,nil,0,nil],[nil,nil,nil,0]]
private var boardDiagInv: [[Int?]] = [[nil,nil,nil,0],[nil,nil,0,nil],[nil,0,nil,nil],[0,nil,nil,nil]]
private var boardRowBig: [[Int?]] = [[nil,nil,nil,nil],[nil,nil,nil,nil],[nil,nil,nil,nil],[nil,nil,nil,nil],[0,0,0,0],[nil,nil,nil,nil]]
private var boardColBig: [[Int?]] = [[nil,nil,nil,nil],[nil,nil,nil,nil],[nil,0,nil,nil],[nil,0,nil,nil],[nil,0,nil,nil],[nil,0,nil,nil],]
private var boardDiagBig: [[Int?]] = [[nil,nil,nil,nil],[nil,nil,nil,nil],[0,nil,nil,nil],[nil,0,nil,nil],[nil,nil,0,nil],[nil,nil,nil,0]]
private var boardDiagInvBig: [[Int?]] = [[nil,nil,nil,nil],[nil,nil,nil,nil],[nil,nil,nil,0],[nil,nil,0,nil],[nil,0,nil,nil],[0,nil,nil,nil]]
func testRules(){
var ruleCol : Rule = AreCols4x()
var ruleRow: Rule = AreRows4x()
@ -64,5 +69,21 @@ final class BoardRulesTests: XCTestCase {
print(ruleRowL.results)
print(ruleColL.results)
print(ruleDiagL.results)
XCTAssertTrue(ruleColL.isRuleMet(grid: boardRowBig, targetedRow: 4, targetedCol: 4, lastPlayedId: 0))
XCTAssertFalse(ruleRowL.isRuleMet(grid: boardRowBig, targetedRow: 1, targetedCol: 1, lastPlayedId: 0))
XCTAssertFalse(ruleDiagL.isRuleMet(grid: boardRowBig, targetedRow: 2, targetedCol: 4, lastPlayedId: 0))
XCTAssertFalse(ruleColL.isRuleMet(grid: boardColBig, targetedRow: 4, targetedCol: 4, lastPlayedId: 0))
XCTAssertTrue(ruleRowL.isRuleMet(grid: boardColBig, targetedRow: 1, targetedCol: 1, lastPlayedId: 0))
XCTAssertFalse(ruleDiagL.isRuleMet(grid: boardColBig, targetedRow: 2, targetedCol: 4, lastPlayedId: 0))
XCTAssertFalse(ruleColL.isRuleMet(grid: boardDiagBig, targetedRow: 4, targetedCol: 4, lastPlayedId: 0))
XCTAssertFalse(ruleRowL.isRuleMet(grid: boardDiagBig, targetedRow: 1, targetedCol: 1, lastPlayedId: 0))
XCTAssertTrue(ruleDiagL.isRuleMet(grid: boardDiagBig, targetedRow: 2, targetedCol: 0, lastPlayedId: 0))
XCTAssertFalse(ruleColL.isRuleMet(grid: boardDiagInvBig, targetedRow: 4, targetedCol: 4, lastPlayedId: 0))
XCTAssertFalse(ruleRowL.isRuleMet(grid: boardDiagInvBig, targetedRow: 1, targetedCol: 1, lastPlayedId: 0))
XCTAssertTrue(ruleDiagL.isRuleMet(grid: boardDiagInvBig, targetedRow: 2, targetedCol: 3, lastPlayedId: 0))
}
}

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:nourscmd/nourscmd.xcodeproj">
</FileRef>
<FileRef
location = "group:nours">
</FileRef>
</Workspace>

@ -1,9 +0,0 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

@ -1,28 +0,0 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "nours",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "nours",
targets: ["nours"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "nours",
dependencies: []),
.testTarget(
name: "noursTests",
dependencies: ["nours"]),
]
)

@ -1,3 +0,0 @@
# nours
A description of this package.

@ -1,6 +0,0 @@
public struct Nounours{
public private(set) var text = "Hello, World!"
public init() {
}
}

@ -1,11 +0,0 @@
import XCTest
@testable import nours
final class noursTests: XCTestCase {
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
XCTAssertEqual(nours().text, "Hello, World!")
}
}

@ -1,305 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objects = {
/* Begin PBXBuildFile section */
7EBE003F29826F1300B62CE4 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EBE003E29826F1300B62CE4 /* main.swift */; };
7EBE004729826F2D00B62CE4 /* nours in Frameworks */ = {isa = PBXBuildFile; productRef = 7EBE004629826F2D00B62CE4 /* nours */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
7EBE003929826F1300B62CE4 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
7EBE003B29826F1300B62CE4 /* nourscmd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = nourscmd; sourceTree = BUILT_PRODUCTS_DIR; };
7EBE003E29826F1300B62CE4 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
7EBE003829826F1300B62CE4 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7EBE004729826F2D00B62CE4 /* nours in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
7EBE003229826F1300B62CE4 = {
isa = PBXGroup;
children = (
7EBE003D29826F1300B62CE4 /* nourscmd */,
7EBE003C29826F1300B62CE4 /* Products */,
7EBE004529826F2D00B62CE4 /* Frameworks */,
);
sourceTree = "<group>";
};
7EBE003C29826F1300B62CE4 /* Products */ = {
isa = PBXGroup;
children = (
7EBE003B29826F1300B62CE4 /* nourscmd */,
);
name = Products;
sourceTree = "<group>";
};
7EBE003D29826F1300B62CE4 /* nourscmd */ = {
isa = PBXGroup;
children = (
7EBE003E29826F1300B62CE4 /* main.swift */,
);
path = nourscmd;
sourceTree = "<group>";
};
7EBE004529826F2D00B62CE4 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
7EBE003A29826F1300B62CE4 /* nourscmd */ = {
isa = PBXNativeTarget;
buildConfigurationList = 7EBE004229826F1300B62CE4 /* Build configuration list for PBXNativeTarget "nourscmd" */;
buildPhases = (
7EBE003729826F1300B62CE4 /* Sources */,
7EBE003829826F1300B62CE4 /* Frameworks */,
7EBE003929826F1300B62CE4 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = nourscmd;
packageProductDependencies = (
7EBE004629826F2D00B62CE4 /* nours */,
);
productName = nourscmd;
productReference = 7EBE003B29826F1300B62CE4 /* nourscmd */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
7EBE003329826F1300B62CE4 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1420;
LastUpgradeCheck = 1420;
TargetAttributes = {
7EBE003A29826F1300B62CE4 = {
CreatedOnToolsVersion = 14.2;
};
};
};
buildConfigurationList = 7EBE003629826F1300B62CE4 /* Build configuration list for PBXProject "nourscmd" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 7EBE003229826F1300B62CE4;
productRefGroup = 7EBE003C29826F1300B62CE4 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
7EBE003A29826F1300B62CE4 /* nourscmd */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
7EBE003729826F1300B62CE4 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7EBE003F29826F1300B62CE4 /* main.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
7EBE004029826F1300B62CE4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
7EBE004129826F1300B62CE4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Release;
};
7EBE004329826F1300B62CE4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
7EBE004429826F1300B62CE4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
7EBE003629826F1300B62CE4 /* Build configuration list for PBXProject "nourscmd" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7EBE004029826F1300B62CE4 /* Debug */,
7EBE004129826F1300B62CE4 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
7EBE004229826F1300B62CE4 /* Build configuration list for PBXNativeTarget "nourscmd" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7EBE004329826F1300B62CE4 /* Debug */,
7EBE004429826F1300B62CE4 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCSwiftPackageProductDependency section */
7EBE004629826F2D00B62CE4 /* nours */ = {
isa = XCSwiftPackageProductDependency;
productName = nours;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 7EBE003329826F1300B62CE4 /* Project object */;
}

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>nourscmd.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
</dict>
</plist>

@ -1,11 +0,0 @@
//
// main.swift
// nourscmd
//
// Created by yorick geoffre on 26/01/2023.
//
import Foundation
print("Hello, World!")
Loading…
Cancel
Save