def getrandomaimove(board, color=BLACK): """ Gets a random move. :param board: 32-element list :param color: what color is the AI getting a move for? :return: list: [starting tile, ending tile, (tiles jumped)] """ moves = Cb.getallpossiblemoves(board, color) if (len(moves) != 0): movenum = random.randint(0, len(moves) - 1) move = moves[movenum] return move else: return []
def gapmoves(request): board = json.loads(request.GET['board']) color = json.loads(request.GET['color']) return HttpResponse(json.dumps(Cb.getallpossiblemoves(board, color)), content_type="application/json")