Create a Main Line Algorithm and Subordinate Algorithms to execute a game of tic
ID: 3717986 • Letter: C
Question
Create a Main Line Algorithm and Subordinate Algorithms to execute a game of tic - tac - toe.all in psudocode not c++ for ex Employee_salary Prompt for salary Get salary_1 DOWHILE salary NOT = 0 Calculate_income_tax Display “income tax due = “ income_tax Prompt for salary Get salary END Calculate_income_tax IF salary_1 < 5000 THEN Income_tax = 0 ELSE IF salary_1 < 10,000 THEN Income_tax = Salary_1 * 0.06 ELSE IF salary_1 < 20,000 THEN Income_tax = Salary_ * 0.15 ELSE IF salary_1 < 30,000 THEN Income_tax = Salary_1 * 0.2 ELSE IF salary_1 < 40,000 THEN Income_tax = Salary_1 * 0.25 ELSE Income_tax = salary_1 * 0.3 ENDIF ENDIF like this not real code
Your Project is to include the following: Logic for The Game Itself (15 points) Accommodations for TWO players (5pts) Players must be called by name when selecting a square (5pts) Logic to pass the move from Player One to Player Two in subordinate module Must receive passed parameter (5pts) Logic to Draw the Game Board (25 points) Actual graphical representation of the game board as a subordinate module (15pts)Each line of the board must be fully represented in text - I will not use my imagination to guess my way there " W H A T E V E R Y O U N E E D T O D O H E R E " " I S W H A T E V E R Y O U N E E D T O D O H E R E " Uses array to manage drawing of the board and moves (5pts) This module must receive passed parameters to draw players chosen moves Must receive passed parameter (5pts) Logic to Maintain the Game (25 points) Subordinate module to ensure that players cannot overwrite another player's selection (5pts) Ensure that bad selection allows user to recover and continue playing successfully (5pts) Logic to check for a winner Must receive passed parameter (5pts) Logic to check for a draw / tie Must receive passed parameter (5pts) Logic to allow a play to continue to play more games as desired (5pts) Organizational Bits and Pieces (35 points) Mainline should be mostly free of structure other than to call on subordinate modules (5 pts) All variables / structures used must be declared in mainline or in subordinate modules (5 pts) Array must be used to maintain player moves (5 pts) Defining Diagrams for your pseudocode (10 points) A hierarchy chart of your program (10 points)
Explanation / Answer
Pseudocode for Tic Tac Toe Game is given below:-
present the game board
0 | 1 | 2
3 | 4 | 5
6 | 7 | 8
one player chooses a box to put his mark
the computer chooses another box to put his mark
if player has (i && i+1 && i+2) or (i%3 == 0) or (i%3 == 1) or (i%3 == 2) or (i%4 == 0) or (i%2 == 0)
then player wins
var player = 1;
//var player1Position = [];
//var player2Position = [];
//define all the column, row, and diagonal counts
while player === 1 {
while (countFirstCol1 < 3 && countSecondCol1 < 3 && countThirdCol1 < 3 && countNWDiagonal1 < 3 && countNEDiagonal1 < 3 && countFirstRow1 < 3 && countSecondRow1 < 3 && countThirdRow1 < 3)
for (each box on the board) {
box.addEventHandler(‘click’,function(){
add a symbol to the board
//player1Position.push(boxNumber);
});
if (boxNumber%3 === 0) {
countFirstCol1++;
} else if (boxNumber%3 === 1) {
countSecondCol1++;
} else if (boxNumber%3 === 2) {
countThirdCol1++;
} else if (boxNumber%4 === 0) {
countNWDiagonal1++;
} else if (boxNumber%2 === 0) {
countNEDiagonal1++;
} else if (boxNumber < 3) {
countFirstRow1++;
} else if (boxNumber > 2 && boxNumber < 6) {
countSecondRow1++;
} else if (boxNumber > 5 && boxNumber < 9) {
countThirdRow1++;
}
determineWinner();
player = 0;
}
}
}
while player === 0 {
for (each box on the board) {
box.addEventHandler(‘click’,function(){
add a symbol to the board
player2Position.push(boxNumber);
});
}
determineWinner();
player = 1;
}
function determineWinner() {
for (each entry in player1Position) {
if (entry%3 === 0) {
countFirstCol++
}
}
}
Please find the text file in the link below:-
https://drive.google.com/file/d/1b8wWIpSzWe7SmL8gXm7nvtb9GZkLOOMU/view
Please let me know if any issues. Thansk!