Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
108 changes: 108 additions & 0 deletions Project templates/u1_battleship/final.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
from random import randint
enem_board = [[u"\U0001F30A"]*5 for n in range(5)]
frnd_board = [[u"\U0001F30A"]*5 for n in range(5)]
name = "Sa'ar"
def print_board(frnd, enem):
print("CPU")
print(end=" ")
for i in range(1, len(enem[0])+1):
print(i, end=" ")
print()
for i in range(1, len(enem[0])+1):
row = enem[i-1]
print(i," ".join(row))
print("-".join(["--"]*5))
print(name)
print(end=" ")
for i in range(1, len(frnd[0])+1):
print(i, end=" ")
print()
for i in range(1, len(frnd)+1):
row = frnd[i-1]
print(i," ".join(row))
print()
#computer hide
row = randint(0, len(enem_board)-1)
col = randint(0, len(enem_board[0])-1)
#player hide
pr = None
pc = None
while pr == None and pc == None:
if pr == None:
pr = randint(1, len(frnd_board))
pr -= 1
if pc == None:
pc = randint(1, len(frnd_board))
pc -= 1
if pc < 0 or pc >= len(frnd_board[0]):
pc = None
if pr < 0 or pr > len(frnd_board):
pr = None
else:
print(pr+1,pc+1)
frnd_board[pr][pc] = u"\U0001F6A2"

won = False
lost = False
while (not won) and (not lost):
print_board(frnd_board, enem_board)
print("CPU: ")
t = False
while not t:
gr = randint(0, len(frnd_board)-1)
gc = randint(0, len(frnd_board[0])-1)
if frnd_board[gr][gc] != u"\U0001F4A3":
t = True
print("Row: ",gr+1)
print("Column: ",gc+1)
print()
if frnd_board[gr][gc] == u"\U0001F6A2":
lost = True
frnd_board[gr][gc] = u"\U0001F4A5"
print("Hit!")
break
else:
frnd_board[gr][gc] = u"\U0001F4A3"
print("Miss!")
print()
print_board(frnd_board, enem_board)
print(name+":")
gr = randint(1, len(enem_board))
gr -= 1
print("Row:",gr)
gc = randint(1, len(enem_board[0]))
gc -= 1
print("Column:",gc)
print()
if gr == row and gc == col:
print("Hit!")
enem_board[gr][gc] = u"\U0001F4A5"
won = True
elif gr < 0 or gr >= len(enem_board) or gc < 0 or gc >= len(enem_board[0]):
print("That's not even in the ocean ):")
elif enem_board[gr][gc] == u"\U0001F4A3":
print("You already guessed that, stupid! DX")
else:
print("Miss!")
print()
enem_board[gr][gc] = u"\U0001F4A3"
if won:
for i in range(len(enem_board)):
for j in range(len(enem_board[i])):
if not enem_board[i][j] == u"\U0001F4A3":
enem_board[i][j] = u"\U0001F525"
else:
enem_board[i][j] = u"\u2620"
enem_board[row][col] = u"\U0001F4A5"
print("Congrats on winning!")
if lost:
for i in range(len(frnd_board)):
for j in range(len(frnd_board[i])):
if not frnd_board[i][j] == u"\U0001F4A3":
frnd_board[i][j] = u"\U0001F525"
else:
frnd_board[i][j] = u"\u2620"
frnd_board[pr][pc] = u"\U0001F4A5"
enem_board[row][col] = u"\U0001F6A2"
print("You sax. Better luck next time!")
print_board(frnd_board, enem_board)
Binary file modified __pycache__/mainloop.cpython-34.pyc
Binary file not shown.
Binary file modified __pycache__/screens.cpython-34.pyc
Binary file not shown.
Binary file modified __pycache__/screens.cpython-35.pyc
Binary file not shown.
Binary file modified __pycache__/window.cpython-34.pyc
Binary file not shown.
Binary file modified dist/LearnPythonWithPython.exe
Binary file not shown.
Binary file added dist/_bz2.pyd
Binary file not shown.
Binary file added dist/_ctypes.pyd
Binary file not shown.
Binary file added dist/_hashlib.pyd
Binary file not shown.
Binary file added dist/_lzma.pyd
Binary file not shown.
Binary file added dist/_socket.pyd
Binary file not shown.
Binary file added dist/_ssl.pyd
Binary file not shown.
Binary file added dist/_tkinter.pyd
Binary file not shown.
Binary file added dist/library.zip
Binary file not shown.
Binary file added dist/pyexpat.pyd
Binary file not shown.
Binary file added dist/python34.dll
Binary file not shown.
Binary file added dist/select.pyd
Binary file not shown.
7 changes: 7 additions & 0 deletions dist/tcl/dde1.4/pkgIndex.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if {([info commands ::tcl::pkgconfig] eq "")
|| ([info sharedlibextension] ne ".dll")} return
if {[::tcl::pkgconfig get debug]} {
package ifneeded dde 1.4.0 [list load [file join $dir tcldde14g.dll] dde]
} else {
package ifneeded dde 1.4.0 [list load [file join $dir tcldde14.dll] dde]
}
Binary file added dist/tcl/dde1.4/tcldde14.dll
Binary file not shown.
148 changes: 148 additions & 0 deletions dist/tcl/itcl4.0.0/itcl.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#
# itcl.tcl
# ----------------------------------------------------------------------
# Invoked automatically upon startup to customize the interpreter
# for [incr Tcl].
# ----------------------------------------------------------------------
# AUTHOR: Michael J. McLennan
# Bell Labs Innovations for Lucent Technologies
# [email protected]
# http://www.tcltk.com/itcl
# ----------------------------------------------------------------------
# Copyright (c) 1993-1998 Lucent Technologies, Inc.
# ======================================================================
# See the file "license.terms" for information on usage and
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.

proc ::itcl::delete_helper { name args } {
::itcl::delete object $name
}

# ----------------------------------------------------------------------
# USAGE: local <className> <objName> ?<arg> <arg>...?
#
# Creates a new object called <objName> in class <className>, passing
# the remaining <arg>'s to the constructor. Unlike the usual
# [incr Tcl] objects, however, an object created by this procedure
# will be automatically deleted when the local call frame is destroyed.
# This command is useful for creating objects that should only remain
# alive until a procedure exits.
# ----------------------------------------------------------------------
proc ::itcl::local {class name args} {
set ptr [uplevel [list $class $name] $args]
uplevel [list set itcl-local-$ptr $ptr]
set cmd [uplevel namespace which -command $ptr]
uplevel [list trace variable itcl-local-$ptr u \
"::itcl::delete_helper $cmd"]
return $ptr
}

# ----------------------------------------------------------------------
# auto_mkindex
# ----------------------------------------------------------------------
# Define Itcl commands that will be recognized by the auto_mkindex
# parser in Tcl...
#

#
# USAGE: itcl::class name body
# Adds an entry for the given class declaration.
#
foreach cmd {itcl::class class itcl::type type ictl::widget widget itcl::widgetadaptor widgetadaptor itcl::extendedclass extendedclass} {
auto_mkindex_parser::command $cmd {name body} {
variable index
variable scriptFile
append index "set [list auto_index([fullname $name])]"
append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"

variable parser
variable contextStack
set contextStack [linsert $contextStack 0 $name]
$parser eval $body
set contextStack [lrange $contextStack 1 end]
}
}

#
# USAGE: itcl::body name arglist body
# Adds an entry for the given method/proc body.
#
foreach cmd {itcl::body body} {
auto_mkindex_parser::command $cmd {name arglist body} {
variable index
variable scriptFile
append index "set [list auto_index([fullname $name])]"
append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
}
}

#
# USAGE: itcl::configbody name arglist body
# Adds an entry for the given method/proc body.
#
foreach cmd {itcl::configbody configbody} {
auto_mkindex_parser::command $cmd {name body} {
variable index
variable scriptFile
append index "set [list auto_index([fullname $name])]"
append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
}
}

#
# USAGE: ensemble name ?body?
# Adds an entry to the auto index list for the given ensemble name.
#
foreach cmd {itcl::ensemble ensemble} {
auto_mkindex_parser::command $cmd {name {body ""}} {
variable index
variable scriptFile
append index "set [list auto_index([fullname $name])]"
append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
}
}

#
# USAGE: public arg ?arg arg...?
# protected arg ?arg arg...?
# private arg ?arg arg...?
#
# Evaluates the arguments as commands, so we can recognize proc
# declarations within classes.
#
foreach cmd {public protected private} {
auto_mkindex_parser::command $cmd {args} {
variable parser
$parser eval $args
}
}

# ----------------------------------------------------------------------
# auto_import
# ----------------------------------------------------------------------
# This procedure overrides the usual "auto_import" function in the
# Tcl library. It is invoked during "namespace import" to make see
# if the imported commands reside in an autoloaded library. If so,
# stubs are created to represent the commands. Executing a stub
# later on causes the real implementation to be autoloaded.
#
# Arguments -
# pattern The pattern of commands being imported (like "foo::*")
# a canonical namespace as returned by [namespace current]

proc auto_import {pattern} {
global auto_index

set ns [uplevel namespace current]
set patternList [auto_qualify $pattern $ns]

auto_load_index

foreach pattern $patternList {
foreach name [array names auto_index $pattern] {
if {"" == [info commands $name]} {
::itcl::import::stub create $name
}
}
}
}
Binary file added dist/tcl/itcl4.0.0/itcl40t.dll
Binary file not shown.
Loading