Friday, September 18, 2009

MATLAB/Octave Utils: submat, grouped

Totally forgot to share these two MATLAB/Octave functions I wrote some time ago:
submat: accessing a sub-matrix of an unknown multi-dimensional matrix
grouped: creating record like data structures from arrays grouped by an index cell

Actually, I still wonder if or why this functionality is not part of the core library or even the 'language syntax '? Anyhow, I couldn't find it so I wrote the two functions myself. (please tell me if you know about a predefined equivalent or a better solution)


1. submat ( submat.m )

In Matlab everything is a (potential) N-dimensional matrix of elements such as doubles, cells or structs. Sub-indexing is easy, unless you try to program in a generic way, e.g. with high-order functions. The problem is that traditional sub-indexing requires you to know the element type (cell or not) and dimensions of the matrix. So I came up with a function submat, which basically does sub-indexing in the highest dimension of an unknown type:

A = [ 1, 2, 3; 4, 5, 6 ];
submat(A,2:3) % same as A(:,2:3)
-> [ 2, 3; 5, 6 ]

B = { 'Hello', 'submat'; 'Goodbye', '(:)' };
submat(B',1) % same as B'{:,1}
-> { 'Hello', 'submat' }



2. grouped ( grouped.m )

The other thing I missed was a simple way to group data arrays to structs. Of course this can easily be done within a for loop, but using the group function eliminates the code repetition. Also, it can be be used in two ways:

First, it allows to simply group equal indices together.

grouped( [ 1, 2, 1, 3, 1, 2, 3] )
-> { [ 1, 3, 5 ], [ 2, 6 ], [ 4, 7 ] }

So far nothing special, but its main purpose is to create a custom struct array.

%artists = { 'Beatles', 'Bob Dylan' };
%records

record_artist_ids = [1, 1, 2, 2, 1];
% or the result of group(record_artist_ids)
record_artist_ids = { [1, 2, 5], [3, 4] };
title = { 'White Album', 'Rubber Soul', 'Blood on the Tracks', 'Blonde on Blonde', 'Revolver' };
year = [ 1968, 1965, 1975, 1966, 1966 ];

artist_records = grouped ( record_artist_ids, 'title', title, 'year', year)

-> artist_records(1).title = { 'White Album', 'Rubber Soul', 'Revolver' }
artist_records(1).year = [ 1968, 1965, 1966 ]
artist_records(2).title = { 'White Album', 'Rubber Soul', 'Revolver' }
artist_records(2).year = [ 1975, 1966 ]

Thursday, September 17, 2009

New Project: Team-Tactics

So what is it about? Well, it's meant to be a playground for exploring intuitive and efficient ways to control/direct virtual entities - or simply a turn based football (soccer) game.

As some might know, my current research is about interaction metaphors for 3D scenes using novel input modalities (multi-touch, motion-sensors, video, ...). Thereby, a special focus lies on concurrent user interaction with both shared and networked devices. Although I might not be able to share much information about this before scientifically published, I believe the evaluation platform should be open right from the beginning. And why shouldn't it be something fun. A tactical football game will fit:

  • the rules are not too complicated to understand and implement

  • the big team size and typical player proximities are ideal for cooperative/competitive interaction

  • easy to realize in both 2D/3D as well as in various levels of abstraction

  • my Ph.D. supervisor is crazy about that football (!FC Barcelona!)


The gameplay will most likely consist of two repeating phases: First, the tactics are defined/adjusted by altering the players' next actions. Afterwards, all the movements are simulated concurrently. Hopefully, this 'genre' (half real-time tactics?) facilitates the strategic/tactical emphasis.

Except for this choice, everything else is still open. The idea is to prototype a lot and to find the most fun and intuitive concepts. (Clearly, the target audience includes casual gamers.)
I guess this is also the place to mention that help is always welcome: if you want to contribute design/interaction ideas, code, graphics, music/sounds or anything else - please let me know.

OK, that's it for now. If you're interested, please follow the dedicated blog at teamtacticsproject.blogspot.com - I intend to write a regular development diary and promise to write at least one post tomorrow.