<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Steve Warren on Medium]]></title>
        <description><![CDATA[Stories by Steve Warren on Medium]]></description>
        <link>https://medium.com/@interactivenyc?source=rss-e4492468c139------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9zg11AmMM8Dcz0ib.jpg</url>
            <title>Stories by Steve Warren on Medium</title>
            <link>https://medium.com/@interactivenyc?source=rss-e4492468c139------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 03:05:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@interactivenyc/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Settlers of Catan]]></title>
            <link>https://medium.com/@interactivenyc/building-settlers-of-catan-11f11b93372c?source=rss-e4492468c139------2</link>
            <guid isPermaLink="false">https://medium.com/p/11f11b93372c</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Steve Warren]]></dc:creator>
            <pubDate>Mon, 26 Nov 2018 18:45:00 GMT</pubDate>
            <atom:updated>2018-11-26T18:45:00.679Z</atom:updated>
            <content:encoded><![CDATA[<p>While studying ReactJS at Fullstack Academy, towards the end of our program we had a Capstone Project to showcase the skills we had learned in their Software Development Immersive course. I was grouped with three other people, and we had to pick a project to build. We discussed several ideas, but wound up choosing a game — Settlers of Catan, as it presented some unique challenges in terms of handling a board comprised of hexagonal tiles, multiplayer interactivity and managing a complex game state.</p><p>Here I will describe the challenges we faced representing the game board model, and how we handled the visual display and data transfer between players.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*ujuRPOAWeZzSRLcubUmruA.png" /><figcaption>Settlers of Fullstack Game Board</figcaption></figure><p>Here’s a picture of a game in progress. Each game tile represents a Resource, each edge between tiles is a Road, and each vertex can be a Settlement or a City. We had to come up with a custom coordinate system for each type of object to track the data in our model, and target DOM elements on our HTML page for visual display.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*YxH0e6-6FextwCqbXpiPBw.png" /><figcaption>Coordinate System for Edges and Vertices</figcaption></figure><p>We came up with a system to track the three types of items with its own set of coordinates - Hexagons, Edges and Vertices are layed out in Rows and Columns from top to bottom and left to right. Each Hexagon maintains a list of which Edges and Vertices it’s connected to in order to easily process certain functions such as isValidMove().</p><p>Once the coordinate system was in place, we were able to handle the visual display by naming each DOM element according to its coordinate string value. These looked like: ‘1,1’, ‘1,2’, ‘1,3’… etc.</p><p>The data model uses three classes and a hash map that uses a key value the same as the coordinate string values used by the front end. We process each Hex, tracking it’s Edges and Vertices in an array. Because edges belong to up to 2 Hexes, and Vertices up to 3 Hexes, using a hash map avoids duplication by returning an object if it already exists, and if it doesn’t to create it and add it to the map.</p><p>Here are a few screenshots to clarify what our code looks like. First, there are the three types of objects with their properties — Resources, Edges and Vertices:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*NLRiX5ZWYjm0Jz83w9kEzw.png" /><figcaption>Resource Object contains references to Edges and Vertices</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*GGOEtdPPHtsHKx6gWMbD4Q.png" /><figcaption>Vertex Object has references to Edges and custom JSON function</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*cl_Oalw-nnjA2QBjqYWARw.png" /><figcaption>Edge Object has reference to Vertices and custom JSON function</figcaption></figure><p>With the way each Edge and Vertex adds itself to the hash table (board), when setting up our model we have helper functions to either get or create a new object as necessary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*6xyC8sEqGSCEG9DwKxLrYw.png" /></figure><p>Our Board object now is comprised of connected Resources, Edges and Vertices!</p><p>The next challenge was to pass the Board data around, as each player takes their turn, the board needs to be updated on the server and sent to the other players. We found that we couldn’t easily serialize the Board object and send it through a connection that would convert it into a text format. The objects and their relationships were not preserved. To solve this, we wrote custom toJSON functions which essentially broke all the connections we had created when the board was built. This allowed us to represent the Board with simple JSON. When an updated board is received by a Player, the board is run through a utility function that re-creates the relationships between the objects, as well as their new values such as which player controls the object, and what color should be used to represent it.</p><p>This game is still currently in development as of this writing, but you can download the code and run it yourself from Github at this URL:</p><p><a href="https://github.com/Interactive-NYC/Settlers-Of-Catan">Interactive-NYC/Settlers-Of-Catan</a></p><p>And to see the latest version of the game in action, you can visit our project deployed on Heroku at this URL:</p><p><a href="http://settlers-of-fullstack.herokuapp.com/">Settlers of Fullstack</a></p><p>Keep in mind that this is a student project in development. I will update this article in the future as we progress, and invite you to test our app when it’s finished. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11f11b93372c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>