Part III: Move Generation - Level Up as a Software Engineer by Writing a Chess Engine

How does a computer think? It must know two things: what is possible and what is optimal. A chess move generation function calculates what is possible from a given position. An evaluation function determines what is optimal. Move generation is the marriage of these two capabilities and the focus of this article. A note about the evaluation function No computer can “see” to the end of a chess game but the engine still needs to find advantageous positions. This is why an evaluation function is necessary to score the approximate advantage of a position. ...

February 12, 2022 · 6 min

Part II: Data Structures - Level Up as a Software Engineer by Writing a Chess Engine

Internal board representation is a good place to start if you are building a chess engine. In other words, how will the program represent a chess position? Resolving this question correctly requires thinking through the entire solution before going to the keyboard. Naive Approach The naive approach is to simply look at the board and come up with a structure that can encode the information. For example, you might use an array of length 64, encoding the pieces as single characters. ...

February 4, 2022 · 9 min

Part I: Introduction - Level Up as a Software Engineer by Writing a Chess Engine

I’ve always learned better working on projects rather than reading theory. So, when I started to learn Golang I wanted to find a challenging project requiring a variety of software engineering concepts. I ended up writing a chess engine and it turned out to be more challenging than I had anticipated. It also greatly improved my skill in applying important software engineering concepts. I want to share the challenges that make chess programming such a great way to level up as a software engineer. ...

January 25, 2022 · 4 min

Thoughts on Growth: Taking risks vs playing it safe

This substack is about living the good life and indeed what exactly that means. This particular essay asserts that growth is requisite to living well. I don’t feel there is a need to defend this because it’s impossible to imagine life absent of growth from both physical and intellectual standpoints. Therefore, differences of opinion on this are a matter of degrees only. What do I mean by growth? At its core, growth is a reduction in the effort needed to achieve some goal. This reduction is achieved through broadening one’s horizon. Because I’m interested in how choices can improve one’s life, I am specifically focusing on intellectual growth, rather than physical. This is because physical growth is involuntary. ...

January 22, 2022 · 5 min

Implementing a Dynamic IP with Domain Hosted on DigitalOcean

In this article, I’ll provide a way to set up a dynamic IP address for your home server with DigitalOcean as the DNS. The article shows you how to monitor the server’s public IP address and dynamically update DigitalOcean records as needed. The article shows how to set up a script to run every hour via crontab and how to cache the previous IP address to avoid unnecessary API calls. ...

December 22, 2021 · 5 min

Part VII: Quick Reference

This guide is part seven of the series, X86–64 Assembly Language Program. This article is more of a reference guide for those learning x86–64 Assembly Language. I hope you find the information and links at the bottom helpful. Registers General-purpose registers — there are 16 general-purpose registers — rax, rbx, rcx, rdx, rbp, rsp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15 data- section is used for declaring initialized data or constants bss- section is used for declaring non initialized variables text- section is used for code rdi- first argument rsi- second argument rdx- third argument rcx- fourth argument r8- fifth argument r9- sixth The first six integer or pointer arguments are passed in registers rdi, rsi, rdx, rcx, r8, r9. r10 is used as a static chain pointer in the case of nested functions. ...

December 20, 2021 · 4 min

Tips and Tricks for using Crontab on Linux

Photo by Towfiqu barbhuiya on Unsplash Crontab is really useful but there are some gotchas. The following was all done on an Ubuntu Server. Results may vary on other distros. Setting up a Cron Job Just run crontab -e A file will open in your default editor with the first list commented out. These comments are useful. I’ve copied the first few here: # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task You end up adding a line that has a similar format to this: ...

November 29, 2021 · 3 min

Part VI: How to Determine String Length

This guide is part six of the series, X86–64 Assembly Language Program. How to Calculate String Length In order to calculate the length of a string, we’ll first need to know what determines the end of a given string. Strings in memory are represented as a pointer. The location pointed at is a byte of data representing a character followed by additional characters contiguous in memory. The important point is that this sequence of bytes is terminated by the byte 0x00. This is called the zero-termination character which is one method of terminating a string (C uses this approach, for example). There are methods of encoding strings that we won’t cover here. ...

November 28, 2021 · 3 min

Thoughts on Emotion

I was thinking about how to think about emotion and came up with a useful metaphor. Emotion is like the color of one’s life, but one chooses what picture to draw. Imagine an artist with an assortment of colors to work with but he draws the picture. One artist may have more blue, another more red, and yes, this does dictate (to some extent) the character of the drawing, but it does not at all dictate the content. ...

November 28, 2021 · 2 min

Part V: Conditionals, Jumping, and Looping

This guide is part five of the series, X86–64 Assembly Language Program. Conditionals and Looping Assembly language supports conditionally jumping to a specific line of the code. Looping is actually just a special implementation of jumping. It’s a jump to the beginning of the “loop” until some condition is finally met. Essentially this post is about writing conditional statements to branch one of two ways depending on some condition. The core conditional operator is cmp which is short for ‘compare’. The cmp operator compares two values and then sets some flags indicating the relation of the two values. Flags can be checked using some other operators, namely: ...

November 1, 2021 · 2 min