parent
2f74ca2dee
commit
0c6d2f80d3
@ -0,0 +1,9 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/config/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1410"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "model"
|
||||
BuildableName = "model"
|
||||
BlueprintName = "model"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "modelTests"
|
||||
BuildableName = "modelTests"
|
||||
BlueprintName = "modelTests"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "modelTests"
|
||||
BuildableName = "modelTests"
|
||||
BlueprintName = "modelTests"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "model"
|
||||
BuildableName = "model"
|
||||
BlueprintName = "model"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@ -0,0 +1,28 @@
|
||||
// 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: "model",
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "model",
|
||||
targets: ["model"]),
|
||||
],
|
||||
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: "model",
|
||||
dependencies: []),
|
||||
.testTarget(
|
||||
name: "modelTests",
|
||||
dependencies: ["model"]),
|
||||
]
|
||||
)
|
@ -0,0 +1,3 @@
|
||||
# model
|
||||
|
||||
A description of this package.
|
@ -0,0 +1,22 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by etudiant on 25/01/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public class Lecteur {
|
||||
init() {
|
||||
|
||||
}
|
||||
|
||||
public func lireInt() -> Int {
|
||||
Int(readLine())
|
||||
}
|
||||
|
||||
public func lireLigne() -> Int {
|
||||
readLine()
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by etudiant on 17/01/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct Board: CustomStringConvertible {
|
||||
var grid: [[Int?]];
|
||||
let nbRows: Int;
|
||||
let nbColumns: Int;
|
||||
private static let descriptionMapper: [Int?:String] = [nil:"-", 1:"O", 2:"X"];
|
||||
|
||||
public init?(nbR: Int = 6, nbC: Int = 7) {
|
||||
if nbR <= 0 || nbC <= 0 {
|
||||
return nil
|
||||
}
|
||||
self.nbRows = nbR
|
||||
self.nbColumns = nbC
|
||||
self.grid = Array(repeating: Array(repeating: nil, count: nbC), count: nbR)
|
||||
}
|
||||
|
||||
public init?(withGrid grid : [[Int?]]){
|
||||
let sizes = grid.map{ return $0.count }
|
||||
|
||||
let result = sizes.allSatisfy {
|
||||
$0 == grid[0].count
|
||||
}
|
||||
|
||||
guard result else {
|
||||
return nil
|
||||
}
|
||||
|
||||
nbRows = grid.count
|
||||
nbColumns = grid[0].count
|
||||
self.grid=grid
|
||||
}
|
||||
|
||||
|
||||
public var description: String {
|
||||
var string = String()
|
||||
|
||||
for row in grid {
|
||||
for cell in row {
|
||||
string.append("\(String(describing: Board.descriptionMapper[cell] ?? "-")) ")
|
||||
}
|
||||
string.append("\n")
|
||||
}
|
||||
|
||||
return string
|
||||
}
|
||||
|
||||
private func isFull() -> Bool {
|
||||
for column in 0..<nbColumns{
|
||||
if !isColumnFull(column: column) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private func isColumnFull(column: Int) -> Bool{
|
||||
for row in 0..<nbRows {
|
||||
if grid[row][column] == nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private mutating func insertPiece(id:Int, row:Int, column:Int) -> BoardResult {
|
||||
guard row >= 0 && row < nbRows && column >= 0 && column < nbColumns else {
|
||||
return .failed(.outOfBound)
|
||||
}
|
||||
|
||||
guard grid[row][column] == nil else {
|
||||
return .failed(.unknown)
|
||||
}
|
||||
|
||||
grid[row][column] = id
|
||||
return .ok
|
||||
}
|
||||
|
||||
public mutating func insertPiece(id:Int, column:Int) -> BoardResult {
|
||||
var result = BoardResult.unknown
|
||||
for row in (0..<nbRows ).reversed() {
|
||||
if row < 0 {
|
||||
return .failed(.columnFull)
|
||||
}
|
||||
result = insertPiece(id: id, row: row, column: column)
|
||||
switch result {
|
||||
case .ok:
|
||||
return .ok
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
return .failed(.unknown)
|
||||
}
|
||||
|
||||
public mutating func removePiece(row:Int, column:Int) -> BoardResult {
|
||||
guard row >= 0 && row < nbRows && column >= 0 && column < nbColumns else {
|
||||
return .failed(.outOfBound)
|
||||
}
|
||||
|
||||
grid[row][column] = nil
|
||||
return .ok
|
||||
}
|
||||
|
||||
public mutating func clearGrid(){
|
||||
for r in 0..<nbRows {
|
||||
for c in 0..<nbColumns {
|
||||
grid[r][c] = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by etudiant on 18/01/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum BoardResult : Equatable{
|
||||
case unknown
|
||||
case ok
|
||||
case failed(FailedReason)
|
||||
}
|
||||
|
||||
public enum FailedReason {
|
||||
case unknown
|
||||
case columnFull
|
||||
case boardFull
|
||||
case outOfBound
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by etudiant on 19/01/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct Game {
|
||||
private var board: Board
|
||||
private var players: [Player]
|
||||
private var numero: Int = 0
|
||||
|
||||
public init?(withBoard board: Board, playedBy players: [Player]) {
|
||||
self.board = board
|
||||
|
||||
self.players = players
|
||||
}
|
||||
|
||||
public init?(withGrid grid: [[Int?]], playedBy players: [Player]) {
|
||||
let b = Board(withGrid: grid)
|
||||
|
||||
guard b != nil else {
|
||||
return nil
|
||||
}
|
||||
|
||||
board = b!
|
||||
|
||||
self.players = players
|
||||
}
|
||||
|
||||
public init?(withNbRow nbRow: Int = 6, withNbCol nbCol: Int = 7, playedBy players: [Player]) {
|
||||
let b = Board(nbR: nbRow, nbC: nbCol)
|
||||
|
||||
guard b != nil else {
|
||||
return nil
|
||||
}
|
||||
|
||||
board = b!
|
||||
|
||||
self.players = players
|
||||
}
|
||||
|
||||
public mutating func tour() -> Player?{
|
||||
let player = players[numero]
|
||||
var result = BoardResult.unknown
|
||||
while(result != BoardResult.ok ){
|
||||
result = board.insertPiece(id: numero + 1, column: player.playInColumn())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by etudiant on 25/01/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public class Human : Player {
|
||||
public var name: String
|
||||
public var board: Board
|
||||
private var lecteur: Lecteur
|
||||
|
||||
public init(named name: String, playedOn board: Board, readOn lecteur: Lecteur){
|
||||
self.name = name
|
||||
self.board = board
|
||||
self.lecteur = lecteur
|
||||
}
|
||||
|
||||
public func playInColumn() -> Int {
|
||||
lecteur.lireInt()
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by etudiant on 25/01/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class IA: Player {
|
||||
var name: String
|
||||
|
||||
var board: Board
|
||||
|
||||
init(named name: String, playedOn board: Board){
|
||||
self.name = name
|
||||
self.board = board
|
||||
}
|
||||
|
||||
func playInColumn() -> Int {
|
||||
return Int.random(in: 0..<(board.nbColumns))
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by etudiant on 19/01/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol Player {
|
||||
var name: String { get set }
|
||||
var board: Board { get set }
|
||||
|
||||
func playInColumn() -> Int
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
import XCTest
|
||||
@testable import model
|
||||
|
||||
final class boardTests: XCTestCase {
|
||||
func test_constructor() throws {
|
||||
var nbR = -8
|
||||
var nbC = 10
|
||||
|
||||
var b = Board(nbR: nbR, nbC: nbC)
|
||||
|
||||
XCTAssertNil(b?.grid)
|
||||
|
||||
nbR = 4
|
||||
nbC = -10
|
||||
b = Board(nbR: nbR, nbC: nbC)
|
||||
XCTAssertNil(b?.grid)
|
||||
|
||||
|
||||
nbR = 4
|
||||
nbC = 10
|
||||
b = Board(nbR: nbR, nbC: nbC)
|
||||
XCTAssertNotNil(b?.grid)
|
||||
XCTAssertEqual(nbR, b?.nbRows)
|
||||
XCTAssertEqual(nbC, b?.nbColumns)
|
||||
}
|
||||
|
||||
func test_manipulatePiece() {
|
||||
var board = Board(nbR: 4, nbC: 4)
|
||||
|
||||
board?.insertPiece(id: 1, column: 2)
|
||||
XCTAssertEqual(1, board?.grid[3][2])
|
||||
|
||||
// XCTAssertEqual(BoardResult.ok, board?.insertPiece(id: 1, column: 2))
|
||||
// XCTAssertEqual(BoardResult.failed(.columnFull), board?.insertPiece(id: 1, column: 2))
|
||||
|
||||
board?.removePiece(row: 3, column: 2)
|
||||
XCTAssertNil(board?.grid[3][2])
|
||||
}
|
||||
|
||||
func test_cleanBoard(){
|
||||
var board = Board(withGrid: [[1,0,1],[0,1,0],[1,0,1]])
|
||||
|
||||
if var b = board {
|
||||
|
||||
XCTAssertNotNil(b.grid[0][0])
|
||||
|
||||
b.clearGrid()
|
||||
|
||||
|
||||
for r in 0..<b.nbRows {
|
||||
for c in 0..<b.nbColumns {
|
||||
XCTAssertNil(b.grid[r][c])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
import XCTest
|
||||
@testable import model
|
||||
|
||||
public class GameTests : XCTestCase {
|
||||
func test_constructeur(){
|
||||
//var game = Game(withNbRow: 4, withNbCol: 4, playedBy: [Player(named: "Joueur1"), Player(named: "Joueur2")])
|
||||
//XCTAssertNotNil(game)
|
||||
|
||||
//game = Game(withGrid: [[nil,1],[1,2]], playedBy: [Player(named: "Joueur1"), Player(named: "Joueur2")])
|
||||
//XCTAssertNotNil(game)
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:puissance4/puissance4.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:model">
|
||||
</FileRef>
|
||||
</Workspace>
|
@ -0,0 +1,8 @@
|
||||
<?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>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
@ -0,0 +1,8 @@
|
||||
<?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>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
@ -0,0 +1,14 @@
|
||||
<?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>BuildLocationStyle</key>
|
||||
<string>UseAppPreferences</string>
|
||||
<key>CustomBuildLocationType</key>
|
||||
<string>RelativeToDerivedData</string>
|
||||
<key>DerivedDataLocationStyle</key>
|
||||
<string>Default</string>
|
||||
<key>ShowSharedSchemesAutomaticallyEnabled</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
@ -0,0 +1,305 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 56;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
EC62D5D52976881000CAB764 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62D5D42976881000CAB764 /* main.swift */; };
|
||||
EC62D5DD2976889500CAB764 /* model in Frameworks */ = {isa = PBXBuildFile; productRef = EC62D5DC2976889500CAB764 /* model */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
EC62D5CF2976881000CAB764 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = /usr/share/man/man1/;
|
||||
dstSubfolderSpec = 0;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 1;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
EC62D5D12976881000CAB764 /* puissance4 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = puissance4; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EC62D5D42976881000CAB764 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
EC62D5CE2976881000CAB764 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EC62D5DD2976889500CAB764 /* model in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
EC62D5C82976881000CAB764 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EC62D5D32976881000CAB764 /* puissance4 */,
|
||||
EC62D5D22976881000CAB764 /* Products */,
|
||||
EC62D5DB2976889500CAB764 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EC62D5D22976881000CAB764 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EC62D5D12976881000CAB764 /* puissance4 */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EC62D5D32976881000CAB764 /* puissance4 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EC62D5D42976881000CAB764 /* main.swift */,
|
||||
);
|
||||
path = puissance4;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EC62D5DB2976889500CAB764 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
EC62D5D02976881000CAB764 /* puissance4 */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = EC62D5D82976881000CAB764 /* Build configuration list for PBXNativeTarget "puissance4" */;
|
||||
buildPhases = (
|
||||
EC62D5CD2976881000CAB764 /* Sources */,
|
||||
EC62D5CE2976881000CAB764 /* Frameworks */,
|
||||
EC62D5CF2976881000CAB764 /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = puissance4;
|
||||
packageProductDependencies = (
|
||||
EC62D5DC2976889500CAB764 /* model */,
|
||||
);
|
||||
productName = puissance4;
|
||||
productReference = EC62D5D12976881000CAB764 /* puissance4 */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
EC62D5C92976881000CAB764 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1410;
|
||||
LastUpgradeCheck = 1410;
|
||||
TargetAttributes = {
|
||||
EC62D5D02976881000CAB764 = {
|
||||
CreatedOnToolsVersion = 14.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = EC62D5CC2976881000CAB764 /* Build configuration list for PBXProject "puissance4" */;
|
||||
compatibilityVersion = "Xcode 14.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = EC62D5C82976881000CAB764;
|
||||
productRefGroup = EC62D5D22976881000CAB764 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
EC62D5D02976881000CAB764 /* puissance4 */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
EC62D5CD2976881000CAB764 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EC62D5D52976881000CAB764 /* main.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
EC62D5D62976881000CAB764 /* 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.0;
|
||||
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;
|
||||
};
|
||||
EC62D5D72976881000CAB764 /* 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.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
EC62D5D92976881000CAB764 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
EC62D5DA2976881000CAB764 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
EC62D5CC2976881000CAB764 /* Build configuration list for PBXProject "puissance4" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
EC62D5D62976881000CAB764 /* Debug */,
|
||||
EC62D5D72976881000CAB764 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
EC62D5D82976881000CAB764 /* Build configuration list for PBXNativeTarget "puissance4" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
EC62D5D92976881000CAB764 /* Debug */,
|
||||
EC62D5DA2976881000CAB764 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
EC62D5DC2976889500CAB764 /* model */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
productName = model;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = EC62D5C92976881000CAB764 /* Project object */;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
@ -0,0 +1,8 @@
|
||||
<?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>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
@ -0,0 +1,14 @@
|
||||
<?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>puissance4.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
@ -0,0 +1,36 @@
|
||||
//
|
||||
// main.swift
|
||||
// puissance4
|
||||
//
|
||||
// Created by etudiant on 17/01/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import model
|
||||
|
||||
//let board = Board(withGrid: [[nil,nil,nil],[1,nil,1],[2,1,2]])
|
||||
//if var b = board {
|
||||
// print(b.description)
|
||||
//
|
||||
// b.insertPiece(id: 1, column: 1)
|
||||
// print(b.description)
|
||||
//
|
||||
// b.insertPiece(id: 2, column: 1)
|
||||
// print(b.description)
|
||||
//
|
||||
// b.removePiece(row: 1, column: 1)
|
||||
// print(b.description)
|
||||
|
||||
var lecteur = Lecteur()
|
||||
|
||||
var b = Board()
|
||||
if var board = b {
|
||||
var player1 = Human(named: "Bingeamain", playedOn: board, readOn: lecteur)
|
||||
var player2 = Human(named: "illohanne", playedOn: board, readOn: lecteur)
|
||||
|
||||
var game = Game(withBoard: board, playedBy: [player1, player2])
|
||||
|
||||
while true {
|
||||
game?.tour()
|
||||
}
|
||||
}
|
Loading…
Reference in new issue