#!/usr/bin/env python
import sys
# create a board map with list. Each element include a tuple describing the location and an int value descriving if a piece is at the place.
#Start_board = [(0,0,1),(1,0,1),(0,1,1),(2,0,1),(1,1,1),(0,2,1),(3,0,1),(2,1,1),(1,2,1),(0,3,1),(4,0,1),(3,1,1),(2,2,1),(1,3,1),(0,4,1)]
Start_board = {(0,0): 1, (1,0): 1, (0,1): 1, (2,0): 1, (1,1): 1, (0,2): 1, (3,0): 1, (2,1): 1, (1,2): 1, (0,3): 1, (4,0): 1, (3,1): 1, (2,2): 1, (1,3): 1, (0,4): 1}
#print(Start_board)
class board():
    boardmap = None
    def __init__(self):
        self.boardmap = Start_board

    def printboard(self):
        board = self.boardmap
        print("    {}    ".format(str(board[(0,0)])))
        print("   {} {}   ".format(str(board[(1,0)]), str(board[(0,1)])))
        print("  {} {} {}  ".format(str(board[(2,0)]), str(board[(1,1)]), str(board[(0,2)])))
        print(" {} {} {} {} ".format(str(board[(3,0)]), str(board[(2,1)]), str(board[(1,2)]), str(board[(0,3)])))
        print("{} {} {} {} {}".format(str(board[(4,0)]), str(board[(3,1)]), str(board[(2,2)]), str(board[(1,3)]), str(board[(0,4)])))
    def pick_a_piece(self,loc):
        self.boardmap[loc] = 0
        
    def make_a_move(self,start_piece,move):
        if move == 1:
            end_piece = (start_piece[0], start_piece[1] - 2)
        elif move == 2:
            end_piece = (start_piece[0] - 2, start_piece[1])
        elif move == 3:
            end_piece = (start_piece[0] + 2, start_piece[1] - 2)
        elif move == 4:
            end_piece = (start_piece[0] - 2, start_piece[1] + 2)
        elif move == 5:
            end_piece = (start_piece[0] + 2, start_piece[1])
        elif move == 6:
            end_piece = (start_piece[0], start_piece[1] + 2)
        #check for the end piece
        else:
            raise ValueError("invalid input")
        if 0 <= end_piece[0] <= 4 and 0 <= end_piece[1] <= 4 and 0 <= end_piece[0] + end_piece[1] <= 4:
            if self.boardmap[start_piece] == 1 or self.boardmap[mid_piece] == 0 or self.boardmap[end_piece] == 1:
                raise ValueError("Can't move that way")
            mid_piece = ((start_piece[0] + end_piece[0]) / 2, (start_piece[1] + end_piece[1]) / 2)
            self.boardmap[start_piece] = 0
            self.boardmap[mid_piece] = 0
            self.boardmap[end_piece] = 1
        else:
            raise ValueError("Can't move that way")

def get_user_input():
        a = input("Input two integers as the location, split with a space:")
        x,y = a.split(' ')
        x = int(x)
        y = int(y)
        if 0 <= x <= 4 and 0 <= y <= 4 and 0 <= x+y <= 4:
            return (x,y)
        else:
            raise ValueError("invalid input")

def game_main():
    x = board()
    print("==========Game Start============")
    x.printboard()
    loc = get_user_input()
    x.pick_a_piece(loc)
    x.printboard()
    print("==========Start Move============")
    for i in range(13):
        print("Start Loc")
        ori_loc = get_user_input()
        move = input("Input a number from 1 to 6, 1 for left top and 2 for right top and so on:")
        move = int(move)
        x.make_a_move(ori_loc,move)
        x.printboard()

if sys.version_info[0] != 3:
    print("This script requires Python 3")
    exit()
game_main()

#!/usr/bin/env python
import sys
# create a board map with list. Each element include a tuple describing the location and an int value descriving if a piece is at the place.
#Start_board = [(0,0,1),(1,0,1),(0,1,1),(2,0,1),(1,1,1),(0,2,1),(3,0,1),(2,1,1),(1,2,1),(0,3,1),(4,0,1),(3,1,1),(2,2,1),(1,3,1),(0,4,1)]
Start_board = {(0,0): 1, (1,0): 1, (0,1): 1, (2,0): 1, (1,1): 1, (0,2): 1, (3,0): 1, (2,1): 1, (1,2): 1, (0,3): 1, (4,0): 1, (3,1): 1, (2,2): 1, (1,3): 1, (0,4): 1}
#print(Start_board)
class board():
    boardmap = None
    def __init__(self):
        self.boardmap = Start_board

    def printboard(self):
        board = self.boardmap
        print("    {}    ".format(str(board[(0,0)])))
        print("   {} {}   ".format(str(board[(1,0)]), str(board[(0,1)])))
        print("  {} {} {}  ".format(str(board[(2,0)]), str(board[(1,1)]), str(board[(0,2)])))
        print(" {} {} {} {} ".format(str(board[(3,0)]), str(board[(2,1)]), str(board[(1,2)]), str(board[(0,3)])))
        print("{} {} {} {} {}".format(str(board[(4,0)]), str(board[(3,1)]), str(board[(2,2)]), str(board[(1,3)]), str(board[(0,4)])))
    def pick_a_piece(self,loc):
        self.boardmap[loc] = 0
        
    def make_a_move(self,start_piece,move):
        if move == 1:
            end_piece = (start_piece[0], start_piece[1] - 2)
        elif move == 2:
            end_piece = (start_piece[0] - 2, start_piece[1])
        elif move == 3:
            end_piece = (start_piece[0] + 2, start_piece[1] - 2)
        elif move == 4:
            end_piece = (start_piece[0] - 2, start_piece[1] + 2)
        elif move == 5:
            end_piece = (start_piece[0] + 2, start_piece[1])
        elif move == 6:
            end_piece = (start_piece[0], start_piece[1] + 2)
        #check for the end piece
        else:
            raise ValueError("invalid input")
        if 0 <= end_piece[0] <= 4 and 0 <= end_piece[1] <= 4 and 0 <= end_piece[0] + end_piece[1] <= 4:
            if self.boardmap[start_piece] == 1 or self.boardmap[mid_piece] == 0 or self.boardmap[end_piece] == 1:
                raise ValueError("Can't move that way")
            mid_piece = ((start_piece[0] + end_piece[0]) / 2, (start_piece[1] + end_piece[1]) / 2)
            self.boardmap[start_piece] = 0
            self.boardmap[mid_piece] = 0
            self.boardmap[end_piece] = 1
        else:
            raise ValueError("Can't move that way")

def get_user_input():
        a = input("Input two integers as the location, split with a space:")
        x,y = a.split(' ')
        x = int(x)
        y = int(y)
        if 0 <= x <= 4 and 0 <= y <= 4 and 0 <= x+y <= 4:
            return (x,y)
        else:
            raise ValueError("invalid input")

def game_main():
    x = board()
    print("==========Game Start============")
    x.printboard()
    loc = get_user_input()
    x.pick_a_piece(loc)
    x.printboard()
    print("==========Start Move============")
    for i in range(13):
        print("Start Loc")
        ori_loc = get_user_input()
        move = input("Input a number from 1 to 6, 1 for left top and 2 for right top and so on:")
        move = int(move)
        x.make_a_move(ori_loc,move)
        x.printboard()

if sys.version_info[0] != 3:
    print("This script requires Python 3")
    exit()
game_main()

#!/usr/bin/env python # create a board map with list. Each element include a tuple describing the location and an int value descriving if a piece is at the place. #Start_board = [(0,0,1),(1,0,1),(0,1,1),(2,0,1),(1,1,1),(0,2,1),(3,0,1),(2,1,1),(1,2,1),(0,3,1),(4,0,1),(3,1,1),(2,2,1),(1,3,1),(0,4,1)] #print(Start_board) #check for the end piece