def derive_grid(mine_map, game_id): """ Returns the derived grid (mine matrix * click matrix) """ mine_matrix = mine_map.to_matrix() click_map = DBSession.query(models.PlayerMap).filter_by( game_id=game_id, map_type=const.PlayerMapType.CLICK).first() click_matrix = click_map.to_matrix() # Acts as a mask return multiply(mine_matrix, click_matrix)
def derive_win_matrix(game): mine_map = DBSession.query(models.MineMap).get(game.mine_map) mine_matrix = mine_map.to_matrix() mask = Matrix(mine_matrix.height, width=mine_matrix.width, init_value=0.1) return bit_flip(multiply(mine_matrix, mask))