SFC86 - Parva Semihora Dignitatis...
Wednesday, February 23, 2011
Tuesday, February 22, 2011
Coffin Plans Halloween
[Python3.1] Find the nugget 2.0!
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 !
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
Thursday, February 17, 2011
Brown Hair With Purple Highlights
[Python3.1] Find the nugget!
A little game in python3.1, just to get the hang of the function call, the doctype and to build on an idea born in the bus to provide material to ' Academy :)
A little game in python3.1, just to get the hang of the function call, the doctype and to build on an idea born in the bus to provide material to ' Academy :)
#! / Usr / bin / env python3.1
# -*- coding: utf-8 -*-
import sys import
random
final stampaCantiere ( field, nugget = None): #
step if the nugget is then checked cell by cell
# which is the right where to put
if nugget! = None :
for r in range ( field ):
for c in range ( campo ):
if r == pepita [ 0 ] and c == pepita [ 1 ]:
print ( " '' ) print
() # altrimenti fai una stampa veloce
# separo i due casi per evitare di eseguire sempre del codice molto pesante else : for
i in range
( campo ):
( "
trovaPepita ( tent, field ): "" "\\ nCreate an array of size field * field where it poses a 'nugget' so random through the randomInt 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.
Can 'be invoked without arguments, in case the default values \u200b\u200b saranno 6 tentativi e una matrice 6x6, altrimenti accetta due numeri dove il numero dei tentativi deve essere inferiore al numero delle cave."""
if
tent >= campo *
campo :
exit (
" Così non si puo' giocare! " )
print (
" \ n Benvenuto nella miniera di TuxErrante !
\ n Sarò lieto di \ condividere con te il mio oro
,
as long as you manage to find ! \\ N \\ You {0}
explosive charges and {1} caves to explore. \\ n
\\ Are you ready? \\ n is the outline of yard \\ n ".
format ( tent,
field field *)) # get the coordinates 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 [ 0 ..{}] \ n x =
"
. format ( campo - 1
)) 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 ) if bangx <
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 ): reveals where # is the nugget!
print ( "coordinate secret {},{}" . format ( nugget [0 ] nugget [ 1])) stampaCantiere
( field, nugget )
exit ( "Congratulations! You found it! We ricchiiiii !! " ) else : # says if you are away or less from the nugget tent -= 1 if
abs ( nugget [0
] - bangx ) ==
1 or abs (
pepita [ 1
] - bangy ) == 1 : print ( " Ci sei vicino !!" ) else : print ( " No, no, non ci siamo. \n" ) if tent >= 1 :
print ( " Dai ritenta !!" )
else :
print ( " Peccato che abbia finito l'esplosivo !! \n Ecco dov'era :" )
stampaCantiere ( campo , pepita )
# 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 )
Go to last version!
Thursday, January 6, 2011
Subscribe to:
Comments (Atom)