Reframing the Gluten Scanner

A lesson that every scientist (or any person in a fast-paced creative field) learns: be glad when we find out that our research idea has already been done.

The situation can be re-framed as follows:

  1. It’s awesome that there are others working just as hard as you to better the world.
  2. Reassurance that you’re not idiotic.
  3. You can now devote your precious time to developing your other projects.

I learned this lesson in 2011. After proving myself competent by assisting others in the lab (George Washington University Robotics Lab, Positronics Division), I was encouraged to pursue an independent research project using the PR2 as the research platform.
I excitedly came up with a list of ideas, then grew progressively more disappointed as I proceeded to research each idea further.
In the crowded lab, I said aloud, “It seems that almost every project I come up with has either already been proposed or wouldn’t be funded”.
To which the senior engineer in the lab (whom had not spoken to me before) responded, “Welcome to science!”.

Sidenote: I ended up programming the PR2 to autonomously navigate and complete a task using only force proprioception.

One of the main projects that I’ve been working on is a gluten scanner.

The scanner allows those with food allergies to avoid accidentally poisoning themselves. This is done in one of two ways:

Raman Spectroscopy Method

  • Identify the minima and maxima on the absorption spectrum of a given protein (currently gluten) with a 1D array of IR / Vis lasers and an Avalanche photodiode Si(c).
  • Perform differential data analysis to determine if the food is contaminated.

This scanner would be able to analyse the food ~>1cm in depth without effecting the food, whereas (if desired) taking a small sample out of the food at an opportune sampling point allows for deeper results.

Originally planning on taking spectroscopic approach, I found that it was incredibly noisy (see below) to detect gluten in a vinegar solution [gluten is insoluble in water], let alone amongst protein rich food!

Thank you, Sunnyvale Biocurious, for training Paul on the spectrophotometer!

Realizing the specificity of the antigen-binding sites on antibodies, I came up with the following biomarker approach to significantly increase the accuracy of my device.

Biomarker Method

Gluten is a protein composite of gliadin and glutenin (stuck together with a starch). G12 and A1 are antibodies that bind to gliadin (a highly immunotoxic 33-mer peptide).

Although A1 has a higher sensitivity to gluten (0.33ppm) than G12 (0.5ppm), most Celiac patients have a 20ppm poisoning threshold (far below both thresholds). G12 is far less expensive, and thus the better option for regular consumer use if you aren’t willing to synthesize your own antibodies in bulk.

Anti-gliadin antibodies can be paired with a colorimetric assay to form a biomarker-based detector in the form of: a toothpick-sized detector to poke into food || the gluten-detecting equivalent of litmus strips.

G12 (Image credit: PDB)

In the past few days, I found that there are a set of devices, GlutenTox, which use my planned approach. Since this realization, I’ve also come across 6sensorlabs, and the TellSpec.

It seems to me that these solutions are not cost-effective enough to be sustainable for daily use. This is likely because antibodies are expensive unless you bulk synthesize them.

Finding Routine in Freedom

I’ve just recently taken on a contract project. Adding that project onto my wheelchair and protein detector projects is a fun exercise in multi-threading that contributed to a recent realization.

After graduating and moving out to the Bay Area, I found myself missing the soft structure imposed by university. Two weeks ago, I finally developed an improved soft structure (independent from academia) to govern my time-expenditure.

It’s exciting to find a routine that works for me in an environment with many more degrees of freedom than I am accustomed to!

The schedule I’ve found is approximately:

08-09 Wake (Coffee)
09-10 Stretch, read papers, and sort todos 
10-11 Check email
11-12 Ab workout/Jog
12-18 Research
18-20 Climb/Bike
20-22 Blog/Research/Draw
22-24 Socialize and reflect on day (lessons learned, significant events and time allotment)

The lovely thing about this schedule is that I have no issue adjusting the time frames to suit my priorities that day. Life is a dynamic environment, but I’ve found most of my days fall into (at least) a permutation of this pattern. Having this structure to reflect on and shape my choices has noticeably increased my productivity and focus.

I hope you have a similar flexible schedule! It is a beautiful feeling to find routine in freedom.

Linux Laptop Environment Setup

I’m regularly asked about the setup of my laptop: a System76 Gazelle Professional named Felix running Ubuntu 14.04. Writing a return to that query produced the following:

Chromium Addons:

Pocket #Formerly Read It Later
GmailTeX #Gmail + LaTeX = GmailTeX
AdBlock [for YouTube] #Saves time
Session Buddy
HTTPS Everywhere
Incognito-Filter #Great for keeping,, etc. from hijacking web history
Hacker Vision #Save your eyes!
The Great Suspender #Suspends tabs not in use
What font? #satisfies curiosity
Wolfram Alpha
Chrome Downloads
Have I Downloaded This Before?
BetterTube #Optimize your YouTube experience

Get Flashplugin working on Chromium:

get adobe-flashplugin
#if that doesn't work, try:
sudo add-apt-repository "deb $(lsb_release -sc) partner"
sudo apt-get update && sudo apt-get install flashplugin-installer

Some of my favorite term aliases*:

alias up='sudo apt-get update && sudo apt-get upgrade'
alias meta='sudo vi ~/.bashrc'
alias rmeta='. ~/.bashrc'
alias sag='sudo apt-get'
alias cx='chmod +x'
alias purge='rm `find *~`'
alias ip='ifconfig | grep "inet addr:"| grep -v "" | cut -d: -f2 | awk "{ print $1}"'
alias get='sudo apt-get install'
alias matlab='matlab -glnx86'
alias p='python'
alias pipi='sudo pip install'
alias sim='cd ~/V-REP_PRO_EDU_V3_0_4_64_Linux/ && ./'

Python-based Research:

get python-pip #pip for managing packages
get build-essential liblapack-dev gfortran gcc g++ 
#Either the ATLAS or OpenBLAS implementation of BLAS. OpenBLAS is speedier but finnicky wrt multiprocessing.
get libatlas-dev libatlas3-base 
get libopenblas-dev
sudo easy_install -U distribute
pipi dev numpy scipy setuptools matplotlib
pipi nose #nicer testing
#Machine Learning
pipi -U scikit-learn
#Computer Vision
get gcc g++ cmake
#download latest opencv from #website
#untar it with
tar -xvf opencv-* #or
unzip opencv-*
#inside untarred folder make new folder call "r" (arbitrary name)
#run the following command in it
make install

A few choice packages/programs:

get guake #drop down term window - crazy useful (Sublime users: check this out)
get vim
get screen
get tex4ht #convert LaTeX to html
get chromium-browser #Preferred browser
get gparted #for managing partitions
get wine #Run (some) Windows on Linux
get haskell-platform
get vlc #My favorite multimedia plugin
get ipython #Bro, do you even Python?
get texmaker #LaTeX editor of choice (gedit plugin is also nice)
get openjdk-6-jre openjdk-7-jre #Open source Java platform
get geary #Alternative to thunderbird
get gwenview #crop pictures
get p7zip #extract *.7z files
get unrar #extract rar
get bleachbit #free your disk space
get libav-tools
sudo add-apt-repository ppa:samrog131/ppa
sudo apt-get update
get ffmpeg
cd ~ && wget -O - "" | tar xzf -
#broke grub?
sudo add-apt-repository ppa:yannubuntu/boot-repair
get -y boot-repair
boot-repair #run boot-repair after installation
#Be safe, use a proxy or VPN (more info)
get squid squid-common
#Note: If you are running 13.04, sudo service squid3 (start|stop|restart)
#evernote on linux
sudo add-apt-repository ppa:nvbn-rm/ppa
sudo apt-get update && sudo apt-get install everpad
#numlock activates at startup
sudo apt-get -y install numlockx
sudo sed -i 's|^exit 0.*$|# Numlock enablen[ -x /usr/bin/numlockx ] && numlockx onnnexit 0|' /etc/rc.local
For quick scripting, I use or IntelliJ IDEA or Sublime with vim command mode enabled. 
To enable control mode in Sublime Text 2: Find Preferences.sublime-settings 
Change the line "ignored_packages": ["Vintage"] to "ignored_packages": []. 
Restart Sublime: boom! Vim controls.
sudo apt-get remove gnome-screensaver
sudo apt-get install xscreensaver xscreensaver-data-extra xscreensaver-gl-extra
#Oracle(Sun) Java (docs)
cd ~/
wget -O
chmod +x
sudo ./
get sun-java6-jre
#VMWare Workstation
get compiz compizconfig-settings-manager compiz-fusion-plugins-extra compiz-fusion-plugins-main compiz-plugins
#matlab from cd
cd /media/MATLAB{version}
gksu ./install
sudo add-apt-repository ppa:irie/blender
sudo apt-get update
get blender
get myunity #Awesome control panel for unity
#Deprecated: get unity-tweak-tool 
#My free robotics simulator of choice, the educational version is free for all and available for OSX, Windows, 32 and 64bit Linux

*To edit your own cd && vim ~/.bashrc
After editing, refresh your bashrc with . ~/.bashrc. Now your aliases can be used! Huzzah!

Using a US Keyboard Layout to type in German? Lesen diesen Beitrag für deutsche Tastaturkürzel.

On Categories and Concepts: Hofstadter Talk

This is a summary of a talk I attended at Stanford by Douglas Hofstadter (well known for his authorship of Gödel, Escher, Bach: An Eternal Golden Braid).

He prefers lecturing without notes. I found it interesting/challenging to sort and summarize the main points of an improvised talk. Enjoy!

The label of a category can be anything from a conjunction to the essence of a situation

A paradigm for the situational label is Danny at the Grand Canyon.

Hofstadter’s family traveled to see the Grand Canyon. As Hofstadter turned his entranced gaze away from the great abyss, he rested his eyes on his son. His 1-year-old son, Danny, sat facing away from the Grand Canyon and staring at ants. He was a child so young that he had no idea of distance. This situation can be generalized to the idea of focusing on what you’re interested in (and are capable of focusing on), harboring little interest in what others consider as gems.

Similarly, idioms are categories:
Left hand doesn’t know what the right hand is doing \(\equiv\) One part of an organization is contradicting the other

Tail wagging a dog \(\equiv\) small things have inordinately large control over a situation.

Conjunctions (logical connectives) are categories:
The conjunction “/” (\(\equiv\) “slash”) is two things that aren’t quite exclusive combined together. Formally, let \(A\) and \(B\) be categories, a slash denotes \({A \cup B : A \cap B \neq \varnothing}\). For example: they’re a bimbo/self-marketing genius.

We may consider ourselves as each having a unique, private repertoire of categories (memories and thoughts)

We are a composition of public and private repertoires. The action of categorization is at the core of cognition. The difference between humans and other animals is the snowballing of categories; we continue to accrete categories to our repertoire through analogy.

These categories begin as a singleton: a set with one member. They evolve and blur into analogies as we add experiences to our private repertoires. This blurring may be coined as “pluralization”.

Reminders are analogies: unconscious thought pushed into consciousness by a situational queue.

The evolution of a category:
\\(\text{Singleton}\rightarrow\text{Superimposed idea}\rightarrow\text{Pluralization}\rightarrow\text{Label}\\)
He defines intelligence as the ability to put one’s finger on the essence of a situation rapidly. In other words, finding propelling analogies quickly.

Circumstances that evoke the choice of a category are extremely subtle

Without getting bogged down in examples, subtlety in is demonstrable in the difference between appropriate use-cases of “go to school” and “go to the school”.

  • “I have to stop by the school today to pick up my spectrometer.”
  • “Ender, you must go to school today.”

Many of cognitive science’s esoterics are bastardized versions of terms inherited from formal logic

In mathematics, predicate logic is an umbrella term for symbolic formal systems, informally, a predicate is a statement that is true or false depending on the values of its elements.

However, predicate calculus is “a general system of logic that accurately expresses a large variety of assertions and modes of reasoning”, capturing the essential logical structure of a complex idea independent of its elements.

The proposition Matvei loves Ubuntu can be represented by a predicate calculus in the form:

[Relationship between elements]([Subject element], [Object element])

However, a predicate calculus does not emit a yes or no. Likewise, category membership is not a boolean. Membership is fuzzy: the strength of membership is on a spectrum including central and peripheral membership of a given category.

Meaning is contextually dependent

The communication of ideas usually takes place through language: a stream of symbols flowing out of the mouth/fingers. Before symbolic exchange generates meaning, the situation must be explored and evaluated in the discourse space: a completely context dependent environment.

Sidenote: Hofstadter realized that meaning had a contextual dependence after he decided that his mathematically based notion that “all that matters in language is truth and falsehood” was incorrect.

Often, meaningful sounding questions are in fact meaningless due to ill-defined terms

When queried: How many languages do you know? He answers, “I’m \(\pi\)lingual”.

\(\pi\)lingual not in the sense that his knowledge of language is transcendental. Instead, \(\pi\) is the result of summing of pieces of languages he knows into blurred fractions.

Before the question is meaningful, the questions What does it mean to know? let alone What does it mean to know a language? must be addressed.

Is it an efficient way to equate the meaning of 2 sentences to represent a network of word-relationships as a weighted graph? Or is this a seemingly logical but meaningless question due to fuzzy definitions?

My question, left unanswered/as an exercise for the reader.

Cognitive Science: An Introduction to the Study of Mind Jay Friedenberg, Gordon Silverman

The Utility of Art vs. STEM

I was recently asked an interesting question in an interview:

You stated in a previous article that you believe math and science are “toolkits” to solving problems in ways that writing and the arts cannot. Can you elaborate on that?

I think science and art are two sides of the same coin. The distinction is quite fuzzy for the fields overlap in a variety of ways that depend on the perception of the viewer. For example, mathematicians find aesthetic beauty in eloquent proofs and concise equations. The main difference between the terms lies in what they contribute to the to the world. Art provides inspiration and science provides understanding and explicit utility. I specify “explicit utility” for implicitly, inspiration provides the driving force for scientific advancement.

Art enables us to describe every emotion and experience known to man, but mathematics enables us to understand the laws that govern everything. Art cannot show us something that is not a human experience, for it is limited by the person who uses it. Mathematics, on the other hand, can show as absolute truth realities too grand to be fully understood by the human mind while science allows us to precisely and repeatedly implement these truths in the physical world.

How Stockfish Works: An Evaluation of the Databases Behind the Top Open-Source Chess Engine

This is a paper I wrote my 3rd year of university as I was working on my Machine Learning-based Braille translator research. Enjoy!


Playing chess has been on the forefront of AI research since Alan Turing and his students proposed chess playing machines. The game of chess is a domain of human thought where very limited sets of rules yield inexhaustible depths, challenges, frustration and beauty. The playing strategies of AI and human players have diverged proportional to the increase of available computing power, namely speed and storage space.
Human players recognize and aim to achieve particular patterns; typically, they perform a deep search weighted towards moves that lead to such desired patterns, transferring past knowledge and adapting it to their present situation. AI chess is mostly played by parsing through a huge database, with broad search algorithms used to search for the next optimal move.

All chess engines work by looking at a heuristically determined subset of the legal moves stemming from a given position and evaluating numbers to represent the new position’s relative value obtained by making those moves; then, recursively doing the same thing for the resulting positions. This is done using an evaluation function. An efficient evaluation function provides a better toolbox to guide the chess tree search, which improves the strength and speed of the AI player.

Stockfish is the top-ranked open-source chess engine, and I will be evaluating its elaborate use of databases; in particular, how Stockfish represents the state of the chessboard, evaluates the static board positions, uses its search algorithm, and uses past moves to optimize its next move.
Keywords: Chess, AI Chess, Search Techniques, Chess algorithms, Databases, Alpha-Beta Pruning, Stockfish, Stockfish 2.3.1


Application Domain

It is important to distinguish between computer chess research and research using chess as a test bed. The latter expands the user community past chess enthusiasts to AI developers. In AI, the real-time evaluation and categorization of a dynamic environment is crucial to maintaining functionality while performing a task. This environment can be categorized using preset labels and rules or adapted to based purely on experience. Stockfish’s evaluation of chess positions, based not only on material properties (i.e., “I have more pieces than you”) but on the relationships and structures that exist between said material (i.e., “My piece is protected by two other pieces, and is threatening your unprotected piece.”), is useful in the domain of autonomous systems which must quickly evaluate the stability of groups of objects interacting within set rules.

Project Motivation

The narrow view of this project’s motivation is to improve the strength of AI chess players. This engine’s effectiveness depends on proper tagging, passing, evaluating, and searching of chess positions.

The main issues faced by AI chess players are:

  • Storing and evaluating data efficiently
  • Proceeding with the recursive search of moves

For most chess positions, computers cannot look ahead to all final possible positions. Instead, they must look ahead a few plies (a “ply” refers to one turn taken by one of the players. “Turn” is problematic since it means different things in different traditions. For example, in standard chess terminology, one move consists of a turn by each player; therefore a ply in chess is a half-move.) and then evaluate the final board position. The algorithm that evaluates final board positions is the evaluation function, which differs between different chess engines.

While the human method of analyzing alternatives seems to involve selecting a few promising lines of play and exploring them, computers are necessarily exhaustive rather than selective, so refinement techniques have been (and continue to be) developed.

Stockfish uses a complicated set of analysis functions depending on what material is on the board. By applying small changes and refinements (i.e. using categorical analysis) to alpha-beta pruning, there is a measurable difference in the time efficiency of pruning, without disregarding interesting nodes. Stockfish continues to expand as additions and tweaks are added by various developers.
Science Usage
The user requirements for Stockfish are mercifully little, for it is an open-source cross-platform engine. The only pre-requisites to using Stockfish are downloading the source code from their website. It may be run from the commandline or a UCI-Compatible GUI.


The ultimate goal of Stockfish is to unite the chess-program-developer community, and continue to a build stronger, faster chess engine.
This includes, among other things, a goal to improve the effectiveness of search evaluations. By creating an efficient board representation, this provides a better toolbox to guide the chess tree search, which improves the AI.

Alpha-beta pruning is just a complicated-sounding name for “Don’t check moves which cannot possibly have an effect on the outcome of your search.” The alpha-beta algorithm used in recursive search continues be improved. These enhancements come from the fact that if you restrict the window of scores that are interesting, you can achieve more cutoffs. The latest technique of move ordering is applied outside of the search, using iterative deepening boosted by a transposition table.


Stockfish has clearly demonstrated that simple, brute-force approaches should not be quickly discarded. Additionally, iterative techniques, in particular, ideas developed for alpha-beta search and iterative deepening, are applicable to other search domains. Stockfish has clearly demonstrated the inadequacy of conventional AI techniques for real-time computation. Stockfish does not use AI languages or knowledge representation methods, for these conventions are too slow for a real-time, high-performance application.

I have found that Stockfish represents the state of the chessboard using bitboards, it evaluates the static board positions using a categorical and statistical representation and uses an advanced alpha-beta search algorithm. In order to not analyze the same position several times, a transposition table is used. This is essentially memorization applied to the search function.

Design and Schema

The design of Stockfish is based on the interaction of various nodes (pictured in Schema).

A move search in Stockfish consists of 21 steps.

Step 1. Initialize node

Step 2. Check for aborted search and immediate draw. Enforce node limit here. (This only works with 1 search thread, as of Stockfish 2.3.1.)

Step 3. Mate distance pruning. Even if we mate at the next move our score would be at best mate_in (\(\text{ss}\rightarrow\text{ply}+1\)), but if alpha is already bigger because a shorter mate was found upward in the tree then there is no need to search further, we will never beat current alpha. Same logic but with reversed signs applies also in the opposite condition of being mated instead of giving mate, in this case return a fail-high score.

Step 4. Transposition table lookup. We don’t want the score of a partial search to overwrite a previous full search. We use a different position key in case of an excluded move.

Step 5. Evaluate the position statically and update parent’s gain statistics

Step 6. Razoring (is omitted in PV nodes)

Step 7. Static null move pruning (is omitted in PV nodes). We’re betting that the opponent doesn’t have a move that will reduce the score by more than futility-margin (depth) if we do a null move.

Step 8. Null move search with verification search

Step 9. ProbCut. If we have a very good capture and a reduced search returns a value much above beta, we can (almost) safely prune the previous move.

Step 10. Internal iterative deepening.

Step 11. Loop through moves. Loop through all pseudo-legal moves until no moves remain or a beta cutoff occurs

Step 12. Extend checks and also dangerous moves

13. Futility pruning.

Step 14. Make the move

Step 15. Reduced depth search (LMR). If the move fails high will be re-searched at full depth.

Step 16. Full depth search, when LMR is skipped or fails high.

Step 17. Undo move

Step 18. Check for new best move

Step 19. Check for split

Step 20. Check for mate and stalemate

Step 21. Update tables. Update transposition table entry, killers and history

Stockfish begins by developing a legal-move tree, whence it must evaluate the resulting board positions. That is, the computer has to look at the pieces on the board and decide whether that arrangement of pieces is “good” or “bad.” The way it does this is by using an evaluation function. Since it is so important to evaluate the best move first, it might be worthwhile to execute a shallower search first and then use the resulting alpha/beta cutoff values as start values for a deeper search.

The chess evaluation function becomes more and more complicated by adding things like board position, control of the center, vulnerability of the king to check, vulnerability of the opponent’s queen, and tons of other parameters. No matter how complicated the function gets, however, it is condensed down to a single number that represents the “goodness” of that board position.

The main rules that govern the evaluation of position in Stockfish are as follows.

Pawn Structure

  1. Penalize doubled, backward and blocked pawns.
  2. Encourage pawn advancement where adequately defended.
  3. Encourage control of the center of the board.

Piece Placement

  1. Encourage knights to occupy the center of the board.
  2. Encourage queens and rooks to defend each other and attack.
  3. Encourage 7th rank attacks for rooks.

Passed Pawns

  1. These deserve a special treatment as they are so important.
  2. Check for safety from opposing king and enemy pieces.
  3. Add enormous incentives for passed pawns near promotion.

King Safety

  1. Encourage the king to stay to the corner in the middlegame.
  2. Try to retain and effective pawn shield.
  3. Try to stop enemy pieces from getting near to the king.

The same position will commonly occur from different move orders, thus most chess engines (including Stockfish) have a trasposition table (position cache). This is implemented using a hash table using the chess position as its key. Using a position cache instead of a hash table negates the need to evaluate large sub trees over and over again.

Alpha-beta pruning, without enhancements nor extensions, is represented in psuedo-Python below.

def alphaBetaMax (alpha, beta, depthleft):
   if (depthleft == 0): return evaluate()
   for (all moves):
      score = alphaBetaMin(alpha, beta, depthleft - 1 )
      if( score >= beta):
         return beta   #fail hard beta-cutoff
      if( score > alpha ):
         alpha = score #alpha acts like max in MiniMax
   return alpha
def alphaBetaMin(alpha, beta, depthleft )
   if ( depthleft == 0): return -evaluate()
   for (all moves):
      score = alphaBetaMax( alpha, beta, depthleft - 1 )
      if( score <= alpha ):
         return alpha #fail hard alpha-cutoff
      if( score < beta ):
         beta = score  # beta acts like min in MiniMax
   return beta
score = alphaBetaMax(-oo, +oo, depth)
print score

This schema shows the input with the current position, and ends with the next move, in order to avoid over-powering the simple nature of Stockfish by showing both method names and method parameters, I have created a representation of the overall use of databases in Stockfish.

The relationship of principle structures in the main database (governed by search.cpp)

Contents of Database

The contents of a typical chess engine database is past moves (moves that have been done in the past, very useful for the opening game), current moves (moves that are legal from a chess board’s current position), and legal moves (rules governing the movement of each type of chess piece). Stockfish uses bitboard representation. Bitboards are a wonderful method of speeding up various operations on chessboards by representing the board by a set of 64 bit numbers.

A brief explanation of Bitboards is as follows: Supposing, for example, we generate a 64 bit number which represents the pawn structure on the chess board. We do this by starting at a8, and moving across then down in the sense a8,b8,c8,…,h8,a7,b7,c7,…,g1,h1. For each square, we put a ‘1’ if there is a pawn, or a ‘0’ otherwise. Then we have just one number on which we can perform all sorts of useful operations. Once we have a bitboard with all the possible destination squares set to ‘1’, we now have to cycle through them one by one. To do this, we require two routines. Firstly we require a routine which locates the position of the first bit in the bitboard which is set, and secondly we need a simple macro which then sets this bit to zero.

10 Questions

Any chess player, human or AI, must answer the following question: What is the “best” move I can make next?. This answer is highly subjective, and depends entirely on what constitutes a “good” position. As humans, we easily recognize patterns, apply our past experience to current games, and use our intuition to judge the quality of play. However, a chess evaluator must find the strength of possible positions in a mechanical way, using a set of parameters (similar to the following questions) to describe and evaluate the strength of a given position.

Query 1) What is the position of all pieces on the board?

Query 2) What legal moves can each piece make from this position?

Query 3) What are relationships between pieces on the board? Are structures threatened or pieces undefended?

Query 4) Is there a strong pawn structure and effective pawn shield?

Query 5) Is the King mobile, well protected, and not in check?

Query 6) Is the center of the board occupied?

Query 7) Are any major pieces blocked?

Query 8) Are there passed pawns near promotion?

Query 9) Are bishops occupying major diagonals?

Query 10) What is the material difference between players?

After these 10 questions have been answered, the chess evaluator can score a position, and feed this score into the chess tree to optimize the \(\alpha-\beta\) pruning that follows.

Algebraic Chess Notation

Symbol Meaning
a-h file from white’s left to right
1-8 rank from white to black
R, N, B/S, Q, K Rook, Knight, Bishop, Queen, King
x capture; the piece that was at this location is removed
+ a note that the king is threatened
# or ++ checkmate; a note that this is the reason for the end of the game
= promoted to; a pawn arriving at the opposite side of the board is promoted to another piece, often a queen.
0-0 castle on the kings side; move to positions (B – Kg8 Rf8 ; W – Kf1 Rg1) (if neither has moved before this point in the game)
0-0-0 castle on the queens side; (B – Kd8 Rc8 ; W – Kc1 Rd1) (if neither has moved before this point in the game)
e.p. en passant capture (non-SAN), a note that a pawn was taken by another pawn passing it. When a pawns first move is a two space move (from 7 to 5 for black or 2 to 4 for white) it can be captured by moving behind it to the 6th rank (white taking black) or 3rd rank (black taking white).
?, ??, !, !! editorial comments, weak, very weak, strong, very strong
Coordinates in Algebraic Chess Notation

Readers are encouraged to explore additional background information provided by the online book Building Skills in Python.


  1. H. Nasreddine and H. S. Poh, “Using an evolutionary algorithm for the tuning of a chess evaluation function based on a dynamic boundary strategy”, 2005.
  2. J. S. T. Anthony Marsland, Feng-hsiung Hsu and D. E. Wilkins, “The role of chess in artificial intelligence research”,
  3. M. Strejczek, “Some aspects of chess programming”,
  4. Wikipedia, “Ply(game theory)”,
  5. T. Romstad, M. Costalba, J. Kiiski, D. Yang, S. Spitaleri, and J. Albett, “Stockfish about,”
  6. O. David-Tabibi, M. Koppel, and N. S. Netanyahu, “Optimizing selective search in chess”,
  7. T. Anantharaman, M. S. Campbell, and F. hsiung Hsu, “Singular extensions: Adding selectivity to brute-force searching”, Artificial Intelligence , pp. 99–109, 1990.
  8. I. Chernev, Logical Chess, Move By Move – Only Chess Book That Explains Every Move Of Every Game, 1957.
  9. D. Levy and M. Newborn, How Computers Play Chess,, Computer Science Press, New York, 1990.
  10. C. Frayn, “Computer chess programming theory”, 2005.

College, Would You Like Fries With That?

I enjoy songwriting and have recently gotten into playing Third-Wave ska on my trombone. The basic premise of ska is to play an incredibly upbeat tune with shocking/macabre lyrics.

Here are the lyrics to a silly ska song I wrote in class. Note that I’m happy with my university experience; this song presents the point that university isn’t for everyone.

College? Would you like fries with that? by Catherine Ray

You’ll struggle through your classes, and they’ll let you out of school
Clutching a degree you’ve wasted your life to get, you fool
Up next, the corporate overlords will laugh and watch you squirm
They’ll lead you on in interviews, in the end you’ll just be spurned
Run with your tail between your legs,
maybe McDonald’s will accept your unskilled naivete.
Life has revealed its disguise
Yell, “I wish I’d Realized!”

Writing insightful term papers on the Third Reich,
you never thought you’d be one of those guys who quit their work on strike
First you paid thousands just to go to lectures and to class
All of that money and time, for 9 to 5, for a chair and a cubicle, to sit on your ass
The next 20 years consist of watching TV and arduous jobs, paying off your student loans
Working over time for mortgage, so you can pay for your worthless home
After work, go to the mirror.
Just look yourself in the eyes,
Yell. “I wish I’d realized!”

The goal of college isn’t to simply earn a scroll and a title
Get something concrete from it – a job, a pay raise, a promotion
Look back now – Clearly you’ll see, your only profit was debt and negative emotion.
Listen up, my friend Getting some degree
won’t cement your name in most minds, surroundings, nor history
Education is awesome for your outlook on life, real life experience is the fastest way.
The assumption that education must be IRL – Get used to living in meatspace
Be an autodidact, it can’t be all that hard.
Get out your laptop, a pen and some flashcards
Learn a language, free eBooks, a chapter, or if you’re lazy, a word a day
All along there was Wikipedia, free online courses, to your dismay
It’s too late for you – unless, you’re a chrononaut
Life ain’t something you can revise.
Yell. “I wish I’d realized!”

Song Recommendations

Arbeit macht das Leben süß

Above is the link to my current collection of unsorted work songs. The playlist is named after a German idiom which literally translates to “Work makes life sweet” (a belief I hold dear).

I suggest listening on shuffle. Enjoy! I’m always open to song recommendations!

Sidenote: As stated in my song “I Write Poetry In Python” : “Put the period outside of the quotes! You’re not quoting the end of the sentence”. This is a grammatical rule which I attempt to consistently implement. Apologies for the discomfort caused to those of differing grammatical views.