Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9a62448d
Kaydet (Commit)
9a62448d
authored
Nis 10, 2002
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use random module instead of whrandom
Move imports to top
üst
3b2625ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
life.py
Demo/curses/life.py
+4
-4
No files found.
Demo/curses/life.py
Dosyayı görüntüle @
9a62448d
...
@@ -17,6 +17,9 @@
...
@@ -17,6 +17,9 @@
# Make board updates faster
# Make board updates faster
#
#
import
random
,
string
,
traceback
import
curses
class
LifeBoard
:
class
LifeBoard
:
"""Encapsulates a Life board
"""Encapsulates a Life board
...
@@ -118,11 +121,10 @@ class LifeBoard:
...
@@ -118,11 +121,10 @@ class LifeBoard:
def
makeRandom
(
self
):
def
makeRandom
(
self
):
"Fill the board with a random pattern"
"Fill the board with a random pattern"
import
whrandom
self
.
state
=
{}
self
.
state
=
{}
for
i
in
range
(
0
,
self
.
X
):
for
i
in
range
(
0
,
self
.
X
):
for
j
in
range
(
0
,
self
.
Y
):
for
j
in
range
(
0
,
self
.
Y
):
if
whrandom
.
random
()
*
10
>
5.0
:
self
.
set
(
j
,
i
)
if
random
.
random
()
>
0.5
:
self
.
set
(
j
,
i
)
def
erase_menu
(
stdscr
,
menu_y
):
def
erase_menu
(
stdscr
,
menu_y
):
...
@@ -139,7 +141,6 @@ def display_menu(stdscr, menu_y):
...
@@ -139,7 +141,6 @@ def display_menu(stdscr, menu_y):
'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit'
)
'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit'
)
def
main
(
stdscr
):
def
main
(
stdscr
):
import
string
,
curses
# Clear the screen and display the menu of keys
# Clear the screen and display the menu of keys
stdscr
.
clear
()
stdscr
.
clear
()
...
@@ -196,7 +197,6 @@ def main(stdscr):
...
@@ -196,7 +197,6 @@ def main(stdscr):
else
:
pass
# Ignore incorrect keys
else
:
pass
# Ignore incorrect keys
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
curses
,
traceback
try
:
try
:
# Initialize curses
# Initialize curses
stdscr
=
curses
.
initscr
()
stdscr
=
curses
.
initscr
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment