Archive for category Programming

The Worst of Software Design (Part 1)

RODIN is an Eclipse-based platform for the formal specification of systems in Event-B. Unfortunately, I have to use it (although, not too much). It is, however, the worst piece of software I have seen for a long time. As such I have decided to share my frustration also with you…

Event-B has a main language structure the Event. An Event has a status (not important for now), local variables (which have a type), guards (which define when the event can be triggered) and actions (which specify how to change the state variables.

I decided to create a local variable rr, but unfortunately I managed to put a space after the name “rr”… so it read “rr ” [look out for the space]. Immediately, RODIN refuses the variable definition and highlights all the occurrences of rr throughout the body of the event as undefined variable. WOW!

I leave you with a screenshot:
rodin_space_in_locals

, , ,

No Comments

The Presentation that sets New Standards

In October 1958, John McCarthy published one in a series of reports about his then ongoing effort for designing a new programming language that would be especially suited for achieving artificial intelligence. That report was the first one to use the name LISP for this new programming language. 50 years later, Lisp is still in use. This year we are celebrating Lisp’s 50th birthday.

Lisp was fifty last month. Happy Birthday!

Most importantly, Guy Steele and Richard Gabriel did a presentation that sets a new standard on presentations. Funny, provocative, original, concise and bright!!! A must see… a must re-see…

Presentation!

If one day I manage to do something similar, I will feel accomplished! Congratulations to the speakers!

, , , , , ,

No Comments

A Music to Wake up…

When I taught Lisp in Portugal, I used to pass this song to my students in their 1st year to get them in the mood… Lets hope this gets you into the mood also and find some time to look at this language! :)

, , ,

No Comments

First Steps with Forerunner 405

This is just an initial post regarding my recent gadget: the Garmin Forerunner 405.

A review can be found here and this initial post is the beginning of a technical approach to reverse engineering its protocol.

More info and data soon. Moreover, if you own this forerunner and are able to provide USB Traces in text form, please let me know.

, , , ,

No Comments

ICFP 2008 After 10 Hours

The 10 Hours have passed. The result is an unfinished C++ implementation of a rover. In fact, all I did in the 10 hours was the supporting framework for the rover.
Its features are:

  • Connection to server;
  • Parsing of messages from server;
  • Wrapper for sending well-formed messages to server;
  • Messages are converted into world objects that can be added to world state;
  • Launches two threads, one to receive messages from server and another one to control the server based on the current state continuously modified by the first thread;

An hourly update is as follows:

  1. Reading of problem description and implemention of the socket for server connection;
  2. Message Keeping structures;
  3. Decision about initial rover strategy (described later on) and implementation of threads;
  4. Finished handling threads;
  5. Creation of world object structures;
  6. Parsing of messages into object structures;
  7. Finished parsing messages into object structures;
  8. Starting implementation of state-based strategy;
  9. Reverting implementation into a stateless strategy;
  10. Initial implementation of a stateless strategy;

The strategy which initially I thought I had time to implement based on state would require the implementation of a QuadTree structure and some path-finding algorithms also in order to reuse information used in previous turns. As the time was not enough I reverted into a simple stateless strategy where the rover purely reacted to its vision environment:

  • Can I see a Martian? If yes, run like hell AWAY from them.
  • Do I see a Boulder or Crater in path? If yes, then turn to the best side depending on obstacle position.
  • Is homebase in current path? If no, then turn to the best side in order to have homebase in path as soon as possible.

This was ultimately the strategy I decided to follow and still no time was enough. Although sad that I couldn’t dedicate the whole weekend to it I still did a few things and had loads of fun. The implementation was all git-kept and a tarballed for future reference. (if for some reason you cannot access the tarball, let me know).

, ,

No Comments

ICFP in 10 Hours

As you all know, ICFP Contest started yesterday at 12.00 PDT. It is about a rover in Mars…

Unfortunately this year I am working in Lleida, Spain for a couple of weeks, including weekends, which means no ICFP Contest for me. However, I have decided to dedicate 10 hours (in 2 slots of 5 non-stop hours each) to the contest. So, today I will be working from 8.00pm to 1.00am and tomorrow the same and this year I will be programming in C++.

I will let you know what you can achieve in 10hours of C++ after the contest ends… Stay tuned!

For all the other participants… good luck!

, ,

No Comments

THE Job Opportunity

For those of you seeking something to do… this is not a job opportunity but THE job opportunity. Unfortunately I cannot do it right now, otherwise I have no doubts in my mind I would apply.

Some quotes I like from the job application:

If you prefer to use Java or .NET then you definitely should not apply for this job. We do not like those languages at all. We feel strongly that those languages are like diseases. However, we do not mind if you currently develop in one of those languages and, like a refugee from a war zone, are seeking to escape.

Even though we like and respect Perl, Python, and Ruby on Rails, if you prefer to use one of these languages then you should not apply for this job either. We know Perl is for the old-timers, Python is what they use at Google, and that all the cool kids these days use Ruby on Rails.

, , ,

No Comments

Meeting 12 – Project Discussion

This meeting was yet again a discussion about our project: A Chess Engine.

We started out by reviewing the basics of Chess:

  • Board
  • Pieces
  • Piece Movement

We then discussed four important exceptions in piece movement:

And we still discussed two major strategies to reduce the search space in Chess:

So that we can starting developing some code, we paired up to do (for this first week) the same code functionality:

  • Board, Piece, and Position Datatypes;
  • Piece Movement Function;

In order to be able to develop a driver to test the written code I assume everyone will implement datatypes:

  • Board : With board information;
  • Position : A position in the board;
  • Piece : Piece describes a piece type with a specific color;
  • PieceType : A type of piece like Rook, King, etc..;
  • PieceColour : Either Black or White;

and the following functions:

-- Initialises a board to the initial chess position
initBoard :: Board

-- Moves a piece on the board from the first position to a second position
-- Returns a board with a final state or nothing is move is invalid
movePiece :: Board -> Position -> Position -> Maybe Board

-- Board selector
getPiece :: Board -> Position -> Maybe Piece

-- Piece selectors
pieceColor :: Piece -> PieceColor
pieceType :: Piece -> PieceType

-- Piece predicates
blackColor :: PieceColor -> Bool
whiteColor :: PieceColor -> Bool
rookPieceType :: PieceType -> Bool
knightPieceType :: PieceType -> Bool
bishopPieceType :: PieceType -> Bool
kingPieceType :: PieceType -> Bool
queenPieceType :: PieceType -> Bool
pawnPieceType :: PieceType -> Bool

-- Position selectors
positionRow :: Position -> Int
positionCol :: Position -> Int

-- Position constructor Assume numbers are given in order row,column and they are always from [1 .. 8].
makePosition :: Int -> Int -> Position

We’re all eager to see the developed code… :-) I hope you are too…

, , , , , ,

1 Comment

Meeting 11 – Project Presentation

As tiped out before, there was already an idea to develop an application in Haskell to make use of what we have learned during the first term and to develop this knowledge.

Given that reading papers showed off to be a bad move in the group because most of the members would end up not reading them, we will just move to the development of the application and read any papers that might be needed during the development phase. This hopefully, might turn up to me more motivational.

The idea is to develop a game, more specifically a chess engine. There are several reasons for this decision. From this meeting a report was produced, which you can find here (as well as in our svn repository).

[Sorry for the lack of content in these posts but rest assured soon enough you'll have enough code to play with!]

, ,

No Comments

Meeting 10 – Ropes and Zippers

The FPSIG is back in action for 2008. As discussed previously we would start by looking at four papers about data structures.

Today was the time for Ropes and Zippers:

We read the papers and tried to understand the data structures. It was commonly agreed that we should take another meeting to understand these better, so that would the plan for next week.

However, people around here tend to have to read papers for either their PhD or PostDoc works which means, they are already quite bored with it and putting them in a group where they have to read papers is detrimental to the groups motivation as I could observe during todays meeting. So, during next meeting there will be a shift in the groups direction.

, , ,

No Comments