From bd2f00543afa8edddb1f10a3f4ab8521f52a3379 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sun, 22 Feb 2015 13:10:54 +0100 Subject: [PATCH] TP3 afficher_jeu Plus performant --- S2/TP3/bataille_navale.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/S2/TP3/bataille_navale.py b/S2/TP3/bataille_navale.py index ecaef9b..33c15a8 100755 --- a/S2/TP3/bataille_navale.py +++ b/S2/TP3/bataille_navale.py @@ -301,16 +301,18 @@ def afficher_jeu(jeu): """ if jeu['plateau']['larg'] > 30: return + s = '' for x in range(1, jeu['plateau']['larg']+1): for y in range(1, jeu['plateau']['haut']+1): if (x, y) in jeu['coups_joues']: if (x, y) in jeu['plateau']: - print('o', end=' ') + s += 'o ' else: - print('x', end=' ') + s += 'x ' else: - print('.', end=' ') - print() + s += '. ' + s += '\n' + print(s) def lire_un_tir(nom): """