Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (45 sloc) 1.66 KB
---
layout: post
title: 'A chess engine to improve my Golang-fu'
permalink: '/go-chess/'
tags: ['golang', 'chess', 'ai']
---
<div class="lead">
<p>
A short post about how writing a chess engine in Golang turned
out to be a fun way to improve my knowledge of the language.
</p>
</div>
<div class="section">
<p>
Over the years, I have had to write (and review) code in various
programming languages: perl, java, php, javascript, C++, ocaml,
python, etc. and most recently Go.
</p>
<p>
In general, programming languages are similar enough that I'm able to
hack on existing codebases without having to formally learn the
language. I gradually pick up language constructs and build an
understanding of things by looking at existing pieces of code. In most
cases, learning the language itself isn't the time consuming process,
it's the frameworks, tooling, libraries, etc.
</p>
<p>
Recently, a short exposure to Go left me wanting to learn more. I
decided to spend a few days writing a chess engine "just for fun".
</p>
<p>
After about 4 days and 900 lines of code, I had a working piece of code
that can solve chess puzzles. My engine handles the obscure en-passant
and castling rules (even though those aren't needed in most chess
puzzles).
</p>
<p>
I'm unsure if the code I have written is "idomatic", I however have
a much better understanding of Go. If you have a few days off, why don't
you pick an unfamiliar programming language and try the same experiment?
</p>
<p>
Feel free to check out the <a href="https://github.com/alokmenghrajani/go-chess">source code</a>.
</p>
</section>