The Stone Wall at Tagamore Swamp
Posted November 2, 2009 04:00:49 AM by emarcarelli

I wrote this poem yesterday morning:

No tame trail leads one there
Through wild rye and tangled brier,
Over paths unworn,
To the old stone wall
That weathers all.
A remnant of lost triumph;
The artifact of forgotten struggle.
When leaves ate wood
And thatch wore to soil,
Crops to seed,
And stock to feral,
It stood there still:
The old stone wall
That weathers all.



Chess AI Project
Posted May 10, 2009 12:51:08 PM by emarcarelli



This is a chess project I created for my artificial intelligence class. The program is capable of playing through a full game of chess. The human player takes the side of white, and the computer will respond with black's moves. The game can look an arbitrary number of moves (plies) into the future to select the best move. It uses four plies by default and takes between 10 and 90 seconds to make a move depending on the complexity of the current position. The game is written in C++ using SDL for graphics, and there are versions available for Windows and Linux.

Each state represents a single position of the board. Each state is linked to two other states: the next possible move on the current ply, and a state that represents the beginning of a list of all the possible moves the other player can make in response to that position. Together, these states form a game tree that can be searched to find the best state within a certain number of plies and determine which move is necessary to get to that state.

A rating system is used to compare states. It is based off of the generally accepted relative values of the pieces: pawn=100, bishop=300, knight=300, rook=500, and queen=900. The king has a value of 400 for its attack and defense capabilities, but cannot be captured. As moves are generated, an array is created that keeps track of which spaces are threatened by each piece. This array is used to determine whether each piece is threatened, defended, or neutral.

To determine how to modify each piece's value I began with a few guesses, and then played over and over, tweaking the system to make it select better moves. I eventually settled on the following system. A threatened piece is only worth 20% of its value, while a defended piece is worth 30% more. A piece in the center is worth 20% more. A pawn gets 50 points for each row it advances, and pawns are only reduced to 40% if they are threatened. Black's pieces are valued positively and white's are valued negatively. A state's final score is the sum of all of the values of the pieces of both players. If a state represents checkmate, it is given an arbitrarily high or low value, depending on the player.

To select a move, the computer player begins with the current state of the board, where it is assumed that white has made the last move. It generates all of the possible moves for that position. The function runs again on each of those states, generating the possible moves for white. This continues until it reaches the designated ply, where the states are rated. After ratings have been generated, they are passed back up the tree. On each level, the highest or lowest ranked state is selected, depending on which side's turn it is. Black wants higher ratings and white favors lower ratings. Eventually this process reaches the current state, and a move has been selected.

Looking ahead n plies requires searching approximately 35^n states. To prevent the program from running out of memory, one branch of the game tree is searched all the way to the bottom and then deleted before moving on to the next. On the second to last ply, a pruning system prevents any move that is not better than the current best move from being added to the game tree. This does not degrade move selection because only the best move matters on the final ply, and it significantly increases the speed.

The game performs fairly well. It tends to be better at defensive than offensive moves, but it will usually take an opportunity to attack when one exists. As it turned out, the rating and selection system was more powerful than I originally expected. In my original proposal I thought I would need to encourage the use of chess tactics such as forks and pins. I was pleased to discover that, because these positions either lead to less available moves or to more valuable moves, the selection algorithm already favors them as long as the benefits are within the number of plies it is searching.

Download with source for Linux or Windows.



The War that Made America
Posted January 31, 2009 09:36:31 PM by emarcarelli

I added a (really long) review of The War that Made America to the writing page.



New projects
Posted January 31, 2009 09:28:16 PM by emarcarelli

I've added two of my recent projects to the projects page.



Bailout's failure to pass shows hope for change
Posted September 30, 2008 11:54:59 AM by emarcarelli

Yesterday the House of Representatives rejected the $700 billion bailout that many people, including myself, considered inevitable. Downsize DC reported that messages to Congress were up to 300 to 1 against the bill. Rep. Ron Paul credits the bill's failure to pass with constituents making their voices heard. This victory is a major proof of the Downsize DC strategy. If enough people contact them, Congress can still be made to listen to the will of the people. Let your voice be heard. Join the fight for liberty today.



Root bets he is more intelligent than Obama
Posted September 6, 2008 12:08:52 PM by emarcarelli

Root is either insane, or acting like he is to deliberately tarnish people's view of the Libertarian Party. He's put out a bet that he had a better GPA than Obama, and said Obama was only admitted to Harvard because he was black. Ever hear of negative public relations, Root? It was bad enough when the media was trying to link Ron Paul to white supremacists who donated to his campaign; now we have the LP VP actually making racist remarks himself. When Root was nominated as the LP VP candidate some people said he was deliberately trying to destroy the party and I'm almost ready to believe that now.

Root's insane (devious?) comments



Micro Review: Freakonomics
Posted August 24, 2008 04:06:30 PM by emarcarelli

Using the tools of economics, the author examines a series of questions with surprising results. What caused a sudden drop in crime in the 90s? Do political campaigns which spend more tend to win? How does a person's name effect their life? The book varies from intriguing in some areas to simply boring in others, but it is a decent read.




View Archive


© 2008-2009 Eric Marcarelli
Register | RSS