mercredi 22 mai 2019

Is there any way to reduce if-else flows?

I am trying to remove those if situations as much as I can. Here, I do have two if statements and I would like to write the same codes with one or none.

def ai_player(self, state, team = 1): 
    new_shape_x = np.asarray(state[1]).shape
    player1 = Minimax(n = new_shape_x, default_team = team)
    if team == -1:
        state = player1.convert_board_state(state)
    best_move = player1.decision_maker(state)
    chosen_succ, utility = best_move
    if team == -1:
        chosen_succ = player1.convert_board_state(chosen_succ)
    return chosen_succ

No Error, it is working fine with extra line codes.

Aucun commentaire:

Enregistrer un commentaire