Guitar Hero III tournament!

Posted in Guitar Hero on June 30, 2008 by iambmf

I’ve signed up for a GH3 tournament 21st to 24th of August, with a prize of 200€.
Not that I think I’m gonna win, but at least I’ll try. >:D

For the record, some info about my current GH3-status (70 songs, PS2 version):

Hard:

  • Songs I didn’t beat: 0
  • Songs I beat but didn’t get 5 stars at: 7
  • Songs I got a 5 stars at but didn’t do a 100%: 44
  • Songs I got a 100% at: 19

Expert:

  • Songs I didn’t beat: 6
  • Songs I beat but didn’t get 5 stars at: 11
  • Songs I got a 5 stars at but didn’t do a 100%: 48
  • Songs I got a 100% at: 5

Some more Prolog

Posted in Misc on June 28, 2008 by iambmf

%% Levenshtein distance

distance(Xs,[],N) :- size(Xs,N), !.
distance([],Ys,N) :- size(Ys,N), !.

distance([X|Xs],[Y|Ys],N) :- X = Y, !, distance(Xs,Ys,N).
distance([X|Xs],[Y|Ys],N) :- X \= Y, !, distance(Xs,Ys,D1), distance([X|Xs],Ys,D2), distance(Xs,[Y|Ys],D3), min(D1,D2,D3,N1), N is N1+1.

size([],0) :- !.
size([X|Xs],N) :- size(Xs,N1), N is N1+1, !.

min(X,Y,Z,X) :- X =< Y, X =< Z, !.
min(X,Y,Z,Y) :- Y =< Z, !.
min(X,Y,Z,Z) :- !.

Backgammon

Posted in Misc on June 23, 2008 by iambmf

“Backgammon is a board game for two players in which the playing pieces are moved according to the roll of dice… Although luck plays an important role, there is a large scope for strategy”

If you don’t know this game, they I strongly suggest you try it out. It’s awesome! I’ve been playing it quite a lot lately, it’s really entertaining.

I had the intention to make a Backgammon playing bot, but it looks like such a thing is harder than I may have thought at first. =/

My first Prolog program. =P

Posted in Misc on June 23, 2008 by iambmf

%% Tests whether a number is prime or not.

prime(X) :- integer(X), prime(2,X).
prime(N,X) :- N < X, N1 is N+1, M is X mod N, M =\= 0, prime(N1,X).
prime(X,X).

^_^

It was time for an update!

Posted in Misc on June 15, 2008 by iambmf

So I updated my personal website today. I had not worked on it for a while, and since now I have some free time… =)

However, I must say I’m not too happy with it… so I may change it again soon.

Solving the sudoku

Posted in Sudoku Solving Robot on June 10, 2008 by iambmf

I know you were eager to taste some source code, so here you have a first version of the solver.
To try it, just follow the steps described in the post below (PIC Simulator, Assembler, Assemble & Load, Run).

To verify it works, you take a look at the status of the GPRs, and if you remember what was said here, you’ll know if it has properly solved the sudoku or not.

The sudoku it solves is defined by the few hundred lines of code enclosed in the region ’sudoku input’.
If you want to try another sudoku, just do what needs to be done.

This is a first version of the solver, and managed to solve ‘very easy’, ‘easy’, ‘medium’ and some ‘hard’ sudokus of those at this site. It did solve an ‘expert’ one , too. We are currently working on an improved version.

The following flowchart shows the strategy the program uses in order to solve the sudokus:

Hello, programmer

Posted in Sudoku Solving Robot on June 10, 2008 by iambmf

You’ve seen that we have already used some PICs (that colour sensor video some posts ago?), so we have programmed them. You’ve seen, too, that we have made a program (in Perl) that generates some assembly code to load the information of a sudoku into memory.

But, we haven’t really got into programming yet, have we?

Since we have already coded a first version of our sudoku solving program (and a second version too, actually), the time for a ’source code’-post is not far. But before that, let’s get ready to code!
In this post, we’ll explain how to set some tools up to ease the coding process.

Firstly, we will need PIC Simulator to test our programs. Let’s explain a bit how it works.

That’s what it looks like when you start PIC Simulator. You can select there which microcontroller you are going to be working with, and at which clock speed. Also, note the section dedicated to General Purpose Registers (GPRs).

If you go to Tools -> Assembler, a text editor will open. Here’s where you are supposed to write the code. Or you can File -> Open another .asm file. Then, Tools -> Assemble & Load and the program gets loaded and ready to be run.

At this point, one basically uses Simulation and Rate tabs at the main window of the program.
The breakpoints manager (Tools -> Breakpoints Manager) is also very helpful (particularly, if you are bug-hunting). This is how it looks:

So far, so good. But the editor that comes with PIC Simulator kind of sucks, and you do realize that when you are writing a program with many lines of code.

We didn’t like it’s poor color-coding, or the fact that it didn’t have code regions. So we decided to move on to an editor that had it all: Notepad++.

It’s a great text editor and, best of all, allows you to define your own languages (user defined languages, yay!).
So we defined a PIC16F language, and that way we had colour coding that we liked, and regions! (They start with the keyword ‘;region’ and end with ‘;endregion’)

If you want to use yourself this language with Notepad++, you just have to download the userDefineLange.xml file and paste it into the folder that opens when you type ‘%APPDATA%\Notepad++’ and press OK at Start->Run.

Well, I think that’s all. You learnt how to use the basic functionality on PIC Simulator and you have a powerful editor to program in. Next, we’ll give you some source code to play around. Later dudes and dudettes!

Back

Posted in Misc on June 10, 2008 by iambmf

Exams are over!

I know it’s been long since my last post, I’ve been pretty busy with exams and stuff. However, the fact that I didn’t find time to post doesn’t imply that I didn’t find time to work on some stuff. So expect some news soon.

I’m currently basically working at the following (among some other things you do not care about):
-A demo with TimeScratchers. We’ll hopefully have it ready before the summer ends.
-The sudoku solving robot with the trigeekz. I’ll write some posts about it soon!

I should also mention that I (as a part of nivel21) will most surely enter the DBP challenge.

What else… I want to learn some prolog, and make a backgammon bot. Still hooked to Guitar Hero III, and watching Lost (3rd Season).

Hooray for free time!

GH II tournament winner!

Posted in Guitar Hero on May 11, 2008 by iambmf

On Friday night there was a Guitar Hero II tournament organized by metalsevilla and Bohemians’ Pub, and I won!

Looks like all those hours spent playing GH were worth something, after all! Haha. There weren’t many participants though (6, to be precise) but oh well, I got a t-shirt, a fancy diploma, and 2 passes for a concert. =)

Actually, only 2 of us had a chance of winning (the rest didn’t play that well, sorry) and I think that that other guy was a bit better than me. The final was awesome, and we battled each other 5 times. I finally won, but I must say that a draw would have been fairly fair! =)

Now, back to Guitar Hero III. And waiting for Aerosmith’s!

SudokusWeb to asm!

Posted in Sudoku Solving Robot on May 11, 2008 by iambmf

When we started working on our sudoku solving assembly (PIC16F648A) program we found we needed a simple way to load the initial data of the sudoku (in order to have something to solve!).

(For those who have read the post “The Data Memory Map”, the following will make more sense)
Loading the initial data of the sudoku basically consists of storing the input data about columns 1-3 at bank 0 (using 2 bytes per sudoku cell), moving on to bank 1, writing input data about columns 4-6, moving on to bank 2 and writing input data about columns 7-9.

The first time we did it manually, but that was a hell of a job. So we looked for a website that could supply us with daily sudokus, from very easy to expert, found one, and wrote a Perl program that, taking one of that site’s images as input, produces the assembly code we need as output.

Then we just paste this code into the part of our sudoku solving assembly program that’s destined to ‘input’, and voila, we can test different sudokus really easily.

Here you can download the source code of this program, as well as an example image to test it.

By the way, the example sudoku that comes in that .rar is already solved by our program. =D
Expect a post about the solver itself soon! (Among a few others hardware-related posts, yay!)