4Blocks with AI

19 08 2009

I’ve been wanting to write another blog post on the series on DSELs I’ve been planning, but I’ve been really swamped with work lately. So once more I’ll post a video or two on something I’ve been working on. It’s the 4blocks game again, this time playing on its own with an AI I’ve written for it. Here are the videos:


On the whole these were two good runs. I’ve had much better and much worse runs of course.

The AI is by no means perfect but it uses the DSEL techniques in Haskell. I have two languages acting here:
1. A Tetris DSEL
2. Haskell acting as a meta-language over the Tetris DSEL.

What is happening is that for every new brick the game state is queried by Haskell for certain information such as occupied blocks or number of lines. Using this information, by means of Haskell’s case statement I simply trigger one of a possible number of strategies. These strategies acquire certain information from the game state and generate a DSEL script. This script is then carried out by a DSEL script interpreter.

There are numerous problems with the AI and its mostly because I haven’t had time to write more strategies or a more intelligent way to select what according to the selected strategy is the best final brick destination.

That’s about it for now. Let me know what you think.

About these ads

Actions

Information

4 responses

20 08 2009
Andrea Vezzosi

I think that we want to see some code snippets of how the strategies are defined :)
Especially since your AI seems to play just like me. Though maybe that’s just the common way to play.

20 08 2009
drewcalleja

Yes Andrea ;) I will 100% make available the code for tetris once I am finished with it. Also if my tutor is ok with it I will release the AI code. :)

8 09 2009
skoorc8

Hi Andrew. I am relatively new to Haskell programming and the idea of DSELs. I found it very interesting and would really like to see how it is done. Probably a high level explanation and the general principles used in creating the DSEL along with the code for the strategies and the AI.

8 09 2009
drewcalleja

I hope to give some more details soon! Stay tuned :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.

%d bloggers like this: