<filename>brd.py
#This file managers the board (matrix)
from user import Printm
def con(height,width,bad,ditch,player):#gets the height and width of the desired board, and with the location of the Badguys, ditches and the player - returns a matrix (the final board)
    brd = []
    for r in range(height):
        brd.append([])
        for c in range(width):
            brd[r].append([' ',' '])
    for c in range(width):
        brd[height-3][c][1] = '-'
    for unit in bad:
        brd[unit[1]][unit[0]] = 'X '
    for d in ditch:
        brd[height-3][d][1] = ' '
    #brd[player[1]][player[0]][0] = 'O'
    return brd

def moving(brd,height,width):
    tempb = []
    for i in range(height):
        tempb.append([])
        for j in range(width):
            tempb[i].append(' ')
    for r in range(height):
        for c in range(width):
            if len(brd[r][c]) == 4:
                #print r
                #print c
                move(brd,tempb,r,c)

            else:
                pass
    copy(brd,tempb,height,width)
    return 0
def move(brd,tempb,r,c):
    unit = brd[r][c]
    #print unit[3]
    if unit[3] == len(unit[2])-1:
        unit[3] = 0
    else:
        unit[3] += 1
    #print unit
    next_loc = unit[2][unit[3]]
    #print "next_loc: {}".format(next_loc)
    b = ['x','x',unit[2][:],unit[3]]
    brd[r][c] = [' ',' ']
    
    tempb[next_loc[1]][next_loc[0]] = b
def copy(brd,tbrd,height,width):
    for row in range(height):
        for column in range(width):
            if tbrd[row][column] != ' ':
                brd[row][column] =  tbrd[row][column]

<filename>brd.py
#This file managers the board (matrix)
from user import Printm
def con(height,width,bad,ditch,player):#gets the height and width of the desired board, and with the location of the Badguys, ditches and the player - returns a matrix (the final board)
    brd = []
    for r in range(height):
        brd.append([])
        for c in range(width):
            brd[r].append([' ',' '])
    for c in range(width):
        brd[height-3][c][1] = '-'
    for unit in bad:
        brd[unit[1]][unit[0]] = 'X '
    for d in ditch:
        brd[height-3][d][1] = ' '
    #brd[player[1]][player[0]][0] = 'O'
    return brd

def moving(brd,height,width):
    tempb = []
    for i in range(height):
        tempb.append([])
        for j in range(width):
            tempb[i].append(' ')
    for r in range(height):
        for c in range(width):
            if len(brd[r][c]) == 4:
                #print r
                #print c
                move(brd,tempb,r,c)

            else:
                pass
    copy(brd,tempb,height,width)
    return 0
def move(brd,tempb,r,c):
    unit = brd[r][c]
    #print unit[3]
    if unit[3] == len(unit[2])-1:
        unit[3] = 0
    else:
        unit[3] += 1
    #print unit
    next_loc = unit[2][unit[3]]
    #print "next_loc: {}".format(next_loc)
    b = ['x','x',unit[2][:],unit[3]]
    brd[r][c] = [' ',' ']
    
    tempb[next_loc[1]][next_loc[0]] = b
def copy(brd,tbrd,height,width):
    for row in range(height):
        for column in range(width):
            if tbrd[row][column] != ' ':
                brd[row][column] =  tbrd[row][column]

#This file managers the board (matrix) #gets the height and width of the desired board, and with the location of the Badguys, ditches and the player - returns a matrix (the final board) #brd[player[1]][player[0]][0] = 'O' #print r #print c #print unit[3] #print unit #print "next_loc: {}".format(next_loc)