Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 3.144.108.200
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
lib64 /
python2.7 /
Demo /
turtle /
[ HOME SHELL ]
Name
Size
Permission
Action
about_turtle.txt
3.44
KB
-rw-r--r--
about_turtledemo.txt
302
B
-rw-r--r--
demohelp.txt
2.38
KB
-rw-r--r--
tdemo_I_dontlike_tiltdemo.py
1.05
KB
-rw-r--r--
tdemo_I_dontlike_tiltdemo.pyc
1.62
KB
-rw-r--r--
tdemo_I_dontlike_tiltdemo.pyo
1.62
KB
-rw-r--r--
tdemo_bytedesign.py
4.12
KB
-rw-r--r--
tdemo_bytedesign.pyc
5.19
KB
-rw-r--r--
tdemo_bytedesign.pyo
5.19
KB
-rw-r--r--
tdemo_chaos.py
953
B
-rw-r--r--
tdemo_chaos.pyc
2.24
KB
-rw-r--r--
tdemo_chaos.pyo
2.24
KB
-rw-r--r--
tdemo_clock.py
2.95
KB
-rw-r--r--
tdemo_clock.pyc
4.38
KB
-rw-r--r--
tdemo_clock.pyo
4.38
KB
-rw-r--r--
tdemo_colormixer.py
1.31
KB
-rw-r--r--
tdemo_colormixer.pyc
2.31
KB
-rw-r--r--
tdemo_colormixer.pyo
2.31
KB
-rw-r--r--
tdemo_fractalcurves.py
3.33
KB
-rw-r--r--
tdemo_fractalcurves.pyc
3.44
KB
-rw-r--r--
tdemo_fractalcurves.pyo
3.44
KB
-rw-r--r--
tdemo_lindenmayer_indian.py
2.38
KB
-rw-r--r--
tdemo_lindenmayer_indian.pyc
3.52
KB
-rw-r--r--
tdemo_lindenmayer_indian.pyo
3.52
KB
-rw-r--r--
tdemo_minimal_hanoi.py
1.92
KB
-rw-r--r--
tdemo_minimal_hanoi.pyc
3.5
KB
-rw-r--r--
tdemo_minimal_hanoi.pyo
3.5
KB
-rw-r--r--
tdemo_nim.py
6.43
KB
-rw-r--r--
tdemo_nim.pyc
9.16
KB
-rw-r--r--
tdemo_nim.pyo
9.16
KB
-rw-r--r--
tdemo_paint.py
1.1
KB
-rw-r--r--
tdemo_paint.pyc
1.7
KB
-rw-r--r--
tdemo_paint.pyo
1.7
KB
-rw-r--r--
tdemo_peace.py
1.09
KB
-rw-r--r--
tdemo_peace.pyc
1.41
KB
-rw-r--r--
tdemo_peace.pyo
1.41
KB
-rw-r--r--
tdemo_penrose.py
3.45
KB
-rw-r--r--
tdemo_penrose.pyc
5.86
KB
-rw-r--r--
tdemo_penrose.pyo
5.86
KB
-rw-r--r--
tdemo_planet_and_moon.py
2.77
KB
-rw-r--r--
tdemo_planet_and_moon.pyc
4.44
KB
-rw-r--r--
tdemo_planet_and_moon.pyo
4.44
KB
-rw-r--r--
tdemo_tree.py
1.38
KB
-rw-r--r--
tdemo_tree.pyc
2.07
KB
-rw-r--r--
tdemo_tree.pyo
2.07
KB
-rw-r--r--
tdemo_wikipedia.py
1.32
KB
-rw-r--r--
tdemo_wikipedia.pyc
1.91
KB
-rw-r--r--
tdemo_wikipedia.pyo
1.91
KB
-rw-r--r--
tdemo_yinyang.py
808
B
-rw-r--r--
tdemo_yinyang.pyc
1.29
KB
-rw-r--r--
tdemo_yinyang.pyo
1.29
KB
-rw-r--r--
turtle.cfg
160
B
-rw-r--r--
turtleDemo.py
9.94
KB
-rw-r--r--
turtleDemo.pyc
9.97
KB
-rw-r--r--
turtleDemo.pyo
9.97
KB
-rw-r--r--
turtledemo_two_canvases.py
885
B
-rw-r--r--
turtledemo_two_canvases.pyc
1.22
KB
-rw-r--r--
turtledemo_two_canvases.pyo
1.22
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : tdemo_nim.py
""" turtle-example-suite: tdemo_nim.py Play nim against the computer. The player who takes the last stick is the winner. Implements the model-view-controller design pattern. """ import turtle import random import time SCREENWIDTH = 640 SCREENHEIGHT = 480 MINSTICKS = 7 MAXSTICKS = 31 HUNIT = SCREENHEIGHT // 12 WUNIT = SCREENWIDTH // ((MAXSTICKS // 5) * 11 + (MAXSTICKS % 5) * 2) SCOLOR = (63, 63, 31) HCOLOR = (255, 204, 204) COLOR = (204, 204, 255) def randomrow(): return random.randint(MINSTICKS, MAXSTICKS) def computerzug(state): xored = state[0] ^ state[1] ^ state[2] if xored == 0: return randommove(state) for z in range(3): s = state[z] ^ xored if s <= state[z]: move = (z, s) return move def randommove(state): m = max(state) while True: z = random.randint(0,2) if state[z] > (m > 1): break rand = random.randint(m > 1, state[z]-1) return z, rand class NimModel(object): def __init__(self, game): self.game = game def setup(self): if self.game.state not in [Nim.CREATED, Nim.OVER]: return self.sticks = [randomrow(), randomrow(), randomrow()] self.player = 0 self.winner = None self.game.view.setup() self.game.state = Nim.RUNNING def move(self, row, col): maxspalte = self.sticks[row] self.sticks[row] = col self.game.view.notify_move(row, col, maxspalte, self.player) if self.game_over(): self.game.state = Nim.OVER self.winner = self.player self.game.view.notify_over() elif self.player == 0: self.player = 1 row, col = computerzug(self.sticks) self.move(row, col) self.player = 0 def game_over(self): return self.sticks == [0, 0, 0] def notify_move(self, row, col): if self.sticks[row] <= col: return self.move(row, col) class Stick(turtle.Turtle): def __init__(self, row, col, game): turtle.Turtle.__init__(self, visible=False) self.row = row self.col = col self.game = game x, y = self.coords(row, col) self.shape("square") self.shapesize(HUNIT/10.0, WUNIT/20.0) self.speed(0) self.pu() self.goto(x,y) self.color("white") self.showturtle() def coords(self, row, col): packet, remainder = divmod(col, 5) x = (3 + 11 * packet + 2 * remainder) * WUNIT y = (2 + 3 * row) * HUNIT return x - SCREENWIDTH // 2 + WUNIT // 2, SCREENHEIGHT // 2 - y - HUNIT // 2 def makemove(self, x, y): if self.game.state != Nim.RUNNING: return self.game.controller.notify_move(self.row, self.col) class NimView(object): def __init__(self, game): self.game = game self.screen = game.screen self.model = game.model self.screen.colormode(255) self.screen.tracer(False) self.screen.bgcolor((240, 240, 255)) self.writer = turtle.Turtle(visible=False) self.writer.pu() self.writer.speed(0) self.sticks = {} for row in range(3): for col in range(MAXSTICKS): self.sticks[(row, col)] = Stick(row, col, game) self.display("... a moment please ...") self.screen.tracer(True) def display(self, msg1, msg2=None): self.screen.tracer(False) self.writer.clear() if msg2 is not None: self.writer.goto(0, - SCREENHEIGHT // 2 + 48) self.writer.pencolor("red") self.writer.write(msg2, align="center", font=("Courier",18,"bold")) self.writer.goto(0, - SCREENHEIGHT // 2 + 20) self.writer.pencolor("black") self.writer.write(msg1, align="center", font=("Courier",14,"bold")) self.screen.tracer(True) def setup(self): self.screen.tracer(False) for row in range(3): for col in range(self.model.sticks[row]): self.sticks[(row, col)].color(SCOLOR) for row in range(3): for col in range(self.model.sticks[row], MAXSTICKS): self.sticks[(row, col)].color("white") self.display("Your turn! Click leftmost stick to remove.") self.screen.tracer(True) def notify_move(self, row, col, maxspalte, player): if player == 0: farbe = HCOLOR for s in range(col, maxspalte): self.sticks[(row, s)].color(farbe) else: self.display(" ... thinking ... ") time.sleep(0.5) self.display(" ... thinking ... aaah ...") farbe = COLOR for s in range(maxspalte-1, col-1, -1): time.sleep(0.2) self.sticks[(row, s)].color(farbe) self.display("Your turn! Click leftmost stick to remove.") def notify_over(self): if self.game.model.winner == 0: msg2 = "Congrats. You're the winner!!!" else: msg2 = "Sorry, the computer is the winner." self.display("To play again press space bar. To leave press ESC.", msg2) def clear(self): if self.game.state == Nim.OVER: self.screen.clear() class NimController(object): def __init__(self, game): self.game = game self.sticks = game.view.sticks self.BUSY = False for stick in self.sticks.values(): stick.onclick(stick.makemove) self.game.screen.onkey(self.game.model.setup, "space") self.game.screen.onkey(self.game.view.clear, "Escape") self.game.view.display("Press space bar to start game") self.game.screen.listen() def notify_move(self, row, col): if self.BUSY: return self.BUSY = True self.game.model.notify_move(row, col) self.BUSY = False class Nim(object): CREATED = 0 RUNNING = 1 OVER = 2 def __init__(self, screen): self.state = Nim.CREATED self.screen = screen self.model = NimModel(self) self.view = NimView(self) self.controller = NimController(self) mainscreen = turtle.Screen() mainscreen.mode("standard") mainscreen.setup(SCREENWIDTH, SCREENHEIGHT) def main(): nim = Nim(mainscreen) return "EVENTLOOP!" if __name__ == "__main__": main() turtle.mainloop()
Close