Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Tic tac toe game in python pdf

19/03/2021 Client: saad24vbs Deadline: 24 Hours

CSCI 503-1 Computer Assignment 4 Spring 2020 (20 points)

Tic-tac-toe is a game for two players, X and O, who take turns marking the spaces in a 3 x 3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is a winner. Write a python program to simulate playing this game. Draw the grid on your terminal screen and display your marks on the grid. You need to import the graphics package into your program, download and install the Xming program (from the Internet) to your computer to activate the graphics package. If you’re using PuTTY to access the tiger machine, you need to enable X11 forwarding, but if you’re directly using the ssh to access the tiger, you need to use the ssh with –X option. One of the players starts playing the game who is randomly chosen between the two players. You can play the game for as many times as you wish, but for a final test, do it for 12 consecutive games. To start your program, follow the example on page 100 of the textbook. To simulate a game, you can use a random number generator (RNG), randrange ( ), importing from the random package, and to get the same sequence of random numbers for each time to execute the program, set the seed value to 1 in your main ( ) routine. The functions described below are just suggestions. You can design your program anyway you like but make it sure that it generates the correct results.

• def main ( ): For each new play, to create a window on the terminal screen for a given size, say 400 x 400 pixels, it calls the function draw_board ( ) that draws a 3 x 3 grid on the screen. It prints the game number and calls the function init_play ( ) to choose the player who makes the first move. To simulate of playing a game, it calls the function play ( ), which returns the identity of the winner or returns None if the game is a draw and updates the number of wins for the winner. After each game, it pauses for the user input to continue to the next game, waiting for the user to enter a “yes” and closes the window for a fresh start. If the user prompt is a “no”, it quits playing the games and calls the function print_stat ( ) to print out the final winning scores.

• def draw_board ( win ): In addition to drawing horizonal and vertical lines on the grid, this function also prints the corresponding index values from 0 to 8 in the 9 cells of the grid, where the index value of leftmost of the first row of the grid has assigned to 0 and the index value of rightmost of the last row of the grid has assigned to 8, and the index values increases from left to right and from bottom to top. The argument win refers to the object of the window drawn on the screen.

• def init_play ( win ): It calls the RNG to choose the first and second player (like a tossing a coin), where the first player will start the game, and it returns the index values of the two players to the main ( ) routine.

• def play ( win, players ): It simulates a single game by alternating between two

players for each step. A game is over when a player ends up of marking three

Tic-Tac-Toe

2

horizontal, vertical, or diagonal cells on the grid; or it’s over when all 9 cells are marked on the grid. For each move, a cell number between 0 to 8 is chosen by the RNG. However, if the cell is chosen before, it calls the RNG to get another cell. The player with index value 0 uses the letter X and the player with index value 1 uses a circle, and places it in the center of the chosen cell. If a player wins a game, then the routine returns the identity of the player to the main ( ) routine, but if the game is a draw, then it returns the value None. After a player makes 3 or more moves in a game, it calls the function after_3_steps ( ) to determine if the player is a winner, and if it’s, it terminates the game.

• def after_3_steps ( n, cell, player): It determines if player is a winner, where n is the

number of moves made by the player and cell is the cell numbers for those n >= 3 moves. To figure out if combinations of 3 out of n cells results a winning: they are located on the same horizontal, vertical, or diagonal positions, it calls the function check_win ( ) for each possible combination: for n = 3, there is only 1 combination, for n = 4, there are 3 combinations, and for n =5, there are 6 combinations. If any one of the possible combinations shows a winning, then it prints the player as a winner and returns the identity of the player to the calling function; otherwise, it returns None.

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Smart Accountants
Assignment Solver
Pro Writer
WRITING LAND
Math Exam Success
Solutions Store
Writer Writer Name Offer Chat
Smart Accountants

ONLINE

Smart Accountants

I have read your project details. I can do this within your deadline.

$49 Chat With Writer
Assignment Solver

ONLINE

Assignment Solver

I am known as Unrivaled Quality, Written to Standard, providing Plagiarism-free woork, and Always on Time

$64 Chat With Writer
Pro Writer

ONLINE

Pro Writer

I have read and understood all your initial requirements, and I am very professional in this task.

$35 Chat With Writer
WRITING LAND

ONLINE

WRITING LAND

Hello, I an ranked top 10 freelancers in academic and contents writing. I can write and updated your personal statement with great quality and free of plagiarism

$36 Chat With Writer
Math Exam Success

ONLINE

Math Exam Success

You can award me any time as I am ready to start your project curiously. Waiting for your positive response. Thank you!

$110 Chat With Writer
Solutions Store

ONLINE

Solutions Store

You can award me any time as I am ready to start your project curiously. Waiting for your positive response. Thank you!

$128 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Bending the frame photojournalism documentary and the citizen pdf - Eastern european folk songs - BW Texas Gov't Opinon Essay Unit 3 - Note payable due in 10 equal annual installments - Mango bite price per candy - BUSI 201article review - Excel Exercise Week 3 - Hm - Kodak future strategy - Kellogg's stakeholder engagement - PS 1000 Week 5 Discussion Ultimate Medical Academy - What was the message of the truman show - Physics Help Needed!!! NOW - Fahrenheit 451 part 3 discussion questions - Brent staples why colleges shower students with a - Brogden v metropolitan railway co - Reading summary - Active Directory GPO and MBSA Responses - A history of the modern world palmer pdf - Ranked URLs (month by month)Filter by: mcgraw hill accounting chapter 10 answers Something went wrong Try to reload widget. If the problem persists, please contact us at semrush-email@semrush.com is human capital the key to avoid being structurally unemployed - Conquest marketing concepts - Visual basic chapter 3 review answers - Frankenstein mary shelley chapter 1 summary - Module 2 Discussion - Assignment: Needs Assessment Surveys - Request to accept paper lodgement - Examples of bad listening habits - The out of control interview case study answers - Novabackup unable to allocate the backup engine - Pittsburgh sleep quality index word document - Martinez company's ending inventory includes the following items - Celf 5 average range - Style with illusory motion crossword - Emil and the detectives reading age - Molar mass of cuso4 5h2o calculation - Brady lat 18 361 word template - Tax Form - Learning activity - Best gopro case 2017 - Masters in counselling nz - The wave study guide answers - Bilingualism in america hayakawa answers - Political Science Week 4 Discussion - Tlmt 601 - Find the attachment look for question 3, it's summary report - Southern cross university graduate diploma early childhood - Kabianga - Personal Philosophy of Nursing - Student exploration titration gizmo answer key - Service Encounter Journal, One page, Pick category #1 or #2 to write - Inside out for horses - Molecular orbital energy diagram of n2 - Money matters newcastle upon tyne - Nursing - Uncovered interest rate parity equation - FEEDBACK FOR PEER - How many degrees of unsaturation does the compound c5h10 have - Wilsons prom tidal river cabins - Paragraph 353b of the immigration rules - All stone quarries castlemaine - 128 broadwater rd mt gravatt - MBA work 8 - Annotated bibliography ama - Pillow method - How to connect pressure switch to starter - Planning Envionments - The person centered view of human nature - Ucl student support and wellbeing - Does edgar die in king lear - Computer science project proposal - Role and Scole DQ9 - Lactic acid fermentation lab report - America by claude mckay worksheet answers - Effects of social networking sites ppt - Assignment ch 10 - Acsc ism - Comparing versions of the flying machine answer key - Jhulan yatra 2020 date - Apic ols - R3 - Discussion - Pave the planet or wear shoes - Ma1015 week 2 assignment - Marie curie jobs cornwall - Apostrophe figurative language examples - Recruitment and selection assignment sample - How much did eggs cost in - Assignment - Ned kelly primary sources - Merchants of doubt youtube - A.1 Accounting/FInance - Compute stanley black & decker's gross profit margin - Construct a binomial probability distribution with the given parameters - CS week 10 discussion - OE W 1 D - The butler worksheet answers - Request to fill vacant position - Solar Energy for Residential Homes - Neway air suspension parts - Jib fowles 15 appeals pdf