Boards
Mathieu GROUSSEAU 1 month ago
parent a960f6f390
commit 27df2f0bb8

@ -3,12 +3,13 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 60;
objects = {
/* Begin PBXBuildFile section */
282549B82D3278F9008D2C3B /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 282549B72D3278F9008D2C3B /* main.swift */; };
282549C02D327907008D2C3B /* Model in Frameworks */ = {isa = PBXBuildFile; productRef = 282549BF2D327907008D2C3B /* Model */; };
EC9914352D40233000C0459C /* CustomTypes in Frameworks */ = {isa = PBXBuildFile; productRef = EC9914342D40233000C0459C /* CustomTypes */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -34,6 +35,7 @@
buildActionMask = 2147483647;
files = (
282549C02D327907008D2C3B /* Model in Frameworks */,
EC9914352D40233000C0459C /* CustomTypes in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -90,6 +92,7 @@
name = CLI;
packageProductDependencies = (
282549BF2D327907008D2C3B /* Model */,
EC9914342D40233000C0459C /* CustomTypes */,
);
productName = CLI;
productReference = 282549B42D3278F9008D2C3B /* CLI */;
@ -119,6 +122,9 @@
Base,
);
mainGroup = 282549AB2D3278F9008D2C3B;
packageReferences = (
EC9914332D40233000C0459C /* XCLocalSwiftPackageReference "../CustomTypes" */,
);
productRefGroup = 282549B52D3278F9008D2C3B /* Products */;
projectDirPath = "";
projectRoot = "";
@ -294,11 +300,22 @@
};
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
EC9914332D40233000C0459C /* XCLocalSwiftPackageReference "../CustomTypes" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../CustomTypes;
};
/* End XCLocalSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
282549BF2D327907008D2C3B /* Model */ = {
isa = XCSwiftPackageProductDependency;
productName = Model;
};
EC9914342D40233000C0459C /* CustomTypes */ = {
isa = XCSwiftPackageProductDependency;
productName = CustomTypes;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 282549AC2D3278F9008D2C3B /* Project object */;

@ -1,11 +1,45 @@
//
// main.swift
// CLI
//
// Created by Mathieu GROUSSEAU on 11/01/2025.
//
import Foundation
print("Hello, World!")
import Model
import CustomTypes
guard var board = Board(columns: 5, rows: 5) else {
print("Failed to create board.")
exit(EXIT_FAILURE)
}
print(board.debugDescription)
print(board)
for i in 0...2 {
for _ in 0...i {
let dropAt = board.getInsertionCoordinates(from: .Top, offset: i)
let landAt = switch board.fallCoordinates(initialCoords: dropAt, direction: .Bottom) {
case .Border(let at), .Piece(let at, _):
at
case .Occupied:
exit(EXIT_FAILURE)
}
board[landAt] = Piece(owner: .A)
}
}
print(board)
board[0, 2] = Piece(owner: .B)
board[2, 4] = nil
for c in 0..<board.rows {
switch board.fallCoordinates(initialCoords: board.getInsertionCoordinates(from: .Right, offset: c), direction: .Left) {
case .Border(let at):
board[at] = Piece(owner: .B)
case .Piece(let at, let touched):
(board[at], board[touched]) = (board[touched], Piece(owner: .B))
case .Occupied:
break
}
}
print(board.debugDescription)
print(board)

Loading…
Cancel
Save