def score_test_3(): width = 8 height = 5 points = [ [1, 0, 2, 1, 1, 2, 0, 1], [0, 1, 0, 1, 1, 0, 1, 0], [1, 3, -1, 2, 2, -1, 3, 1], [0, 1, 0, 1, 1, 0, 1, 0], [1, 0, 2, 1, 1, 2, 0, 1] ] tiled = [ [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 2, 1 ,0], [0, 1, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0] ] board = Board(width, height, points, tiled) game = Game(board, []) true_score = { 1: { "tilePoint": 22, "areaPoint": 10 }, 2: { "tilePoint": 2, "areaPoint": 4 } } assert(game.cal_score([1, 2]) == true_score)
def score_test_6(): width = 7 height = 7 points = [ [0, 1, 2, 0, 2, 1, 0], [2, -2, 0, 1, 0, -2, 2], [2, 1, 0, -2, 0, 1, 2], [1, 2, 2, 3, 2, 2, 1], [1, 2, 2, 3, 2, 2, 1], [2, 1, 0, -2, 0, 1, 2], [2, -2, 0, 1, 0, -2, 2] ] tiled = [ [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1] ] board = Board(width, height, points, tiled) game = Game(board, []) true_score = { 1: { "tilePoint": 32, "areaPoint": 22 } } assert(game.cal_score([1]) == true_score)
def score_test_5(): width = 5 height = 5 points = [ [-2, 0, 1, 0, -2], [1, 0, -2, 0, 1], [2, 2, 3, 2, 2], [2, 2, 3, 2, 2], [1, 0, -2, 0, 1] ] tiled = [ [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1] ] board = Board(width, height, points, tiled) game = Game(board, []) true_score = { 1: { "tilePoint": 15, "areaPoint": 4 } } assert (game.cal_score([1]) == true_score), "Test Failed"
def flow_test_2(): width = 7 height = 3 points = [ [1, 4, -2, 5, -2, 4, 1], [8, 9, 1, 0, 1, 9, 8], [0, 4, 6, 3, 6, 4, 0], ] tiled = [ [0, 0, 1, 0, 2, 0, 0], [0, 0, 1, 0, 2, 0, 0], [0, 0, 1, 0, 2, 0, 0] ] agents = [ Agent(1, 1, 2, 0), Agent(1, 2, 2, 1), Agent(1, 3, 2, 2), Agent(2, 4, 4, 0), Agent(2, 5, 4, 1), Agent(2, 6, 4, 2), ] board = Board(width, height, points, tiled) simulator = Game(board, agents) # 1 simulator.set_action(1, 1, 1, 0) simulator.set_action(1, 2, 1, 0) simulator.set_action(1, 3, -1, 0) simulator.set_action(2, 4, 1, 0) simulator.set_action(2, 5, -1, 0) simulator.set_action(2, 6, -1, 0) simulator.step() true_score = { 1: { "tilePoint": 14, "areaPoint": 0 }, 2: { "tilePoint": 12, "areaPoint": 0 } } assert(simulator.cal_score([1, 2]) == true_score) assert(simulator.turn == 1)
def flow_test_1(): width = 5 height = 5 points = [ [2, 1, 0, 1, 2], [4, 5, 3, 5, 4], [1, 1, 2, 1, 1], [4, 5, 3, 5, 4], [2, 1, 0, 1, 2] ] tiled = [ [0, 1, 0, 2, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 2, 0, 1, 0] ] agents = [ Agent(1, 1, 1, 0), Agent(1, 2, 3, 4), Agent(2, 3, 3, 0), Agent(2, 4, 1, 4) ] board = Board(width, height, points, tiled) simulator = Game(board, agents) simulator.set_action(1, 1, 0, 1) simulator.set_action(1, 2, -1, 0) simulator.set_action(2, 3, 1, 0) simulator.set_action(2, 4, 0, -1) simulator.step() true_score = { 1: { "tilePoint": 7, "areaPoint": 0 }, 2: { "tilePoint": 9, "areaPoint": 0 } } assert(simulator.cal_score([1, 2]) == true_score) assert(simulator.turn == 1)