Showing posts with label swingame. Show all posts
Showing posts with label swingame. Show all posts

Monday, November 09, 2009

Regex for Tracing

I've been working on SwinGame, and one of the tasks has been to add tracing code to the core to make it easier to debug problems. This involves adding TraceEnter and Trace exit calls to each procedure in the code.

To avoid having to do this by hand I am using a Regular Expression in TextMate to find procedures in the code, and replace them with a version that includes the injected trace enter and exit code. The regex I am using is shown below. It will work with a maximum depth of four begin/end groups... so its not completely automatic, but is a good start.

(function |procedure )(.*?)(;(\n|.)*?begin)((\n|(begin(\n|(begin(\n|(begin(\n|(begin(\n|.)*?end)|.)*?end)|.)*?end)|.)*?end)|.)*?)(\n end;)
This is then replaced using the following replace text. The $1 values are the groups that are matched in the regular expression. This enables me to place the procedure name, parameters and return type in the traced output ($2). It also ensures that all of the code from the program is output in the right spot.
$1$2$3
{$IFDEF TRACE}
TraceEnter('sgCamera', '$2', '');
{$ENDIF}
$5
{$IFDEF TRACE}
TraceExit('sgCamera', '$2', '');
{$ENDIF}
$15
This regular expression converts the following code...
function VectorFrom(x, y: Single): Vector; overload;
begin
result := VectorFrom(x, y, false);
end;
into this code which now has the tracing details added.
function VectorFrom(x, y: Single): Vector; overload;
begin
{$IFDEF TRACE}
TraceEnter('sgCamera', 'VectorFrom(x, y: Single): Vector', '');
{$ENDIF}

result := VectorFrom(x, y, false);

{$IFDEF TRACE}
TraceExit('sgCamera', 'VectorFrom(x, y: Single): Vector', '');
{$ENDIF}
end;
This should save me some time... though a real parser trace injector would be great!

Wednesday, March 05, 2008

Python is intriguing...

I share an office with Clinton who has lately become somewhat of a Python convert. Today I started to play with Python for the first time. Unlike "normal" people I didn't start with Python in Python... I started by embedding it within a Pascal program. Embedding Python within Pascal was really simple - I am totally amazed! With less than 20 lines of Pascal code you can embed a Python interpreter and have it load and run python modules.

The code for this will be placed on Google Code once I have it a little farther along.

Why am I doing this? We are looking at providing the ability to run Scripts within SwinGame, its looking like we should have something interesting soon!

Wednesday, February 27, 2008

Portfolio Assessment

Well semester 1 has started... I can where did all that time go? This semester I am teaching HIT1301 Algorithmic Problem Solving again, and as always there are improvements to be made. This semester most of the changes revolve around the assessment, with some minor changes to the lectures and resources available.

On the assessment side of things the assessment will be much more flexible than in the past. Basically for APS there will be some core assignments and tests, each quite short but covering all the basics. Passing these means you pass the subject, in most cases you need to get them working to pass so dont think 50% = pass for these! To get anything greater than this students will need to submit a portfolio that shows their capabilities and depth of understanding of software development. This means students can choose what they want to focus on, while still ensuring they cover all bases. The focus of this assessment is on depth of understanding and quality of work, rather than quantity.

I'll keep you informed of how this goes... Let me know what you think of the idea.

In other news we are (well Clinton really) making progress with the new python port of SwinGame. This will mean that you will be able to call the SwinGame API from Python... the next step is to embed Python within SwinGame :)

Monday, February 04, 2008

SwinGame Excitement

The swingame project has gone through some very exciting developments. Over the last few weeks we have managed to develop a new edition of SwinGame (version 1.1) and is now available for download. Have a look at the game promo videos that we have created for this of YouTube they have been great fun to create.

Let us know what you think.

Friday, December 14, 2007

Exciting things are afoot

The Summer Semester Project this year is working on extending the SwinGame API that was started last year. This is a really exciting project with some great outcomes already, and we're less than half way through...

So what have the students achieved? The most visible part is the SwinGame web site. This site will be used to promote and distribute the SDKs when they are finished. The site uses a combination of MediaWiki and phpBB, combined together with a common theme. The wiki will be used to document the API while the forum will offer a place to discuss the games, and any issues with the API. You can read their comments on the SwinGameSDK Development blog.

I've used the SDK to create a small game, "Alien Flight". Its been great fun to have a chance to play around with this, though I guess I'll need to get back to work soon :(. I'll be putting the game up on the site some time soon.

Anyway check out the site and let me know what you think. Its a little empty at the moment, but we're working on getting content in soon.

Have a great christmas, and new year!