~yacinechaouche/+junk/BZR

« back to all changes in this revision

Viewing changes to CODE/REDDIT/TTT/Tic-Tac-Toe-master/python 2.7/moves.py

  • Committer: yacinechaouche at yahoo
  • Date: 2015-01-14 22:23:03 UTC
  • Revision ID: yacinechaouche@yahoo.com-20150114222303-6gbtqqxii717vyka
Ajout de CODE et PROD. Il faudra ensuite ajouter ce qu'il y avait dan TMP

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import random
 
2
 
 
3
def choose_random_move(board, moves):
 
4
    possible_moves = []
 
5
    for move in moves:
 
6
        if board.is_space_free(move):
 
7
            possible_moves.append(move)
 
8
    if len(possible_moves) != 0:
 
9
        return random.choice(possible_moves)
 
10
    else:
 
11
        None