- admasmaca oyunu
- Thursday, December 18th, 2008 at 3:32:39am MST
- # -*- coding: utf-8 -*-
- # adamasmaca şeysi
- # coded by rohanrhu@kubuntu 2008-11-04 saat 10:20 (sabah) suları...
- from sys import exit, stderr
- from random import choice
- from time import time
- # oyuna başlanılan zaman alınıyor...
- startTime = time()
- # ASCII resimler...
- status = ['\n\n|\n|\n|\n|\n|\n -------\n', '\n -------\n|\n|\n|\n|\n|\n -------\n',
- '\n -------\n| O\n|\n|\n|\n|\n -------\n',
- '\n -------\n| O\n| |\n| |\n|\n|\n -------\n',
- '\n -------\n| O\n| |\n| |\n| |+|\n|\n -------\n',
- '\n -------\n| O\n| |+|+|\n| |\n| |+|\n|\n -------\n']
- def index(a, b):
- """ 1. arguman ı 2. arguman içinde arar ve,
- kaçıncı elemanları oluduğunu liste halinde verir..."""
- d = []
- for i in range(len(a)):
- try:
- c = a.index(b, i)
- if c not in d:
- d.append(c)
- except: break
- return d
- def replace(a, b):
- """Liste halinde ki index den alınan elemaanları tek tek değiştirir..."""
- c = []
- for i in a:
- for f in b:
- if i == f:
- c.append(f)
- if i not in c:
- c.append("-")
- d = ""
- for i in c:
- d = d + i
- return d
- def puts(w):
- """Daha sonra gelişecek olan özel print :P"""
- print w
- def len_(a):
- """Bir eleman cümle içersinde bir den fazla yer alıyor ise,
- bu fonksiyon ile her eleman bir kere sayılıyor..."""
- b = []
- for i in a:
- if i not in b:
- b.append(i)
- return len(b)
- # kelimeleri bu listeye ekleyin...
- words = ["linux", "kubuntu", "ubuntu", "pardus", "opensource", "acik kaynak"]
- word = choice(words)
- pWord = "-" * len(word)
- tWord = []
- allPuts = []
- trues = 0
- healt = 0
- # kelimede boşluk varsa boşluk tahmini yapılmış işlemi yapılıyor...
- if " " in word:
- tWord.append(" ")
- pWord = replace(word, tWord)
- trues += 1
- while True:
- # şuan ki zaman alınıyor...
- nowTime = time()
- t = nowTime - startTime # zamanların farkı...
- t = int(t)
- pHealt = status[healt]
- writing = "%(pHealt)s\n%(pWord)s" % vars()
- puts(writing)
- if healt == 5:
- puts("%s dakika %s saniye de Asıldınız!" % (t / 60, t))
- break
- if trues == len_(word):
- puts("Tebrikler %s dakika %s saniyede, %s tahminde bildiniz..." \
- % (t / 60, t, allPuts.__len__().__str__()))
- break
- # eğer klavye kesmesi gelirse döngü "break" ile bitirilecek...
- try: put = raw_input("Tahmininiz: ")
- except: break
- # verilen yazının ilk elemanı boşluk mu diye denetleniyor...
- try:
- if (put == "") or (put[0] == " ") or (len(put) != 1):
- # öyle ise sağlık azalmadan döngü yeniden başlıyor...
- print "Geçersiz girdi... (boşluk yada tek karakter den fazla)"
- continue
- except: pass
- # eğer bu tahmin daha önce yapılmışsa uyarı veriliyor ve döngü başa dönüyor...
- if put in allPuts:
- print "Bu tahmini daha önce yapmıştınız..."
- continue
- # daha sonra denetlenmek için tahmin tüm girdilere ekleniyor...
- if put not in allPuts: allPuts.append(put)
- if put in word:
- tWord.append(put)
- pWord = replace(word, tWord)
- trues += 1
- else:
- healt += 1
- print "Oynadığınız için teşekkürler..."
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.