Here's a simple program that allows you to play the classic game of Twenty Questions in Swift. This program asks the user to think of an object, and then asks up to 20 yes-or-no questions in order to guess what the object is.
main.swift2727 chars83 lines
This is just a simplified version of the game, but you can make it more complex by adding more questions and more elaborate decision-making rules.
gistlibby LogSnag