Labs CSE 415, Winter 2009

Function Factory

Our first lab deals with functional programming. Here is a copy of the handout.
In addition to the handout, here is the code for the sequence recognition program for the supplemental activity. The supplemental activity is to download the code and use the functions defined there to analyze the following sequences and generate the next few elements of each.
[13, 15, 17]
[4, 6, 9]
[1, 4, 2, 6, 3, 9]

State-Space Move Generation

This lab is a stepping stone to Assignment 2. Here is a copy of the lab sheet.
And here is a sample solution to Activity A:
sampleBoard = [['X',' ',' '], [' ','O',' '], ['X',' ',' ']]
sampleState = [sampleBoard, 'O']

# Activity A:

def prettyPrint(state):
    board = state[0]
    whoseMove = state[1]
    for i in range(3):
        r = board[i]
        print ' '+r[0]+' | '+r[1]+' | '+r[2]
        if i<2: print '-----------'
    print 'It is '+whoseMove+"'s turn to move"
    print 25*'='
    
prettyPrint(sampleState)

Search Algorithms

In this lab we compare five standard search algorithms. Here is a copy of the lab sheet.
The code for this lab consists of five .py files tarred up into an archive that can be unpacked with WinZip.

Image Understanding

In this lab we experiment with sampling of an image to find out the minimum number of pixels required to faithfully represent the frequency of an oscillating pattern (a picket fence), and we proceed to histogram analysis, thresholding, and simple morphology with erosion and dilation.

Logic Programming

In this lab we briefly explore the use of Horn clause resolution in answering queries. The SWI Prolog interpreter can either be downloaded from its own site or, for the Windows version only, locally here. The lab sheet will be handed out at the lab, but is available here, too.