/
2015-08-02-go-chess.html
46 lines (45 loc) · 1.66 KB
/
2015-08-02-go-chess.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
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>