Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Text-to-Speech/Text-to-speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
def speaknow():
engine.say(textv.get())
engine.runAndWait()
engine.stop()

root=Tk()

Expand Down
16 changes: 11 additions & 5 deletions Tic-Tac-Toe/TicTacToe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def printBoard(board):
print(" | | ")

def isBoardFull(board):
if board.count(" ") > 1:
return False
else:
if board.count(" ") == 1:
return True
else:
return False

def isWinner(b,l): # b = board, l = letter
# check all possibilities
Expand Down Expand Up @@ -55,6 +55,10 @@ def compMove():
possibleMoves = [x for x,letter in enumerate(board) if letter == " " and x != 0]
move = 0

# If no moves available, return 0 to indicate tie game
if len(possibleMoves) == 0:
return 0

for let in ['O','X']:
for i in possibleMoves:
boardCopy = board[:]
Expand Down Expand Up @@ -82,10 +86,12 @@ def compMove():
if i in [2,4,6,8]:
edgeOpen.append(i)


if len(edgeOpen) > 0:
move = selectRandom(edgeOpen)
return move

# If we reach here, return 0 (shouldn't happen with proper logic)
return 0

def selectRandom(list_):
import random
Expand Down Expand Up @@ -114,7 +120,7 @@ def main():

if move == 0:
print("Tie game")

break
else:
insertLetter("O", move)
print(f"Computer place O on position {move}")
Expand Down