Ed ecco la seconda versione del gioco più appasionante del momento!
Tutti lo vogliono!
Nato grazie alla collaborazione con Risca .
Guarda l'ultima versione qui !
- Migliorata grafica schema;
- risolto problemi di rilevamento vicinanza alla pepita;
- inseriti indici numerici del campo;
- memorizzazione e visualizzazione dei tentativi falliti;
- eliminata la possibilità di fare più volte lo stesso errore;
#! / Usr / bin / env python3.1
# -*- coding: utf-8 -*-
"" "
game demo created for the Academy debianized.
Copyright 2011 Risca \u0026lt;risca at altervista (cancella questo)dot org>
Copyright 2011 TuxErrante \u0026lt;trimurtide at gmail (delete this)dot com>
GPLv2 or later
"" "
import sys
import random
errore = []
benvenuto = " \ n \ n \ n \ n \ n \ nBenvenuto nella miniera TuxErrante & Risca co .!\ n \
Sarò lieto di condividere con te il nostro oro , a patto che \
tu riesca a trovarlo !\ n \
Hai { 0 } cariche di esplosivo e { 1 } cave to explore . \\ n \\
you ready? \\ nHere diagram of yard \\ n "
nugget # = [-10, -10]
final stampaCantiere ( field, nugget = [- 10 - 10 ] error =[]):
step # if the nugget then it must check the cell to cell
# which is the right where to put
print ( "-" * 50 )
print ( " " , end = ' ' )
for i in range ( campo ):
if i < 9 :
print ( "{} " . format ( i + 1 ), end = ' ' )
else :
print ( "{}" . format ( i + 1 ), end = ' ' )
print ()
for r in range ( campo ):
if r < 9 :
print ( ' {}' . format ( r + 1 ), end = ' ' )
else :
print ( r + 1 , end = ' ' )
for c in range ( field ):
if [ r, c ] in error:
print ( "O" , end = '' )
elif r == nugget [0 ] and c == nugget [ 1]:
print ( "X" , end = '' )
else :
print ( . " , end = '' )
print () # wraps for each new line
final trovaPepita ( tent, field ):
"" "\\ nCreate an array of size field * field where it poses a 'nugget' so
randomInt random through the function ( ) that we must try to find
to win. If the distance between the 'quarry' and added that the nugget is
one, will warn us of the neighborhood. \\ n
Can 'be invoked without arguments, in case the default values \u200b\u200b
6 attempts and will be a 6x6 matrix, otherwise takes two numbers where
the number of attempts must be less than the number of slots. "
if tent > = \u200b\u200b field * field :
exit ( "So you can not 'play!" )
print ( welcome. format ( tent, field * field ))
# get the coordinates of the nugget randomly between 0
# and the size of the field-1 =
nugget [ random. randInt (0 , field - 1) random. randInt (0 , field - 1)]
stampaCantiere ( field ) # print the blank
while tent > 0 :
bangx = input ( " \ n Inserisci le coordinate in cui vuoi piazzare la mina \
comprese tra [ 1 ..{}] \ n x = " . format ( campo ))
bangy = input ( " y = " )
if not bangx . isnumeric () or not bangy . isnumeric ():
print ( " Inserisci delle coordinate numeriche per favore! \n" )
continue
else :
bangx , bangy = int ( bangx ), int ( bangy )
bangx -= 1 -=
bangy 1
if bangx \u0026lt;0 or bangx > = \u200b\u200b field or bangy \u0026lt;0 or bangy > = \u200b\u200b field :
print ( "Please enter the correct coordinates ! \\ n \\
Remember those you have in hand are explosive! \\ n ")
continuous
else : # coordinates entered eligible
if ( nugget [ 0] == bangx ) and ( nugget [ 1] == bangy ):
# svela dove è la pepita !
print ( "coordinate segrete {},{}" . format ( pepita [ 0 ], pepita [ 1 ]))
stampaCantiere ( campo , pepita , errore )
exit ( " Complimenti !! L'hai trovata ! Siamo ricchiiiii \\ n \\
We need a percentage , remember! ")
elif ([ bangx , bangy ] in error): print
( " to err is human to persevere is diabolical " )
continuous
else : # says whether or not you are away from the nugget
tent -= 1
errore . append ([ bangx , bangy ]) # inserisco nella lista errori
print ( "\n" )
stampaCantiere ( campo ,[- 10 ,- 10 ], errore )
testX = abs ( Pepita [ 0 ] - bangx )
test = abs ( Pepita [ 1 ] - bang )
if ( testX == 1 or testX == 0 ) and ( test == 1 or test == 0 ):
print ( "We're close!" )
else :
print ( "No, no , we have not. \\ n " )
if tent > = \u200b\u200b1 :
print ( " Then try again! " )
else :
print ( "\n Peccato che abbia finito l'esplosivo !!\n Ecco dov'era :" )
stampaCantiere ( campo , pepita , errore )
# chiamata della funzione principale
# se viene chiamata senza argomenti gli verranno passati di default 6 e 6
# chiamare lo script con '-h' per vedere la documentazione
if len ( sys . argv ) == 3 :
trovaPepita ( int ( sys . argv [ 1 ]), int ( sys . argv [ 2 ]))
elif len ( sys . argv ) == 2 and sys . argv [ 1 ] == '-h' :
print ( trovaPepita . __doc__ )
else :
trovaPepita ( 6 , 6 )
- puoi trovarlo anche qui
0 comments:
Post a Comment