Swift client for Software-Challenge Germany 2022/2023

Overview

Swift client for Software-Challenge Germany 2022/2023

Build package Swift Supported Platforms

This package contains a simple client written in Swift for Software-Challenge Germany 2022/2023.

The game of the contest year 2022/2023 is called Hey, Danke für den Fisch!. It is played on a hexagon board consisting of hexagon fields. The goal of the game is to collect as many fish as possible. The complete documentation of the game rules and the XML communication with the game server can be found here.

Usage

Please make sure that you have installed the latest Swift toolchain (or at least version 5.7) on your operating system. The latest version of Swift can be found here.

To build and run the executable of the simple client, use the run command of the Swift Package Manager.

swift run

If you want to use e.g. another host address or port for the simple client, then you can pass additional arguments to the run command of the Swift Package Manager. Please note that you need to specify the name of the executable when using additional arguments.

swift run simple-client -h 127.0.0.1 -p 13050

The simple client supports the following command-line arguments.

Usage: simple-client [options]
  -h, --host:
      The IP address or name of the host to connect to (default: 127.0.0.1).
  -p, --port:
      The port used for the connection (default: 13050).
  -r, --reservation:
      The reservation code to join a prepared game.
  -s, --strategy:
      The strategy used for the game.
  --help:
      Print this help message.
  --version:
      Print the version number.

Creating an archive for upload

In order to use the simple client on the competition system (a.k.a. Wettkampfsystem), a zip archive must be created that contains a start script and the compiled executable. To create such an archive, run the following commands on the terminal.

chmod u+x scripts/zip-client.sh
scripts/zip-client.sh

The resulting archive (simple-client.zip) can then be uploaded to the competition system. Please make sure that you select the start script (start-client.sh) as the main file in the uploading process.

Note: The above script (zip-client.sh) builds the client with the release configuration and calls the Swift compiler with the -O flag to optimize the executable for speed.

Customizing the logic

To customize the logic of the simple client to your own needs, simply adjust the onMoveRequested() method in the SCGameLogic.swift class.

func onMoveRequested() -> SCMove? {
    print("*** A move is requested by the game server!")

    // TODO: Add your own logic here.

    return self.gameState.possibleMoves().randomElement()
}

If you want to return e.g. the last possible move, the method can be changed as follows.

func onMoveRequested() -> SCMove? {
    print("*** A move is requested by the game server!")

    return self.gameState.possibleMoves().last
}

In addition to the default logic class, you can also implement your own logic classes. To use one of your own logic classes, the simple client offers the possibility to select a strategy (logic class) based on the value of a command-line argument (-s or --strategy). By default, this feature is disabled. To enable the feature, create a logic instance based on the strategy property of the SCGameHandler.swift class. This can be done by replacing the existing code line with a switch-statement like the following.

switch self.strategy {
    case "winner":
        self.delegate = SCWinnerLogic(player: player)
    case "crazy":
        self.delegate = SCCrazyGameLogic(player: player)
    case "another_logic":
        self.delegate = AnotherLogic(player: player)
    // ...
    default:
        self.delegate = SCGameLogic(player: player)
}

Renaming the client

If you want to change the name of the simple client, you have to adjust the target name in the Package.swift file and the directory name in the Sources folder. Furthermore the EXECUTABLE_NAME variable in the shell scripts and the executableName constant in the main.swift file needs to be changed.

Troubleshooting

Should you encounter an error or unexpected behavior while using the simple client, you may be able to resolve the problem by following the advice below.

  • Increase the TCP socket timeout: On some systems the current socket timeout of 1ms results in fatal errors before sending the first move. To prevent this, you can increase the socket timeout to a higher value. Any value greater than or equal to 5000 (which corresponds to 5ms) should resolve the problem on most systems.

If none of these tips help and you feel that you have encountered a bug, feel free to open an issue. Please describe your problem as accurately as you can and include steps to reproduce the error if possible. Note that a GitHub account is required to create a new issue. You can also instruct your tutor to do it for you.

You might also like...
My winning contribution to Apple's Swift Student Challenge 2021

SynthApp My winning contribution to Apple's Swift Student Challenge 2021 This repository contains an Xcode project and the final Swift Playgrounds fil

Challenge-vip-delivery - Project for VIP (Clean Swift) Architecture Dev Sprints on Devpass
Challenge-vip-delivery - Project for VIP (Clean Swift) Architecture Dev Sprints on Devpass

VIP (Clean Swift) - Delivery App 🍕 Neste desafio, aplicaremos conceitos da arquitetura VIP para finalizar a implementação de um aplicativo. Desenvolv

Rick and Morty Challenge With Swift

Rick-and-Morty-Challenge A Branch mais atualizada é a main. Tecnologias Modo cla

'The Particle Binder' - Winning WWDC22 Swift Student Challenge submission!

The Particle Binder 'The Particle Binder' - Winning WWDC22 Swift Student Challenge submission! Welcome to The Particle Binder, the particle accelerato

US bank coding exercise challenge

USBankcodingexercise US bank coding exercise challenge This repo has two projects Project to demo MVVM design pattern problem statement - read data fr

Flipgrid Challenge
Flipgrid Challenge

FlipgridChallenge Overview The project follows MVVM-FlowViewController architecture that scales nicely as more screens/flows are added. I have added c

Birthdays App Challenge set by Chalkboard

Chalkboard Birthdays App Challange This is an app that utilises a web api to provide the user an ordered list of birthdays youngest to oldest How to i

iOS NBA Challenge Based on Xcode 12.4, PR2S Project By: Oscar Pastás

iOS NBA Challenge Based on Xcode 12.4, PR2S Project By: Oscar Pastás iOS This test app consists of a list of users Considerations This test should be

Starter project for the iOS code challenge

iOS Base Project for Podium Take-Home Challenge Introduction We have provided two version of this base project: one using UIKit, one using SwiftUI. Th

Owner
Jan-Hendrik Matthes
Frontend/Mobile developer. Computer Science at Kiel University. Germany Scholarship holder. Interested in Swift, functional programming and web technologies.
Jan-Hendrik Matthes
Challenge-M2Y-TM4 - A challenge provided by Mobile2You, with the purpose of analyzing knowledge about UI, API consumption

Challenge-M2Y-TM4 Um desafio proporcionado pela Mobile2You, com proposito de ana

Felipe Brigagão de Almeida 0 Jan 31, 2022
TakeHomeChallenge - iOS Tech Challenge - Take Home Challenge

iOS Tech Challenge - Take Home Challenge Thank you for your interest in taking t

Michael 0 Feb 1, 2022
Application for iOS Applications Development, Autumn 2022

iOS2022AUT Application for iOS Applications Development, Autumn 2022, 41889/05 https://github.com/johnballauts/iOS2022AUT Team members: Name Student I

John Balla 1 Nov 3, 2022
[Accepted] My WWDC21 Swift Student Challenge submission

My WWDC21 Swift Student Challenge submission I made a playground book that teaches you the basics of ARKit through interactive lessons. It covers posi

Zheng 25 Nov 12, 2022
WWDC2020 Swift Student Challenge - TheHackOfRayTracing playground book

wwdc2021 My wwdc2021 submission The HackOf RayTracing How to run Install swift playground from App Store on your Mac or iPad Double clik TheHackOfRayT

haoboxuxu 20 May 20, 2022
[Accepted] My WWDC2021 Swift Student Challenge submission chosen as one of the 350 winners!

Genetic Algorithms | WWDC21 This project was entirely built with SwiftUI. To direct download this Playground and run it on your Mac or IPad, click he

Fred Lacis 2 Dec 22, 2021
My Winning Submission for Apple's WWDC 2021 Swift Student Challenge

Symmetries This playground book gives a quick insight into the symmetry groups of 3-dimensional objects like the platonic solids. The user can play ar

David 4 Apr 23, 2022
🎉 WWDC 2021 Swift Student Challenge Winner 🎉 Dance Party allows users to record choreography and play against other users to try and match the key poses!

?? Dance Party ?? ?? WWDC 2021 Swift Student Challenge Winner ?? Installation Steps (Works on iPad Only) Clone or Download Unzip the .playgroundbook.z

Alan Yan 7 Oct 17, 2022
The Feed API challenge with swift

The Feed API challenge - iOSLeadEssentials.com It's time to put your skills to the test! You are called to implement the RemoteFeedLoader to load a co

Andrew Marmion 0 Oct 28, 2021
Code Challenge - Using Alamofire is a Swift-based, HTTP networking library, also Codable for Data Model and Combine Framework .

Code Challenge ##Using Alamofire is a Swift-based, HTTP networking library, also Codable for Data Model and Combine Framework . Alamofire is one of th

Eng Angelo Saber 0 Nov 24, 2021