• En
  • /
  • Jp
  • Chess Go

    2017.11.28
    • Share
    • Twitter
    • Google+
    • はてなブックマーク
    Introduction

    My name is Vic Villanueva of COMMUDE Philippines,
    and one of my tasks at COMMUDE is to look into current technologies and techniques involved into augmented reality (AR), to see how it could serve our customers and to prototype the ideas of the creative minds inside the company.

    Having a iOS Development background I’m not a game developer at a professional level, however having used a Unity3D, following closely the world of game development since college and sometimes participating in it, I have some knowledge about the tools involved in the process, so this was an opportunity for both the company and me to explore the topic a bit further.

    Contents:


    Today I will be introducing the Chess Go App developed by our company, COMMUDE PHILIPPINES, INC.In this short topic, we will be discussing the following items:

    Introduction to Chess Go


               Chess Go is an iOS game that allows a player to play a live chess match against another player within his area. Chess Go utilizes modern frameworks namely iOS’s CoreLocation, SceneKit, ARKit, Firebase, GeoFirebase etc. Players would be able to see available opponents within his area and vice-versa, and play against them. In displaying the 3D chess board and pieces, Chess Go utilizes one of the latest frameworks in iOS 11 which is ARKit for devices that can support Augmented Reality, and SceneKit for devices that doesn’t support Augmented Reality.

    In this article, we will be discussing in the implementations for login, mapping players via CoreLocation,seeking and engaging a match, leveling up, displaying 3D objects using ARKit / SceneKit, idle timer, and calculations for possible moves.

    Login

               Chess Go utilizes Firebase as its back-end server. On launch, Chess Go would attempt to login. If there is no cached player, then the player would be prompted to login. In this scene, player may login using an existing account or register for a new one. During registration, players may select a custom image that would serve as his/her avatar. The data would be stored using Firebase’s secured register API.

    For now we’ll focus on Mappin Players.

    Mapping Players

               Once the player is logged in, we use GeoFirebase in determining players’s location. By utilizing iOS’s CoreLocation framework, we would be able to identify the current player’s coordinates. The captured coordinates are submitted to GeoFirebase as reference and are being updated every x seconds. We then use GeoFirebase to get other players’ coordinates within the radius of the current player. With this information available to us, we can map out the players.

    Seeking and Engaging a match

               Players may press on the Start button to start seeking match. This would change the state of the player in our Firebase. If the player is seeking match, an indicator will appear that is also visible to other players. This informs the other players that the specified player is seeking a match then the other players could challenge the seeking player by tapping his/her avatar. Concurrency is an issue here when multiple challengers tap the avatar of the seeking player at the same time. To handle it, we utilized Firebase’s transaction API so that the first challenger would be playing against the seeking player. But before really starting, we had to chose both the hardware and the software we’d use.

    Leveling Up

              Players level up as they accumulate wins. Each level has a required number of wins for the player to moved up on the next level. As of now a player can only view his own profile where he can see the results of his previous games, whether its a win, draw, or a loss.


    Displaying 3D objects using ARKit / SceneKit

               ARKit is one of the latest technologies that Apple released and is one of the core features of Chess Go. For ARKit to be supported, the iOS device must either have an A9, A10, or A11 chip. At the time of this writing, the following are the current devices that have these said technologies:

    • iPhone SE
    • iPhone 6 and 6s Plus
    • iPhone 7 and 7 Plus
    • iPhone 8 and 8 Plus
    • iPhone X
    • iPad Pro (9.7, 10.5, or 12.9) – both first-gen and second-gen
    • iPad (2017)

    •           If the device doesn’t support ARKit, the framework utilized to display the 3D objects is SceneKit which has a minimum iOS version requirement of iOS 8.


                One of the main differences between these two frameworks is that in ARKit, 3D models are placed in a space and will remain stationary unless changed. So, if the player moves the camera away from the 3D object, the 3D object would remain there. In SceneKit, the 3D models move in relation to the device. If the 3D object is in the middle of the screen, even if the phone moves, the 3D object would still remain in the middle of the screen. Due to this, we added another feature to switch between the two modes, AR and non-AR modes. If the device doesn’t support ARKit, the player won’t be able to switch between the two. Otherwise, the player could switch between the two. An example usage of this is, a player who initially preferred to play using AR mode then has to go on transit. By switching to non-AR mode, the player could still continue playing then if he prefers to use AR mode again, he could do so.



      More info about ARKit:https://developer.apple.com/arkit/
      Chess Go on App Store:https://itunes.apple.com/ph/app/chess-go/id1296171727?mt=8

    Idle Timer

              To handle idle players, each player is given x minutes to make a move. If he/she doesn’t, then the said player would lose. There are different ways to handle idle players like by having the mechanism like the chess clocks have. But for the first version of Chess Go, this is how it is handled.

    Calculations for possible moves

              A piece’s possible moves calculation comprises several steps. First, we need to tackle about a property of chess squares. Chess squares store a reference to its adjacent squares. In other words, a chess square has a reference to the chess square on its right, left, top, bottom, top right, top left, bottom right, and bottom left. So once a piece is selected, calculations are initiated. The following are the steps to calculate the move of a chess piece.

    1. Check whether the piece is owner by the player who selected it.

    2. Depending on the piece, the neighbour cells are then determined except for a knight piece. For example, if a black pawn is selected the neighbour cells at bottom are checked. Special cases have to be checked as well for capture and en passant. For bishops, top left, top right, bottom left, and bottom right are check until it is the edge square or there is a piece occupying the cell. And if there is a piece occupying the cell, it is checked whether opponent’s piece. If it is, then it is added as a possible move. Below is a screenshot of possible moves for a bishop.


    Ending

              Chess Go utilizes latest technologies made available by iOS and Firebase allowing for players to play 3D chess real-time. There are areas for improvement to be made for future releases like a better management for idle player, ranking system, match making process, additional database security, etc. For now, enjoy playing against opponents and friends with the latest iOS framework ARKit!


    Download Chess Go on App Store:https://itunes.apple.com/ph/app/chess-go/id1296171727?mt=8
    to be continued…