Homework 30 — due Friday April 6 by end of class


Descriptions of the functions are available at the end of the module functions section.

15 tile game of mandrill


Discussion

standard_ordering = [

      ( 0, 0 ), ( 1, 0 ), ( 2, 0 ), ( 3, 0 ),
      ( 0, 1 ), ( 1, 1 ), ( 2, 1 ), ( 3, 1 ),
      ( 0, 2 ), ( 1, 2 ), ( 2, 2 ), ( 3, 2 ),
      ( 0, 3 ), ( 1, 3 ), ( 2, 3 ), ]             # only 15 tiles

random_ordering = standard_ordering[ : ] # make a copy of the standard

random.shuffle( random_ordering ) # and shuffle it


Module functions

Function initialize_globals( img )

global LINE_WIDTH, GRID_COLOR, TILE_DIMENSIONS, BOARD, BLACK_TILE, BLACK_TILE_SPOT

LINE_WIDTH = 4

GRID_COLOR = 'SteelBlue'

TILE_DIMENSIONS = ( img.width // 4, img.height // 4 )

BLACK_TILE = Image.new( 'RGB', TILE_DIMENSIONS, 'Black' )

BLACK_TILE_SPOT = ( 3, 3 )

BOARD = Image.new( 'RGB', ( img.width + 5*LINE_WIDTH, img.height + 5*LINE_WIDTH ), GRID_COLOR )


Function convert_spot_into_board_coordinate( g_spot )


Function convert_spot_into_image_coordinate( g_spot )


Function overlay( tile, g_spot )


Function get_image_tile( img, g_spot )

15 tile game of mandrill


Function initialize_board( img )

15 tile game of mandrill


Function scramble_board( img )

15 tile game of mandrill


Function setup( img )


Function get_board_tile( g_spot )

15 tile game of mandrill


Function inbounds( spot )


Function slide_black_tile_left()

If instead the leftward spot is out of bounds, no action is taken.


Function slide_black_tile_right()


Function slide_black_tile_down()


Function slide_black_tile_up()