Category Archives: Swift

Creating Tic-tac-toe in Swift: Artificial intelligence

This blog post is the second update about my Tic-tac-toe game, being written in Swift. The source code is available on GitHub: https://github.com/ijoshsmith/swift-tic-tac-toe Over the past week I wrote an intelligent agent which implements the Tic-tac-toe strategy devised by Allen Newell and … Continue reading

Posted in Swift, Tic-tac-toe, Uncategorized | Tagged , | 1 Comment

Creating Tic-tac-toe in Swift: Gameplay and data model

This blog post is an update on my work-in-progress Tic-tac-toe game, being written in Swift. The source code is available on GitHub: https://github.com/ijoshsmith/swift-tic-tac-toe I’ve reached the first major milestone. The program is capable of playing Tic-tac-toe against itself, although there … Continue reading

Posted in Swift, Tic-tac-toe | Tagged , | 1 Comment

Creating Tic-tac-toe in Swift

Normally I blog about a program I’ve already written. I decided this time to take a different approach, and blog about a Tic-tac-toe program that I’m writing instead. This will give people who are interested in watching a Swift program evolve over … Continue reading

Posted in Swift, Tic-tac-toe | Tagged , | 3 Comments

Compressing a Swift array

Suppose you have an array of values in your Swift app and you need to compress it to a smaller size, with the intention of making it occupy less memory. If the array contains many consecutive repeated values it could be … Continue reading

Posted in Swift | Tagged | 1 Comment

Creating ASCII art in functional Swift

This article explores an iOS app, written in a functional Swift style, that converts an image to ASCII art. For example, when given the famous Lenna photograph… …it creates a string that, when printed, looks something like this… Zooming into … Continue reading

Posted in Swift | Tagged , | 5 Comments

Caesar cipher in Swift

I posted a Swift project to GitHub that implements the Caesar cipher, which was the encryption technique used to protect Julius Caesar’s personal correspondence. It’s a straightforward algorithm that maps each letter in the alphabet to another letter. The code also … Continue reading

Posted in Swift | Tagged , | 2 Comments

Getting into functional programming with Swift

This article examines two implementations of a logic puzzle written in Swift. The first example uses an imperative programming style, which is the style familiar to most iOS developers. Then we see the same small program written in a functional style, which is … Continue reading

Posted in Swift | Tagged , | 12 Comments