<commit_before># -*- coding: utf-8 -*-
import string
from command import *
from gui import *
from ai import *
"""
 __   __   __   ___               __   __        __   ___
/  ` /  \ |  \ |__     | |\ |    /__` |__)  /\  /  ` |__
\__, \__/ |__/ |___    | | \|    .__/ |    /~~\ \__, |___

.     .       .  .   . .   .   . .    +  .
  .     .  :     .    .. :. .___---------___.
       .  .   .    .  :.:. _".^ .^ ^.  '.. :"-_. .
    .  :       .  .  .:../:            . .^  :.:\.
        .   . :: +. :.:/: .   .    .        . . .:\
 .  :    .     . _ :::/:               .  ^ .  . .:\
  .. . .   . - : :.:./.                        .  .:\
  .      .     . :..|:                    .  .  ^. .:|
    .       . : : ..||        .                . . !:|
  .     . . . ::. ::\(                           . :)/
 .   .     : . : .:.|. ######              .#######::|
  :.. .  :-  : .:  ::|.#######           ..########:|
 .  .  .  ..  .  .. :\ ########          :######## :/
  .        .+ :: : -.:\ ########       . ########.:/
    .  .+   . . . . :.:\. #######       #######..:/
      :: . . . . ::.:..:.\           .   .   ..:/
   .   .   .  .. :  -::::.\.       | |     . .:/
      .  :  .  .  .-:.":.::.\             ..:/
 .      -.   . . . .: .:::.:.\.           .:/
.   .   .  :      : ....::_:..:\   ___.  :/
   .   .  .   .:. .. .  .: :.:.:\       :/
     +   .   .   : . ::. :.:. .:.|\  .:/|
     .         +   .  .  ...:: ..|  --.:|
.      . . .   .  .  . ... :..:.."(  ..)"
 .   .       .      :  .   .: ::/  .  .::\
 
                 .___       .__                                            
  ____  ____   __| _/____   |__| ____     _________________    ____  ____  
_/ ___\/  _ \ / __ |/ __ \  |  |/    \   /  ___/\____ \__  \ _/ ___\/ __ \ 
\  \__(  <_> ) /_/ \  ___/  |  |   |  \  \___ \ |  |_> > __ \\  \__\  ___/ 
 \___  >____/\____ |\___  > |__|___|  / /____  >|   __(____  /\___  >___  >
     \/           \/    \/          \/       \/ |__|       \/     \/    \/ 
"""
def new_game(path, list_players):
	"""
	Create a new game from a '.cis' file.

	Parameters
	----------
	path : to the cis file (str).
	list_players: list of players (list).

	Return
	-------
	game_stats : new game stats (dic).

	Version
	-------
	specification : Nicolas Van Bossuyt (v1. 09/02/2017)
			Bayron Mahy (v2. 10/02/2017)

	implementation : Bayron Mahy (v1. 10/02/2017)
			 Bayron Mahy (v2. 10/02/2017)
			 Nicolas Van Bossuyt (v3. 10/02/2017)
			 Bayron Mahy (v4. 10/02/2017)
	"""

	# Create game_stats dictionary.
	game_file = parse_game_file(path)
	game_stats = {'board':{}, 'players':{},'model_ship':{}, 'ship': {},'board_size': game_file['size'], 'rounds': 0, 'max_nb_rounds': 10*len(list_players)}

	# Create the game board.
	for line in range(game_file['size'][0]):
		for column in range(game_stats['board_size'][1]):
			game_stats['board'][(line,column)] = []

	# Create players.
	for player in list_players:
		if player == 'ai' or play_game == 'distant':
			player_type = player
		else:
			player_type = 'human'

		game_stats['players'][player] = {'name': player, 'money':100, 'nb_ship': 0, 'type':player_type, 'color':''}

	# Create ship specs sheet.
	game_stats['model_ship']['fighter']={'icon': u'F', 'max_heal':3, 'max_speed':5, 'damages':1, 'range':5, 'price':10}
	game_stats['model_ship']['destroyer']={'icon': u'D', 'max_heal':8, 'max_speed':2, 'damages':2, 'range':7, 'price':20}
	game_stats['model_ship']['battlecruiser']={'icon': u'B', 'max_heal':20, 'max_speed':1, 'damages':4, 'range':10, 'price':30}

	#place the bonus ships
	for ships in game_file['ships']:
		game_stats['ship'][ships[2]]= { 'type':ships[3], 'heal_points':game_stats['model_ship'][ships[3]]['max_heal'],'direction':ships[4], 'speed':0, 'owner': 'none', 'postion': [ships[0],ships[1]] }
		game_stats['board'][(ships[0],ships[1])].append(ships[2])

	return game_stats

def parse_game_file(path):<commit_msg>cohérence corrigées<commit_after># -*- coding: utf-8 -*-
import string
from command import *
from gui import *
from ai import *
"""
 __   __   __   ___               __   __        __   ___
/  ` /  \ |  \ |__     | |\ |    /__` |__)  /\  /  ` |__
\__, \__/ |__/ |___    | | \|    .__/ |    /~~\ \__, |___

.     .       .  .   . .   .   . .    +  .
  .     .  :     .    .. :. .___---------___.
       .  .   .    .  :.:. _".^ .^ ^.  '.. :"-_. .
    .  :       .  .  .:../:            . .^  :.:\.
        .   . :: +. :.:/: .   .    .        . . .:\
 .  :    .     . _ :::/:               .  ^ .  . .:\
  .. . .   . - : :.:./.                        .  .:\
  .      .     . :..|:                    .  .  ^. .:|
    .       . : : ..||        .                . . !:|
  .     . . . ::. ::\(                           . :)/
 .   .     : . : .:.|. ######              .#######::|
  :.. .  :-  : .:  ::|.#######           ..########:|
 .  .  .  ..  .  .. :\ ########          :######## :/
  .        .+ :: : -.:\ ########       . ########.:/
    .  .+   . . . . :.:\. #######       #######..:/
      :: . . . . ::.:..:.\           .   .   ..:/
   .   .   .  .. :  -::::.\.       | |     . .:/
      .  :  .  .  .-:.":.::.\             ..:/
 .      -.   . . . .: .:::.:.\.           .:/
.   .   .  :      : ....::_:..:\   ___.  :/
   .   .  .   .:. .. .  .: :.:.:\       :/
     +   .   .   : . ::. :.:. .:.|\  .:/|
     .         +   .  .  ...:: ..|  --.:|
.      . . .   .  .  . ... :..:.."(  ..)"
 .   .       .      :  .   .: ::/  .  .::\
 
                 .___       .__                                            
  ____  ____   __| _/____   |__| ____     _________________    ____  ____  
_/ ___\/  _ \ / __ |/ __ \  |  |/    \   /  ___/\____ \__  \ _/ ___\/ __ \ 
\  \__(  <_> ) /_/ \  ___/  |  |   |  \  \___ \ |  |_> > __ \\  \__\  ___/ 
 \___  >____/\____ |\___  > |__|___|  / /____  >|   __(____  /\___  >___  >
     \/           \/    \/          \/       \/ |__|       \/     \/    \/ 
"""
def new_game(path, list_players):
	"""
	Create a new game from a '.cis' file.

	Parameters
	----------
	path : to the cis file (str).
	list_players: list of players (list).

	Return
	-------
	game_stats : new game stats (dic).

	Version
	-------
	specification : Nicolas Van Bossuyt (v1. 09/02/2017)
			Bayron Mahy (v2. 10/02/2017)

	implementation : Bayron Mahy (v1. 10/02/2017)
			 Bayron Mahy (v2. 10/02/2017)
			 Nicolas Van Bossuyt (v3. 10/02/2017)
			 Bayron Mahy (v4. 10/02/2017)
	"""

	# Create game_stats dictionary.
	game_file = parse_game_file(path)
	game_stats = {'board':{}, 'players':{},'model_ship':{}, 'ships': {},'board_size': game_file['size'], 'nb_rounds': 0, 'max_nb_rounds': 10*len(list_players)}

	# Create the game board.
	for line in range(game_file['size'][0]):
		for column in range(game_stats['board_size'][1]):
			game_stats['board'][(line,column)] = []

	# Create players.
	for player in list_players:
		if player == 'ai' or play_game == 'distant':
			player_type = player
		else:
			player_type = 'human'

		game_stats['players'][player] = {'name': player, 'money':100, 'nb_ship': 0, 'type':player_type, 'color':''}

	# Create ship specs sheet.
	game_stats['model_ship']['fighter']={'icon': u'F', 'max_heal':3, 'max_speed':5, 'damages':1, 'range':5, 'price':10}
	game_stats['model_ship']['destroyer']={'icon': u'D', 'max_heal':8, 'max_speed':2, 'damages':2, 'range':7, 'price':20}
	game_stats['model_ship']['battlecruiser']={'icon': u'B', 'max_heal':20, 'max_speed':1, 'damages':4, 'range':10, 'price':30}

	#place the bonus ships
	for ships in game_file['ships']:
		game_stats['ships'][ships[2]]= { 'type':ships[3], 'heal_points':game_stats['model_ship'][ships[3]]['max_heal'],'direction':ships[4], 'speed':0, 'owner': 'none', 'postion': [ships[0],ships[1]] }
		game_stats['board'][(ships[0],ships[1])].append(ships[2])

	return game_stats

def parse_game_file(path):
{'fraction_non_alphanumeric': 0.2739303610432995, 'fraction_numerical': 0.02415521007323654, 'mean_word_length': 1.2458165031736872, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '873546', 'n_tokens_mistral': 3301, 'n_tokens_neox': 3021, 'n_words': 342}