SlideShare a Scribd company logo
((Note: Assembly Language programming Please and format
from book *86 PROCESSORS. such as
INCLUDE Irvine32.inc ))
Problem: Write a program that simulates the game of Tic-Tac-
Toe. The User will play against the computer (your assembly
program) or the computer will play against itself.
1. You must use a two-dimensional array and Base-Index
operands (Row-major order) throughout the game. The game
board is created with characters.
- | - | -
- | - | -
- | - | -
This is an example of the empty board.
- | x | -
- | o | -
- | - | -
This is an example of a game in progress.
2. All Procedures will be called with PROTO/INVOKE/PROC. I
will be checking for this. DO NOT USE USES as discussed in
class. The only exception is the Irvine32 library. These must be
called with CALL.
3. If the game is player vs computer, start the game by
randomly choosing which of player or computer to make first
move. The first player will be assigned the letter x.
a. The computer chooses a move by selecting an open position
randomly. (We are not developing Artificial Intelligence)
i) However, if the game is player vs computer, and the center
square is available on the computer’s first turn, the computer
MUST chose that square (regardless of whether or not the
computer the first or second player).
ii) Afterwards, all moves by the computer will be random.
b. The player will enter a move via the keyboard.
i) You must check to see if it is a valid move, i.e. not an already
occupied ‘square’, or a square that is non-existent.
ii) Keep asking for a move until a valid move is entered.
c. After each move clear the screen and redisplay the game with
the new move entered.
d. At the conclusion of each game of tic-tac-toe, ask if the
player wishes to play again. Yes, even if it is computer vs
computer.
e. Have a menu option that allows the user to check statistics.
i) How many games played
ii) How many games won by Player 1
iii) How many games won by Player 2
iv) How many games resulted in a draw.
f. When the user chooses to exit the above statistics should be
displayed until a key is pressed.
4. If the game is computer vs computer after each move display
the current state of the game for 2 seconds, before allowing
another move to be made. The user just watch the game being
played.
5. When the game ends, display who won or if the game was a
draw. a. If someone (either player or computer) wins, highlight
the winning path (either three x’s or three o’s) with black on
yellow as the final display.
6. The game will start with a menu. The options are player vs
computer, computer vs computer, and exit.
7. As always, variables used by a procedure must either be
passed to that procedure or created within the procedure. Only
Main PROC can directly access the variables initialized in .data.
All others must be local to the procedures.
8. Style counts to include proper commenting.
Solution
Many computer games, such as strategy games, simulation
games etc uses game boards that can be implemented as two
dimensional arrays. In Java (and in many other languages) 2D
arrays can be defined as an array of 1D arrays. For example a
2D matrix of characters (with dimensions 8x10) can be defined
as follows.
char[][] Board = new char[8][10]
We can think of Board as a table with 8 rows (indexed from
0..7) and 10 columns(indexed from 0..9)
Tic Tac Toe is played on a 3x3 board with two players
alternating between X’s and O’s, alternatively placing their
respective marks on the board. First player succeeding in
getting three of his marks in a row, column or diagonally wins
the game.
How do we design the classes to implement a tictactoe game?
Let us think of the objects in a tictactoe game environment. We
can think of four types of objects, tictactoe board, human
player, dumb (or random) player and smart player. In this
program we will only implement human player and dumb
player. As an extra credit assignment you are encouraged to
write a smart player that can analyze the board and make the
best move. However that is not necessary. Let us begin with the
following classes and methods.
Class
Methods
TicTacToe
clearBoard( ) isWin(int), winner(), printBoard( ), putMark(int,
int)
Driver
Main( )
HumanPlayer
makeMove( TicTacToe B)
ComputerPlayer (extra credit only)
makeMove(TicTacToe B), findMove(TicTacToe B)
DumbPlayer
makeMove(TicTacToe B)
The description of each method can be found in the source code.
Your assignment is to complete the incomplete methods from
TicTacToe, HumanPlayer and DumbPlayer classes.
Testing your program
You may use any kind of IDE such as eclipse to test your
program. However, you need to make sure all programs run
under Andrew linux. You should also check your program by
creating different scenarios.
Human vs Human
First define, two human players and play them against each
other. You can do this by initializing two HumanPlayers as
follows.
HumanPlayer Player1 = new HumanPlayer( );
HumanPlayer Player2 = new HumanPlayer( );
The program should prompt each player to enter position as a
pair of “valid” integers.
For example, two players taking turns can be shown as follows:
> Player X : 0 1
> Player O : 1 1
Game should continue until one player wins or game is a draw.
The program should correctly display the end of the game.
For Example:
Human vs Dumb
Initialize a human player and a dumb player as follows.
HumanPlayer Player1 = new HumanPlayer( );
DumbPlayer Player2 = new DumbPlayer( );
DumbPlayer will always make a random move. Therefore,
human player should be able to usually beat the dumb player.
Dumb vs Dumb
First define, two dumb players and play them against each
other. You can do this by initializing two DumbPlayers as
follows.
DumbPlayer Player1 = new DumbPlayer( );
DumbPlayer Player2 = new DumbPlayer( );
Class
Methods
TicTacToe
clearBoard( ) isWin(int), winner(), printBoard( ), putMark(int,
int)
Driver
Main( )
HumanPlayer
makeMove( TicTacToe B)
ComputerPlayer (extra credit only)
makeMove(TicTacToe B), findMove(TicTacToe B)
DumbPlayer
makeMove(TicTacToe B)

More Related Content

Similar to ((Note Assembly Language programming Please and format from book 8.docx

Ddn
DdnDdn
#include iostream#include fstream#include Opening.h.docx
#include iostream#include fstream#include Opening.h.docx#include iostream#include fstream#include Opening.h.docx
#include iostream#include fstream#include Opening.h.docx
adkinspaige22
 
Week3.pptx
Week3.pptxWeek3.pptx
Week3.pptx
WillSephton
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number Tutorial
OXUS 20
 
Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to Unity
Koderunners
 
This is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxThis is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docx
abhi353063
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
Krishna Agarwal
 
Tic Tac Toe Java Development
Tic Tac Toe Java DevelopmentTic Tac Toe Java Development
Tic Tac Toe Java Development
pengqia chen
 
Bow&arrow game
Bow&arrow gameBow&arrow game
Bow&arrow game
Shaibal Ahmed
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA Game
Sohil Gupta
 
AI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmAI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax Algorithm
Kiran Shahi
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30
Mahmoud Samir Fayed
 
Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
manjan6
 
You will write a multi-interface version of the well-known concentra.pdf
You will write a multi-interface version of the well-known concentra.pdfYou will write a multi-interface version of the well-known concentra.pdf
You will write a multi-interface version of the well-known concentra.pdf
FashionColZone
 
"Pemrograman Python untuk Pemula dan Ahli"
"Pemrograman Python untuk Pemula dan Ahli""Pemrograman Python untuk Pemula dan Ahli"
"Pemrograman Python untuk Pemula dan Ahli"
Muhammadlenterabawon
 

Similar to ((Note Assembly Language programming Please and format from book 8.docx (15)

Ddn
DdnDdn
Ddn
 
#include iostream#include fstream#include Opening.h.docx
#include iostream#include fstream#include Opening.h.docx#include iostream#include fstream#include Opening.h.docx
#include iostream#include fstream#include Opening.h.docx
 
Week3.pptx
Week3.pptxWeek3.pptx
Week3.pptx
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number Tutorial
 
Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to Unity
 
This is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxThis is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docx
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
 
Tic Tac Toe Java Development
Tic Tac Toe Java DevelopmentTic Tac Toe Java Development
Tic Tac Toe Java Development
 
Bow&arrow game
Bow&arrow gameBow&arrow game
Bow&arrow game
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA Game
 
AI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmAI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax Algorithm
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30
 
Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
 
You will write a multi-interface version of the well-known concentra.pdf
You will write a multi-interface version of the well-known concentra.pdfYou will write a multi-interface version of the well-known concentra.pdf
You will write a multi-interface version of the well-known concentra.pdf
 
"Pemrograman Python untuk Pemula dan Ahli"
"Pemrograman Python untuk Pemula dan Ahli""Pemrograman Python untuk Pemula dan Ahli"
"Pemrograman Python untuk Pemula dan Ahli"
 

More from ajoy21

Please complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docxPlease complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docx
ajoy21
 
Please cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docxPlease cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docx
ajoy21
 
Please choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docxPlease choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docx
ajoy21
 
Please check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docxPlease check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docx
ajoy21
 
Please answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docxPlease answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docx
ajoy21
 
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docxPlease attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
ajoy21
 
Please answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docxPlease answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docx
ajoy21
 
Please answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docxPlease answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docx
ajoy21
 
Please answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docxPlease answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docx
ajoy21
 
Please answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docxPlease answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docx
ajoy21
 
Please answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docxPlease answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docx
ajoy21
 
Please answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docxPlease answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docx
ajoy21
 
Please answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docxPlease answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docx
ajoy21
 
Please answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docxPlease answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docx
ajoy21
 
Please answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docxPlease answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docx
ajoy21
 
Please answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docxPlease answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docx
ajoy21
 
Please answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docxPlease answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docx
ajoy21
 
Please answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docxPlease answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docx
ajoy21
 
Please answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docxPlease answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docx
ajoy21
 
Please answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docxPlease answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docx
ajoy21
 

More from ajoy21 (20)

Please complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docxPlease complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docx
 
Please cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docxPlease cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docx
 
Please choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docxPlease choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docx
 
Please check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docxPlease check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docx
 
Please answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docxPlease answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docx
 
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docxPlease attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
 
Please answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docxPlease answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docx
 
Please answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docxPlease answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docx
 
Please answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docxPlease answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docx
 
Please answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docxPlease answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docx
 
Please answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docxPlease answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docx
 
Please answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docxPlease answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docx
 
Please answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docxPlease answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docx
 
Please answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docxPlease answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docx
 
Please answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docxPlease answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docx
 
Please answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docxPlease answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docx
 
Please answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docxPlease answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docx
 
Please answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docxPlease answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docx
 
Please answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docxPlease answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docx
 
Please answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docxPlease answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docx
 

Recently uploaded

Demonstration module in Odoo 17 - Odoo 17 Slides
Demonstration module in Odoo 17 - Odoo 17 SlidesDemonstration module in Odoo 17 - Odoo 17 Slides
Demonstration module in Odoo 17 - Odoo 17 Slides
Celine George
 
How To Sell Hamster Kombat Coin In Pre-market
How To Sell Hamster Kombat Coin In Pre-marketHow To Sell Hamster Kombat Coin In Pre-market
How To Sell Hamster Kombat Coin In Pre-market
Sikandar Ali
 
RDBMS Lecture Notes Unit4 chapter12 VIEW
RDBMS Lecture Notes Unit4 chapter12 VIEWRDBMS Lecture Notes Unit4 chapter12 VIEW
RDBMS Lecture Notes Unit4 chapter12 VIEW
Murugan Solaiyappan
 
Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17
Celine George
 
Java MCQ Questions and Answers PDF By ScholarHat
Java MCQ Questions and Answers PDF By ScholarHatJava MCQ Questions and Answers PDF By ScholarHat
Java MCQ Questions and Answers PDF By ScholarHat
Scholarhat
 
5. Postharvest deterioration of fruits and vegetables.pptx
5. Postharvest deterioration of fruits and vegetables.pptx5. Postharvest deterioration of fruits and vegetables.pptx
5. Postharvest deterioration of fruits and vegetables.pptx
UmeshTimilsina1
 
Odoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List ScanningOdoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List Scanning
Celine George
 
View Inheritance in Odoo 17 - Odoo 17 Slides
View Inheritance in Odoo 17 - Odoo 17  SlidesView Inheritance in Odoo 17 - Odoo 17  Slides
View Inheritance in Odoo 17 - Odoo 17 Slides
Celine George
 
C Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdfC Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdf
Scholarhat
 
11. Post harvest quality, Quality criteria and Judgement.pptx
11. Post harvest quality, Quality criteria and Judgement.pptx11. Post harvest quality, Quality criteria and Judgement.pptx
11. Post harvest quality, Quality criteria and Judgement.pptx
UmeshTimilsina1
 
2024 Winter SWAYAM NPTEL & A Student.pptx
2024 Winter SWAYAM NPTEL & A Student.pptx2024 Winter SWAYAM NPTEL & A Student.pptx
2024 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
BỘ ĐỀ THI HỌC SINH GIỎI CÁC TỈNH MÔN TIẾNG ANH LỚP 9 NĂM HỌC 2023-2024 (CÓ FI...
BỘ ĐỀ THI HỌC SINH GIỎI CÁC TỈNH MÔN TIẾNG ANH LỚP 9 NĂM HỌC 2023-2024 (CÓ FI...BỘ ĐỀ THI HỌC SINH GIỎI CÁC TỈNH MÔN TIẾNG ANH LỚP 9 NĂM HỌC 2023-2024 (CÓ FI...
BỘ ĐỀ THI HỌC SINH GIỎI CÁC TỈNH MÔN TIẾNG ANH LỚP 9 NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Introduction to Banking System in India.ppt
Introduction to Banking System in India.pptIntroduction to Banking System in India.ppt
Introduction to Banking System in India.ppt
Dr. S. Bulomine Regi
 
E-learning Odoo 17 New features - Odoo 17 Slides
E-learning Odoo 17  New features - Odoo 17 SlidesE-learning Odoo 17  New features - Odoo 17 Slides
E-learning Odoo 17 New features - Odoo 17 Slides
Celine George
 
1. Importance_of_reducing_postharvest_loss.pptx
1. Importance_of_reducing_postharvest_loss.pptx1. Importance_of_reducing_postharvest_loss.pptx
1. Importance_of_reducing_postharvest_loss.pptx
UmeshTimilsina1
 
MVC Interview Questions PDF By ScholarHat
MVC Interview Questions PDF By ScholarHatMVC Interview Questions PDF By ScholarHat
MVC Interview Questions PDF By ScholarHat
Scholarhat
 
7. Post Harvest Entomology and their control.pptx
7. Post Harvest Entomology and their control.pptx7. Post Harvest Entomology and their control.pptx
7. Post Harvest Entomology and their control.pptx
UmeshTimilsina1
 
Open and Critical Perspectives on AI in Education
Open and Critical Perspectives on AI in EducationOpen and Critical Perspectives on AI in Education
Open and Critical Perspectives on AI in Education
Robert Farrow
 
FIRST AID PRESENTATION ON INDUSTRIAL SAFETY by dr lal.ppt
FIRST AID PRESENTATION ON INDUSTRIAL SAFETY by dr lal.pptFIRST AID PRESENTATION ON INDUSTRIAL SAFETY by dr lal.ppt
FIRST AID PRESENTATION ON INDUSTRIAL SAFETY by dr lal.ppt
ashutoshklal29
 
MATATAG CURRICULUM sample lesson exemplar.docx
MATATAG CURRICULUM sample lesson exemplar.docxMATATAG CURRICULUM sample lesson exemplar.docx
MATATAG CURRICULUM sample lesson exemplar.docx
yardenmendoza
 

Recently uploaded (20)

Demonstration module in Odoo 17 - Odoo 17 Slides
Demonstration module in Odoo 17 - Odoo 17 SlidesDemonstration module in Odoo 17 - Odoo 17 Slides
Demonstration module in Odoo 17 - Odoo 17 Slides
 
How To Sell Hamster Kombat Coin In Pre-market
How To Sell Hamster Kombat Coin In Pre-marketHow To Sell Hamster Kombat Coin In Pre-market
How To Sell Hamster Kombat Coin In Pre-market
 
RDBMS Lecture Notes Unit4 chapter12 VIEW
RDBMS Lecture Notes Unit4 chapter12 VIEWRDBMS Lecture Notes Unit4 chapter12 VIEW
RDBMS Lecture Notes Unit4 chapter12 VIEW
 
Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17
 
Java MCQ Questions and Answers PDF By ScholarHat
Java MCQ Questions and Answers PDF By ScholarHatJava MCQ Questions and Answers PDF By ScholarHat
Java MCQ Questions and Answers PDF By ScholarHat
 
5. Postharvest deterioration of fruits and vegetables.pptx
5. Postharvest deterioration of fruits and vegetables.pptx5. Postharvest deterioration of fruits and vegetables.pptx
5. Postharvest deterioration of fruits and vegetables.pptx
 
Odoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List ScanningOdoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List Scanning
 
View Inheritance in Odoo 17 - Odoo 17 Slides
View Inheritance in Odoo 17 - Odoo 17  SlidesView Inheritance in Odoo 17 - Odoo 17  Slides
View Inheritance in Odoo 17 - Odoo 17 Slides
 
C Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdfC Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdf
 
11. Post harvest quality, Quality criteria and Judgement.pptx
11. Post harvest quality, Quality criteria and Judgement.pptx11. Post harvest quality, Quality criteria and Judgement.pptx
11. Post harvest quality, Quality criteria and Judgement.pptx
 
2024 Winter SWAYAM NPTEL & A Student.pptx
2024 Winter SWAYAM NPTEL & A Student.pptx2024 Winter SWAYAM NPTEL & A Student.pptx
2024 Winter SWAYAM NPTEL & A Student.pptx
 
BỘ ĐỀ THI HỌC SINH GIỎI CÁC TỈNH MÔN TIẾNG ANH LỚP 9 NĂM HỌC 2023-2024 (CÓ FI...
BỘ ĐỀ THI HỌC SINH GIỎI CÁC TỈNH MÔN TIẾNG ANH LỚP 9 NĂM HỌC 2023-2024 (CÓ FI...BỘ ĐỀ THI HỌC SINH GIỎI CÁC TỈNH MÔN TIẾNG ANH LỚP 9 NĂM HỌC 2023-2024 (CÓ FI...
BỘ ĐỀ THI HỌC SINH GIỎI CÁC TỈNH MÔN TIẾNG ANH LỚP 9 NĂM HỌC 2023-2024 (CÓ FI...
 
Introduction to Banking System in India.ppt
Introduction to Banking System in India.pptIntroduction to Banking System in India.ppt
Introduction to Banking System in India.ppt
 
E-learning Odoo 17 New features - Odoo 17 Slides
E-learning Odoo 17  New features - Odoo 17 SlidesE-learning Odoo 17  New features - Odoo 17 Slides
E-learning Odoo 17 New features - Odoo 17 Slides
 
1. Importance_of_reducing_postharvest_loss.pptx
1. Importance_of_reducing_postharvest_loss.pptx1. Importance_of_reducing_postharvest_loss.pptx
1. Importance_of_reducing_postharvest_loss.pptx
 
MVC Interview Questions PDF By ScholarHat
MVC Interview Questions PDF By ScholarHatMVC Interview Questions PDF By ScholarHat
MVC Interview Questions PDF By ScholarHat
 
7. Post Harvest Entomology and their control.pptx
7. Post Harvest Entomology and their control.pptx7. Post Harvest Entomology and their control.pptx
7. Post Harvest Entomology and their control.pptx
 
Open and Critical Perspectives on AI in Education
Open and Critical Perspectives on AI in EducationOpen and Critical Perspectives on AI in Education
Open and Critical Perspectives on AI in Education
 
FIRST AID PRESENTATION ON INDUSTRIAL SAFETY by dr lal.ppt
FIRST AID PRESENTATION ON INDUSTRIAL SAFETY by dr lal.pptFIRST AID PRESENTATION ON INDUSTRIAL SAFETY by dr lal.ppt
FIRST AID PRESENTATION ON INDUSTRIAL SAFETY by dr lal.ppt
 
MATATAG CURRICULUM sample lesson exemplar.docx
MATATAG CURRICULUM sample lesson exemplar.docxMATATAG CURRICULUM sample lesson exemplar.docx
MATATAG CURRICULUM sample lesson exemplar.docx
 

((Note Assembly Language programming Please and format from book 8.docx

  • 1. ((Note: Assembly Language programming Please and format from book *86 PROCESSORS. such as INCLUDE Irvine32.inc )) Problem: Write a program that simulates the game of Tic-Tac- Toe. The User will play against the computer (your assembly program) or the computer will play against itself. 1. You must use a two-dimensional array and Base-Index operands (Row-major order) throughout the game. The game board is created with characters. - | - | - - | - | - - | - | - This is an example of the empty board. - | x | - - | o | - - | - | - This is an example of a game in progress. 2. All Procedures will be called with PROTO/INVOKE/PROC. I will be checking for this. DO NOT USE USES as discussed in class. The only exception is the Irvine32 library. These must be called with CALL. 3. If the game is player vs computer, start the game by randomly choosing which of player or computer to make first move. The first player will be assigned the letter x. a. The computer chooses a move by selecting an open position randomly. (We are not developing Artificial Intelligence) i) However, if the game is player vs computer, and the center square is available on the computer’s first turn, the computer MUST chose that square (regardless of whether or not the computer the first or second player). ii) Afterwards, all moves by the computer will be random. b. The player will enter a move via the keyboard. i) You must check to see if it is a valid move, i.e. not an already occupied ‘square’, or a square that is non-existent. ii) Keep asking for a move until a valid move is entered.
  • 2. c. After each move clear the screen and redisplay the game with the new move entered. d. At the conclusion of each game of tic-tac-toe, ask if the player wishes to play again. Yes, even if it is computer vs computer. e. Have a menu option that allows the user to check statistics. i) How many games played ii) How many games won by Player 1 iii) How many games won by Player 2 iv) How many games resulted in a draw. f. When the user chooses to exit the above statistics should be displayed until a key is pressed. 4. If the game is computer vs computer after each move display the current state of the game for 2 seconds, before allowing another move to be made. The user just watch the game being played. 5. When the game ends, display who won or if the game was a draw. a. If someone (either player or computer) wins, highlight the winning path (either three x’s or three o’s) with black on yellow as the final display. 6. The game will start with a menu. The options are player vs computer, computer vs computer, and exit. 7. As always, variables used by a procedure must either be passed to that procedure or created within the procedure. Only Main PROC can directly access the variables initialized in .data. All others must be local to the procedures. 8. Style counts to include proper commenting. Solution Many computer games, such as strategy games, simulation
  • 3. games etc uses game boards that can be implemented as two dimensional arrays. In Java (and in many other languages) 2D arrays can be defined as an array of 1D arrays. For example a 2D matrix of characters (with dimensions 8x10) can be defined as follows. char[][] Board = new char[8][10] We can think of Board as a table with 8 rows (indexed from 0..7) and 10 columns(indexed from 0..9) Tic Tac Toe is played on a 3x3 board with two players alternating between X’s and O’s, alternatively placing their respective marks on the board. First player succeeding in getting three of his marks in a row, column or diagonally wins the game. How do we design the classes to implement a tictactoe game? Let us think of the objects in a tictactoe game environment. We can think of four types of objects, tictactoe board, human player, dumb (or random) player and smart player. In this program we will only implement human player and dumb player. As an extra credit assignment you are encouraged to write a smart player that can analyze the board and make the best move. However that is not necessary. Let us begin with the following classes and methods. Class Methods TicTacToe
  • 4. clearBoard( ) isWin(int), winner(), printBoard( ), putMark(int, int) Driver Main( ) HumanPlayer makeMove( TicTacToe B) ComputerPlayer (extra credit only) makeMove(TicTacToe B), findMove(TicTacToe B) DumbPlayer makeMove(TicTacToe B) The description of each method can be found in the source code. Your assignment is to complete the incomplete methods from TicTacToe, HumanPlayer and DumbPlayer classes. Testing your program You may use any kind of IDE such as eclipse to test your program. However, you need to make sure all programs run under Andrew linux. You should also check your program by creating different scenarios. Human vs Human First define, two human players and play them against each other. You can do this by initializing two HumanPlayers as follows. HumanPlayer Player1 = new HumanPlayer( ); HumanPlayer Player2 = new HumanPlayer( ); The program should prompt each player to enter position as a
  • 5. pair of “valid” integers. For example, two players taking turns can be shown as follows: > Player X : 0 1 > Player O : 1 1 Game should continue until one player wins or game is a draw. The program should correctly display the end of the game. For Example: Human vs Dumb Initialize a human player and a dumb player as follows. HumanPlayer Player1 = new HumanPlayer( ); DumbPlayer Player2 = new DumbPlayer( ); DumbPlayer will always make a random move. Therefore, human player should be able to usually beat the dumb player. Dumb vs Dumb First define, two dumb players and play them against each other. You can do this by initializing two DumbPlayers as follows. DumbPlayer Player1 = new DumbPlayer( ); DumbPlayer Player2 = new DumbPlayer( ); Class Methods TicTacToe clearBoard( ) isWin(int), winner(), printBoard( ), putMark(int, int) Driver
  • 6. Main( ) HumanPlayer makeMove( TicTacToe B) ComputerPlayer (extra credit only) makeMove(TicTacToe B), findMove(TicTacToe B) DumbPlayer makeMove(TicTacToe B)