<?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 Yerik K. on Medium]]></title>
        <description><![CDATA[Stories by Yerik K. on Medium]]></description>
        <link>https://medium.com/@yerik.koslowski?source=rss-ca77022490a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lP3jytoHq4G1sqCQ</url>
            <title>Stories by Yerik K. on Medium</title>
            <link>https://medium.com/@yerik.koslowski?source=rss-ca77022490a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 14:31:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yerik.koslowski/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[Making a Tutorial in under 3 minutes -WWDC23]]></title>
            <link>https://medium.com/apple-developer-academy-pucpr/making-a-tutorial-in-under-3-minutes-wwdc23-dc3ddd2c30bb?source=rss-ca77022490a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc3ddd2c30bb</guid>
            <category><![CDATA[games]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[wwdc23]]></category>
            <category><![CDATA[swift-student-challenge]]></category>
            <dc:creator><![CDATA[Yerik K.]]></dc:creator>
            <pubDate>Sat, 22 Apr 2023 21:13:45 GMT</pubDate>
            <atom:updated>2023-04-27T17:10:23.475Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello 👋. I am Yerik and I am taking part in the Swift Student Challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NAf-4G3SvccJaxFCIzBaOg.jpeg" /><figcaption>Me and my App</figcaption></figure><p>If you’re not aware what the Swift Student Challange is, according to Apple:</p><p>“Show us your passion for coding by submitting an incredible app playground on the topic of your choice. Winners will receive exclusive WWDC23 outerwear, AirPods Pro, a customized pin set, and one year of membership in the Apple Developer Program. In addition, we’ll hold a separate random selection process just for winners who opt in for the opportunity to attend the special event at Apple Park.” — Apple</p><p>To give you a better context about my app and why I had to make a tutorial, allow me to share some background on what I did. If you want a video version, you can check my Devlog series:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtYkQzaQiTvI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtYkQzaQiTvI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FtYkQzaQiTvI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c217b422b1c4d8afc318fdc7285ff33/href">https://medium.com/media/1c217b422b1c4d8afc318fdc7285ff33/href</a></iframe><p>My App Playground main goal is to help people learn about computational thinking, which is:<br>“We consider computational thinking to be the thought processes involved in formulating problems so their solutions can be represented as computational steps and algorithms.” — Alfred V. Aho, 2011</p><p>In order to achieve that, the App has puzzles in which the player has to “program” a ship to navigate through the obstacles and reach an objective. I won’t go into the details about the storytelling and why it’s a pirate ship since that is outside the scope of this article.</p><p>My main concern during development was: since the app is an educational tool/game, it must be easier to learn than the content it is trying to teach. I need my tutorial to be very easy to follow and once the player understands the basics, they’ll be able to venture in the more advanced levels. At the other hand, the Swift Student Challenge states that:<br>“[…] an App Playground that can be experienced within three minutes.” — Apple</p><p>We arrive then at the central topic of this article, how do you make a tutorial that teaches the player a complex topic in under 3 minutes?</p><p>I appologise if the title makes it sound like we’re building a tutorial in under 3 minutes, tutorials require a lot more thought and care than only 3 minutes.</p><p>The first step I took into making a tutorial was to design a starter level. In order to design it, you need to know what are the difficulties or obstacles in your game. Normally these obstacles are intended mechanics that you are already aware of.<br>In my App, the obstacles were:</p><ul><li>The instructions are relative to the ship’s current position and rotation</li><li>The player has to keep the ship state (position and rotation) in their memories while “programming”</li></ul><p>Both difficulties play into one another: The player has to keep in mind the ship state because the next instruction is relative to the current state.</p><p>The first level has to dial down all the difficulties. If you present the game hardest level for someone who has never played it before, they won’t have a fun and enjoyable time with it. Knowing the challenges my game presented, I knew that a good first level would:</p><ol><li>Keep the ship in the same orientation as the player</li><li>Keep the number of instructions low</li></ol><p>Both of these “guidelines” removed the difficulty from my game and allowed the player to focus in learning the interface.</p><p>Another important part of a first level is creating a safe environment for the player to learn. In my game, the only penalty in getting the instructions wrong is wasting time, so the first level has to be very quick to solve, diminishing the penalty. Even if the player gets it wrong, it’s a safe environment to experiment.</p><p>I came up with this design for the tutorial level</p><figure><img alt="An iPad with the screen divided in half. The left half has a 3D gameboard with some elements sitting on it, the right half has the Treasure Map Editor" src="https://cdn-images-1.medium.com/max/1024/1*YC__wAn34iu2TnU4VrBFCQ.png" /><figcaption>First prototype for the tutorial level</figcaption></figure><p>I placed the ship aligned at the bottom center of the board and the treasure chest is dead center, those places are likely where the players look over first. I also placed the obstacles in an Arrow-like shape but I can’t really tell if that made any difference in the tutorial.</p><p>At this point in time, I tested the App with 3 different players. 2 of them had a bit of previous knowledge about my game, one of them had no previous knowledge. What surprised me was that the results were almost identical regardless of that.</p><p>All players reported initial confusion when trying to solve the first puzzle. They claimed that they didn’t know what to do. I took some notes during their play session and I noticed that, althought they reported feeling confused, through exploration of the interface they were able to finish the first level.</p><p>With any iterative process, you gather feedback and then work to improve the weak points. So did I. With all my notes and feedback from the playtesters and mentors, I set out to make the interface a bit more intuitive.</p><p>My hypothesis is that there were the following causes to the confusion:</p><ol><li>The App went from storytelling straight to the Treasure Map Editor (programming screen)</li><li>The Editor buttons weren’t in intuitive places</li><li>Screen components were blending together</li></ol><p>My next step is to improve on these issues. Once again it’s important to remember the 3 minute limit, I can only add more steps to the tutorial as long as it’s still less than 3 minutes.</p><p>To tackle the first hypothesis, I added another text box. This box divided the screen in half so the player could only see the Editor half, reducing the amount of information they had to process at any time in the first level. Since the players understood the game through exploration of the interface, the text encouraged the player to try to press the buttons and see what happens.</p><p>While on the topic of buttons, I changed them. The buttons related to instructions were repositioned above the instruction list at the header and the button to run the level was moved to the bottom of the screen. This took advantage of the fact we read from top to bottom, this way the player will see the buttons on the screen at the order they will be used.</p><p>Finally for the screen components blending together, I did a color overhaul on the editor and color coded specific instructions. Green meant turn left, red meant going forward and blue meant turn right. Not only this color change helped players in the tutorial, they improved the overall editor use throughout the game.</p><p>Here is how the editor was looking after the first iteration:</p><figure><img alt="An iPad with the screen divided in half. The left half has a textbox, the right half has the Treasure Map Editor" src="https://cdn-images-1.medium.com/max/1024/1*tWatl3v6MKrwZ9Cd9l44bg.png" /><figcaption>The new text box</figcaption></figure><figure><img alt="An iPad with the screen divided in half. The left half has a 3D gameboard with some elements sitting on it, the right half has the Treasure Map Editor" src="https://cdn-images-1.medium.com/max/1024/1*r8atooLODOSBHvLRgIxSwA.png" /><figcaption>Color coding made a huge difference in the editor aesthetics</figcaption></figure><p>I tested with a few other players and these changes improved significantly how they performed. Players tried out the buttons and this led to faster understading of the core concept. But this round of testing showed a new problem that hadn’t surfaced yet. Players felt it was difficult to find the ship and the treasure on the board preview screen.</p><p>The way tackled this issue was adding a new text box to briefly hide the editor and allow the player to focus only on the board preview, and adding some visual elements to both the ship and the treasure chest. I added a shinny sparkle effect and while this helped, I also added a less subtle light in the first level. These effects had no real tie into the game and are probably the “weakest” solution, since they don’t blend in too well with the game theme, but they did get the job done. Another thing I added to improve visibility was a foam trail behind the ship.</p><figure><img alt="An iPad with the screen divided in half. The left half has a 3D gameboard with some elements sitting on it, the right half has a text box" src="https://cdn-images-1.medium.com/max/1024/1*GqjySx2dAuDwDLWKwR2T0w.png" /><figcaption>The light guided the player&#39;s sight into the ship and the treasure</figcaption></figure><p>This last iteration was finished a few days before the deadline for the Swift Student Challenge submissions so I didn&#39;t had enough time to properly test it. In the only test I was able to run, the player didn&#39;t report any confusion and I didn&#39;t notice any issue with them understanding the game concepts.</p><p>In parallel, I was also developing the game&#39;s second level</p><p>In the first level I removed all difficulty, so in the second level I had to increment the challenge. This game is a very simple example, but this applies to all other games: stacking mechanics is the best way of teaching them. By stacking your game mechanics, you reinforce what the player has already learned and you introduce something new that ties into what the player already knows.</p><p>Keeping this in mind, the second level had to teach the player how to turn the ship around. The first level only required a single “Move Forward” instruction, so by adding a second level with at least a “Turn Left” required, I&#39;d be certain that the player knows how to turn the ship once they get into the final level.</p><p>My first (and only) iteration of the second level was this:</p><figure><img alt="An iPad with the screen divided in half. The left half has a 3D gameboard with some elements sitting on it, the right half has the Treasure Map Editor" src="https://cdn-images-1.medium.com/max/1024/1*EBYkVTB3JIF3Kmck57TMkg.png" /><figcaption>The second level is very similar to the first</figcaption></figure><p>The first instruction is exactly the same as the last level. This is a way of stacking them, I&#39;m building the turn mechanic on top of the already established move forward mechanic.</p><p>After the required &quot;turn left&quot; instruction, the player is also required to move the ship forward 2 steps. This is done intentionally, to show the player that moving forward (and turning) is relative to where the ship is currently pointing. Finally having 2 “move forward” instructions give different results, reinforces to the player that all instructions are dependent on the current ship state.</p><p>This level had no other iterations because it worked flawlessly with the first level. While the first level had to teach the player how to use the interface, this one only had to teach about a single instruction.</p><p>So, how did the players perform?</p><p>Throughout testing I found out that these tutorials were very effective. Players who reported an initial confusion were able to complete the third level, which required 9 instructions to complete (3 times more than the second level).</p><p>Player didn&#39;t report any confusion on either the second or the third level, and most of them were able to complete it first try. The few players who didn&#39;t complete either of them in the first try had enough knowledge of the game mechanics to quickly figure out what went wrong and fix their “programming”.</p><p>This also highlighted another point which is not inherently part of the tutorial but is equally important. The game should give feedback on what the player is doing wrong. In my game this feedback comes visually through the AR Board, the player can follow the ship and see what they did wrong. Depending on how they failed, the interface also highlights the instruction that crashed the ship, giving them a better lead on what went wrong.</p><p>Here is a shortened version of all that I did to design the tutorial:</p><ol><li>Figure out what makes my game difficult</li><li>Create a first level that removes all the difficulty</li><li>Make this first level a safe environment (no punishment for getting it wrong)</li><li>Test it with players and take notes on how they perform</li><li>iteratively improve the level based on player behavior and how they react to the tutorial</li><li>Repeat for all the other tutorial levels, increasing the difficulty and stacking new mechanics with previously learned concepts</li></ol><p>Finally, if you wish to see my WWDC23 Submission, you can check it out on youtube:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFGGAY_MBKvA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFGGAY_MBKvA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFGGAY_MBKvA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2554bff2e4dce00e9175534256c114d7/href">https://medium.com/media/2554bff2e4dce00e9175534256c114d7/href</a></iframe><p>if you want to learn more about game tutorials, here are some great resources:</p><ol><li><a href="https://youtu.be/45csSEotJY8">https://youtu.be/45csSEotJY8</a></li><li><a href="https://youtu.be/MMggqenxuZc">https://youtu.be/MMggqenxuZc</a></li></ol><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc3ddd2c30bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apple-developer-academy-pucpr/making-a-tutorial-in-under-3-minutes-wwdc23-dc3ddd2c30bb">Making a Tutorial in under 3 minutes -WWDC23</a> was originally published in <a href="https://medium.com/apple-developer-academy-pucpr">Apple Developer Academy PUCPR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making a Chess AI in Golang]]></title>
            <link>https://medium.com/@yerik.koslowski/making-a-chess-ai-in-golang-601a1d8d472e?source=rss-ca77022490a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/601a1d8d472e</guid>
            <category><![CDATA[chess]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[university]]></category>
            <dc:creator><![CDATA[Yerik K.]]></dc:creator>
            <pubDate>Wed, 25 May 2022 20:56:29 GMT</pubDate>
            <atom:updated>2022-05-25T20:56:29.351Z</atom:updated>
            <content:encoded><![CDATA[<p>Chess programming is a fascinating topic. Earlier this year I was tasked with creating a chess AI for a competition in University. After 3 weeks in this wild ride I was able to finish eXtreme Go Chess and have a great time with it.</p><figure><img alt="Chessboard showing extreme go chess" src="https://cdn-images-1.medium.com/max/790/1*PjQt8t5dq8kB9K_OgUUQcQ.gif" /></figure><p>The AI plays with depth 5, but with iterative deepening it can reach up to depth 11. The competition had a few rules different than traditional chess:</p><ul><li>Each AI had 5 minutes to make a move</li><li>Pawns can only promote to queens</li></ul><h3>Move Generation</h3><p>The first step into making the AI was the move generation. Instead of calculating the moves at runtime, I decided to pre-compile all possible movements in a library:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1d84a7cede90cb71a173677be465d88/href">https://medium.com/media/d1d84a7cede90cb71a173677be465d88/href</a></iframe><p>The movement library is a one dimensional array in which each position is represented in a byte and each piece movement is aligned to a defined offset. The queen is the piece with the most movement options, with 8 diferent directions and at max 7 possible movements for each direction. This means that in 56 bytes (8 direction * 7 squares * 1 byte) we can represent all movements the queen can make from any given square. The first 56 bytes are all the possible movements a white pawn can make starting from A1 square (and since a white pawn can’t ever be at A1 it’s all zeros), the following 56 bytes are all the moves a white pawn can make starting from A2 square and so on.</p><p>In order to represent a position in a byte, the following method is used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/163/1*PS7y7zJ9KISEJfl0EQ2dhA.png" /></figure><p>Bits 1, 2 and 3 hold the Y position, bits 4, 5 and 6 hold the X position and bit 8 is a flag to represent a valid position, this way the position A1 is not equivalent to the number 0 but rather to 128. It’s important having 0 represent an invalid position since the movement data needs to be padded to 56 bytes.</p><p>While odd, this method allowed all possible movements to be registered, including castling. In a way having a dedicated move library also decouples part of the logic from other situational game rules (for instance <em>en passant</em> or whether a king can or cannot castle), which made easier to debug these specific rules and edge cases.</p><h3>Board</h3><p>The second part in the journey was making a playable board that I could interact and see what the engine was doing. I chose to make the board using ReactJS and make the interface between the board and the engine through web sockets, not UCI though since time was short and the engine needed only to talk to this board.</p><p>I used the library <em>chessboardjsx </em>to render the board and register callback for when pieces are moved around. The board state is stored in a React state variable called <em>boardPos, </em>this variable shifts between being a FEN string and a position object. The current engine evaluation for the board is stored in the <em>evalScore </em>react state<em>.</em></p><p>The functions for comunicating with the engine were all declared in it’s own module called <em>wsfunctions</em>.</p><p>On the board itself there is a callback function for when the player drags a piece around:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ae6df547e14ff6058b6c9c79d5e975b/href">https://medium.com/media/0ae6df547e14ff6058b6c9c79d5e975b/href</a></iframe><p>The function checks if the piece is being dropped at another square and in that case it moves the piece locally (not necessary but it provides better user experience with smoother transitions) and then it sends to the engine.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c5951bd3ed39a7ed4851a50638a3e15/href">https://medium.com/media/6c5951bd3ed39a7ed4851a50638a3e15/href</a></iframe><p>The <em>wsfunctions </em>module also listens to the engine messages and treat them accordingly: checking if the engine is sending a board evaluation, the checkmate, draw or stalemate signal or the new board position FEN.</p><p>For sending the movement to the engine, the following format is used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*-riu7cxER46YNFhhPWxZDQ.png" /></figure><p>All the move verification is done in the engine, the board front-end is only an interface.</p><h3>The Engine</h3><p>This was one of my first projects using Golang. While I like to think I did a decent job, I noticed in my code reviews after that the types and structures got messy. Being entirely honest, my code started out fine but due to time constrains my methodology ended up being <a href="https://medium.com/@dekaah/22-axioms-of-the-extreme-go-horse-methodology-xgh-9fa739ab55b4">eXtreme Go Horse</a> (thus the engine name). I’ll do my best to explain how the overall engine works, but since I entered low level territory the code might be hard to understand.</p><h4>Representing the Board</h4><p>There are various different way to represent a chessboard. The one I chose was keeping a list of all the pieces in the board with their position.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95d00028d3505b497bb9451b8aad8fcb/href">https://medium.com/media/95d00028d3505b497bb9451b8aad8fcb/href</a></iframe><p>The list has a length of 24. That’s for the 16 regular pieces and 8 promoted pieces. There are 2 <em>PieceMap </em>variables that hold what a pawn promoted to. The board also provide functions for loading FEN strings or generating FEN strings.</p><h4>Movement Validation</h4><p>The engine has 3 functions for making a movement: <em>MakeMove TestMove MakeUnsafeMove. MakeMove </em>and <em>TestMove</em> are essentially the same, the main difference is that <em>MakeMove</em> actually makes movement (alters board state) while <em>TestMove </em>returns a <em>PossibleMove </em>object without changing the board state</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34f4f886f83c57f8dd6c171b37713273/href">https://medium.com/media/34f4f886f83c57f8dd6c171b37713273/href</a></iframe><p><em>MakeUnsafeMove</em> applies a <em>PossibleMove</em> thus changing the board state. The main reason behind using 3 functions for movement is that the AI algorithm has to generate and test many different board states, so instead of holding thousands of Boards in memory, the algorithm can instead use a list of <em>PossibleMoves</em> which use way less memory (and are faster to generate).</p><p><em>MakeMove </em>holds all the special logic for pawn promotion, en passant capture, castle, checking if a move is legal. The function is too large to show here entirely but there’s one important part: using the movement library generated earlier.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7830c232ab3537bf27291d36ee100571/href">https://medium.com/media/7830c232ab3537bf27291d36ee100571/href</a></iframe><p>This code only allows the piece to move to valid locations and it prevents a move if another piece blocks the movement</p><h4>Minimax</h4><p>The Minimax algorithm is the core of the AI. It works by examining all possible moves a player can make to find the best one. The algorithm is recursive and goes on until it finds a winning/losing condition or it reaches a set depth or if your PC runs out of memory and overflows the stack. Keep in mind that the amount of boards the algorithm analizes are exponentially proportional to the depth.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d139763e59bb69320504cb85d258dc1/href">https://medium.com/media/0d139763e59bb69320504cb85d258dc1/href</a></iframe><h3>Conclusion</h3><p>Even with performance limitations and unoptimized code the engine was able to outperform me and every other human player at the tournament. I learned a lot about chess programming, about playing chess and about Golang. Due to the resources needed to run the AI I don’t currently have it hosted anywhere, but you can access the source code on my github:</p><p><a href="https://github.com/yrk06/chess-ai">GitHub - yrk06/chess-ai</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=601a1d8d472e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>