Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Hello World program in Python
- print ("==Le monde==");
- carte = [['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
- ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
- ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
- ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
- ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
- ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
- ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
- ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
- ]
- def voir_carte():
- for ligne in carte:
- for e in ligne:
- print(e, end = '')
- print("")
- # Taile de la carte en Y et X
- def taille_carte(carte):
- lignes = len(carte)
- colonnes = len(carte[0])
- return lignes, colonnes
- def BFS(carte, pos): #current_pos
- for neighbor in voisins(carte, pos):
- print(neighbor)
- #discovered = [pos]
- #while len(discovered) >= 0:
- #current_pos = discovered.pop()
- #x, y = current_pos
- #if carte[y][x] == 'o':
- #break
- #for neighbor in voisins(carte, current_pos):
- #if neighbor in discovered:
- #continue
- #discovered.append(neighbor)
- #
- #return discoverd.pop()
- # On cherche pour des cases vides où on peut aller (les '.')
- def voisins(carte, pos):
- x, y = pos
- voisins = []
- #print("pos:", x, y)
- #print("ele:", carte[y][x])
- print(len(carte[y]))
- print("pos:", x, y)
- if x + 1 < len(carte[0]) and carte[y][x + 1] == '.':
- voisins.append((x + 1, y))
- if x > 0 and carte[y][x - 1] == '.':
- voisins.append((x - 1, y))
- if y + 1 < len(carte) and carte[y + 1][x] == '.':
- voisins.append((x, y + 1))
- if y > 0 and carte[y - 1][x] == '.':
- voisins.append((x, y - 1))
- return voisins
- voir_carte()
- print("Taille de la matrice de la carte:", taille_carte(carte))
- # Ajouter un joueur, des barrières et des biscuits à collecter sur la carte
- carte[7][6] = 'x'
- carte[3][5] = '='
- carte[3][6] = '='
- carte[3][7] = '='
- #carte[3][8] = '='
- carte[3][9] = '='
- carte[3][10] = '='
- carte[5][6] = '='
- carte[5][8] = '='
- carte[5][4] = '='
- carte[1][10] = 'o'
- carte[3][2] = 'o'
- carte[4][6] = 'o'
- voir_carte()
- pos = 6, 7
- i = 0
- while i < 3:
- i += 1
- BFS(carte, pos)
- x, y = pos
- carte[y][x] = 'x'
- voir_carte()
- if x == None or y == None:
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement