Game algorithms

Lawrence Weiner algorithm 04Have been talking with Tiong about my work today.  Talking  clears my mind, so the act of talking through my recent work and my plans for new stuff usually helps me a lot. These guys (one girl) that teach us  give great feedback, too.

I’ve been talking with Tiong about the nature of  algorithms and how there are numeric algorithms and language-based algorithms.

The subject came up because I see my games as algorithms, a term that I met with in my computer programming days. To me, a game is an algorithm for the things people do, a prescription  for actions to be performed.  I used the idea of the algorithm in my blog about  Sophie Calle’s work, and also in my blog about the work of Laurence Weiner (see pic).  I also  blogged earlier  about Alexander Galloway who writes about algorithms in his ‘Essays on Algorithmic Culture’. His idea of the control in modern society being exercised by way of algorithms is one that fascinates me.

But before I go and discuss this idea, I need to talk about what an algorithm is. For I learned today that  it  is an unfamiliar term for a lot of people.

Let’s do Wiki first: In mathematics, computer science, and related subjects, an ‘algorithm’ is an effective method for solving a problem expressed as a finite sequence of instructions. Algorithms are used for calculation, data processing, and many other fields.

Each algorithm is a list of well-defined instructions for completing a task. Starting from an initial state, the instructions describe a computation that proceeds through a well-defined series of successive states, eventually terminating in a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate randomness.

The example I used for explaining what an algorithm is is the following:

Imagine having a random row of numbers, for example 4, 7, 1, 11, 19, 2, 5, 14. I now want a computer to sort this row. My algorithm would be as follows: Read the first number, read the second number, compare, swich number on first position with number on second position if number on second  position is smaller than number on first position,  read number on third position,  compare, swich number on second position with number on third position if number on third  position is smaller than number on second  position,  read number on fourth  position &cet. Do the whole row again and again until no more swiches are necessary and voila, the row is sorted.

This is what the algorithm makes happen:

4, 7, 1, 11, 19, 2, 5, 14

4, 1, 7, 11, 2, 5, 14, 19

1, 4, 7, 2, 5, 11, 14, 19

1, 4, 2, 5, 7, 11, 14, 19

1, 2, 4, 5, 7, 11, 14, 19

Of course a math-like notation of the algorithm is much more compact and elegant than the language type instructions I gave first. So here goes:

procedure bubbleSort( A : list of sortable items ):
do
swapped := false
for each i in 0 to length(A) – 2 inclusive do:
if A[i] > A[i+1] then
swap( A[i], A[i+1] )
swapped := true
end if
end for
while swapped
end procedure

This is only one of the many ways a row can be sorted. It even has a name of its own: Bubble Sort, named after the way small elements bubble through the row until they find their place. And this clean elegance is why I love computer programming. Used some of these skills when programming the game-interface to my essay for MaHKU.

« <-- previous post next post --> »