Beginner Tic Tac Toe Game for Python

I am a beginner programmer and would like some feedback on this Tic Tac Toe game I made on Python. Any feedback would be appreciated, as I really want to get better at programming and pick up good habits. Here is my code. Something I would add is ‘try’ statements for invalid user input, but this is not important as I would like feedback on how to optimise this code. I would also love feedback on the check_if_win() function as I believe there might be a better way of doing this. Thank you!

"""Tic Tac Toe"""  __author__ = "Enrique Gonzalez Aretos"  EMPTY = " " PLAYER_1 = "X" PLAYER_2 = "O"  # Create Board def create_board():     """     Function which creates an empty game board     :return: <list<list<str>>> Returns the game board     """     return [         [EMPTY, EMPTY, EMPTY],         [EMPTY, EMPTY, EMPTY],         [EMPTY, EMPTY, EMPTY]     ] # Show board def show_board(board):     """     Function which prints the board for the user     :param board: <list<list<str>>> The Tic Tac Toe board     :return: <str> A clean-looking version of the board     """     for x in board:         # Find better way to print this         print("|".join(x))  # Place X on spot def place_player(board, active_player, row, column):     """     Function which places the player into the board     :param board:     :param active_player:     :param row:     :param column:     :return:     """     if board[row-1][column-1] == EMPTY:         board[row-1][column-1] = active_player  # Check if someone has won def check_if_win(board, active_player):     """     Function which checks if the active player has won     :param board: <list<list<str>>> Tic Tac Toe Board     :param active_player: <str> The current active player     :return: <bool> Return True or False     """     # Making lists which will store the diagonals and columns of baord     diagonal1 = []     diagonal2 = []     column1 = []     column2 = []     column3 = []     # Diagonal counter is used to index the different values in each row     diagonal_counter = 1     for row in board:         # When each row is checked, the different indexes are organised         # into the column and diagonal lists         column1.append(row[0])         column2.append(row[1])         column3.append(row[2])         diagonal1.append(row[diagonal_counter-1])         diagonal2.append(row[-diagonal_counter])         diagonal_counter += 1         if "".join(row) == active_player * 3:             return True      # If statement which checks if any list is full of the active      # player's symbol     if "".join(column1) == active_player * 3 or "".join(column2) ==      active_player * 3 or "".join(column3) == active_player * 3:         return True     elif "".join(diagonal1) == active_player * 3 or "".join(diagonal2)      == active_player * 3:         return True     else:         return False  def swap_player(active_player):     if active_player == PLAYER_1:         return PLAYER_2     else:         return PLAYER_1   def main():     # Creates board and assigns starting player     board = create_board()     active_player = PLAYER_1     while True:         show_board(board)         # Ask for player input         row = int(input("\nIt is {}'s turn play. Choose a row (1-3):                ".format(active_player)))         column = int(input("Choose a column: "))         place_player(board, active_player, row, column)         # Checks if player has won         if check_if_win(board, active_player) is True:             show_board(board)             print("\n{} won!".format(active_player))             break         active_player = swap_player(active_player)  if __name__ == "__main__":     main() 

Night-time football game under field lights

I am shooting a little league football game at night under the field lights for the first time amd I have a few questions to ask.

I will be using the Canon EOS 60D camera with a Canon 24-70mm 1:2.8 L lens and a Canon 580EX Speedlite .

I’m looking for some tips about ISO speed and shutter speed (I obviously will have to experiment with various combinations of both). I intend to use autofocus and the manual shutter mode.

In the old days (with film), it was risky using too fast an ISO setting because of the grain problem. I hear that this may not be a problem with digital cameras. Is that true? Also, how important is the Speedlite when I will be far from the action?

Naruto Online Game Guides – Most Related Keywords Ranking First Page Google

Why are you selling this site?
I'm looking for urgent funding to other big projects I'm working on.

How is it monetized?
AdSense. But the niche is not AdSense friendly so it's not making much from Adsense

Does this site come with any social media accounts?
Yes, there is a Facebook account with 590 organic likes.

How much time does this site take to run?
Depends on how much time the buyer wants to spend. The site is about adding contents related to Naruto Online…

Naruto Online Game Guides – Most Related Keywords Ranking First Page Google

Simple Rock, Paper, Scissors Python Game

I tried to learn Python during the weekend and after getting some knowledge, decided to make a small rock, paper, scissors game. I would be grateful for your inputs on how I could improve my code. All feedback is highly appreciated c:

import random   def round_winner(choice):     ai_chosen = str(random.randint(1, 3))     print(f'AI chose {ai_chosen}')      if choice == '1' and ai_chosen == '2':         return 'ai'     elif choice == '2' and ai_chosen == '3':         return 'ai'     elif choice == '3' and ai_chosen == '1':         return 'ai'     elif choice == ai_chosen:         return 'tie'     else:         return 'player'   def display_round_winner(winner):     if winner == 'tie':         print('This round is tied!')     else:         print(f'The winner this round is the {winner.upper()}')      print(f'''     Current points as follows:     Player: {counter['player']}     AI: {counter['ai']}     Rounds Tied: {counter['tie']}     ''')   def score_checker():     global game_ongoing     for key, value in counter.items():         if value == 2:             print(f'{key.upper()} wins the game!')             game_ongoing = False   def initializer():     global counter     message = '''     Please choose one of the following:     1: Rock     2: Paper     3: Scissors     '''      print(message)      choice_of_obj = input('What will it be: ')     if choice_of_obj in ['1', '2', '3']:         winner = round_winner(choice_of_obj)         counter[winner] += 1         display_round_winner(winner)         score_checker()     else:         print('Out of bounds')   counter = {     'player': 0,     'ai': 0,     'tie': 0 }  game_ongoing = True  while game_ongoing:     initializer() 

Exception on running game with proton

I got Ubuntu 18.04, I installed newest version of Steam, then I get Proton. When I’m trying to run game Call to Arms, there’s EXCEPTIO_ACCESS_VIOLATION: screen

Any idea why it’s happen? It looks like problem with rigths (steam & game is in my home dir). I was thinking about running steam with sudo, but I read on internet that it could crash system.

Formal justification of the Chaos game in the Sierpinsky triangle

I want to justify why the Chaos game works to produce Sierpinsky triangle. I use a theorem taken from Massopoust Interpolation and Approximation with Splines and Fractals.

Suppose that $ (X,d)$ is a compact metric space and $ (X,F,P)$ is an IFS with probabilities. Futher assume that $ m \in P(X)$ is the invariant fractal measure. Let $ x_0 \in X$ be arbitrary and let $ x_k = f_i(x_{k-1})$ for $ k \in \mathbb{N}$ where $ f_i \in F$ is chosen with probability $ p_i \in P$ .

Then, for almost all random sequences $ \{x_k\}$ , the following equality holds: $ $ \mu(A) = \lim_{k \to \infty} \frac{N(A \cap \{x_l:l = 0,1,\ldots,k)\})}{k+1}$ $ for all $ A \in B(H(X))$ with $ m(fr(A)) = 0$ and where $ N(B)$ denotes the number of points in set $ B$ .

The right hand side of the equation represents the fraction of points that lie on set $ A$ . So if I choose the IFS generating the Sierpinsky triangle such as in this video I would need that $ \mu(\mathcal{a}) \sim 1$ where $ \mathcal{a}$ is the Sierpinski triangle.

I tried to compute by hand the invariant fractal measure for the IFS that produces the Sierpinsky triangle but I was obtaining a wrong results. Is that the right way to go? How can I justify that the chaos game produces the Sierpinsky triangle in the limit using this theorem?


Given a IFS with probabilities, $ (X,\{f_i\})$ formed by a compact metric space $ (X,d)$ and a finite number of contractive mappings $ f_i:X \to X$ and a set of probabilities $ p_i > 0$ with $ \sum p_i = 1$ , the measure $ \mu$ such that $ \mu = \sum p_i \cdot \mu \circ f_i ^{-1}$ is called $ p$ -balanced measure or invariant fractal measure.