Git Product home page Git Product logo

fourinarow's Introduction

FourInARow: Using the GameplayKit Minmax Strategist for Opponent AI

This sample demonstrates how to use the GKMinmaxStrategist class to implement a computer-controlled opponent for turn-based, adversarial games. As part of this demonstration, the sample shows how to structure gameplay model code for use with the minmax strategist using the GKGameModel protocol and related APIs.

Playing the Game

Tap in a column to drop a chip of your color there. (Red moves first, Black moves second.) Get four chips in a row -- horizontally, vertically, or diagonally -- to win.

Building a Game Model

This project builds a game in stages:

  1. The AAPLBoard and AAPLPlayer classes implement a generic model for a Four-In-A-Row game. Use the FourInARowTests unit test case to exercise the generic game model.
  2. The AAPLViewController class adds a UI for playing the game on an iOS device. With the USE_AI_PLAYER macro left undefined, the game is for two human players.
  3. The classes and categories in AAPLMinmaxStrategy.h and AAPLMinmaxStrategy.m extend the generic game model to support using GameplayKit for opponent AI.
  4. With the USE_AI_PLAYER macro defined, the AAPLViewController class replaces user control for the second player (black chips) with an AI opponent using the GKMinmaxStrategist class.

For a more thorough discussion of this project, see the chapter "The Minmax Strategist" in GameplayKit Programming Guide.

Requirements

Build

Xcode 7.0, iOS 9.0

Runtime

iOS 9.0

Copyright (C) 2015 Apple Inc. All rights reserved.

fourinarow's People

Contributors

imjerrybao avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.