Question

Create a assembler(MASM) program to allow two players to play a game of pig. For learning...

Create a assembler(MASM) program to allow two players to play a game of pig. For learning the game, I would recommend playing against the computer - it is easier to keep track of whose turn it is when playing against the computer. You will only handle two people playing, don't worry about trying to implement a computer player. Note that you will want to use the RandomRange procedure that is part of the Irivne32 library. Learn to play here http://www.playonlinedicegames.com/pig

0 0
Add a comment Improve this question Transcribed image text
Answer #1

THE ASSEMBLER PROGRAM:

The assembler program is is lower language Each assembly language is particular computer architecture and operating system.used to the most high-level programming languages are generally portable across multiple architectures.but require interpreting or compiling.

A two player game of pig.

  • The game of Pig is a very simple dice game in which two players race to reach 100 points.
  • The random range procedure in the 32 library.
  • Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn, the player is faced with two decisions:

roll - If the player rolls a

1: the player scores nothing and it becomes the opponent's turn.

2 - 6: the number is added to the player's turn total and the player's turn continues.

hold - The turn total is added to the player's score and it becomes the opponent's turn.

In this lab you will play an entire game with two simulated players. The game begins to the user to enter the "roll until" value for each player (the players may have different values). Then the program will play an entire game using the two simulated players. The game ends when one of the player's total score is 100 or greater, and prints a message stating which player won.

One way to have two players play the game would be to copy and paste the code for one player's turn to create a second player's turn. But this means that you will be repeating code, a very bad design practice. Instead, you will write two functions for this program: one that gets the strategy for a player (their "roll until" value), and one that simulates a player's turn. Inside the whole game loop, you can call these functions for each of the players. A real player would end their turn as soon as their game total was 100 or greater. Our computer player will continue its final turn until it reaches its specified turn total, or until it rolls a one

Here is some code that i need to use:

#include<iostream>
#include<cstdlib>
#include<string>
#include<time.h>
using namespace std;
int player Roll(int start, string name);
int get Start(string name);

(// SHASES MEANING OF THE PROGRAM:
// Note: It is best to not work on this program in the order that things are
// written in this file. Start by writing pseudo code, then write the function
// prototypes, followed by the functions, and finally write the main function.
// Put the function prototypes here
// You will write three functions: One to get the player's strategy from user
// input, another to simulate a turn of the game, and a third to print the
// game results.
// End of function prototypes. Move on to write the block of code in the
// main function
int main()
{
    int total_Player1 = 0; // Player 1 score tracker
    int total_Player2 = 0; // Player 2 score tracker
    int Player1_Strat; // Player 1's strategy for each turn
    int Player2_Strat; // Player 2's strategy for each turn
Strand(static_cast<int> (time(NULL)));

WRITE A CODE END OF THE COMMENT.
     // Get the strategy for each player (use a function).
    // You should write a single function and call it twice (once for more players)
   // Use a loop to have the two players continue to take turns until one
    // has a total game score of 100 or greater. If the first player wins
    // that you don't allow the second player to take a turn (quit the loop as soon as one player reaches 100 or greater).
   //Use a function for the player's turn. You should write a single function
    // and call it two times (once for each player's turn).
     // End of your code block in the main function.
    // Move on to write the three functions below the main function.
// Print the results

  • NOTE - you need to write the Print Results function

    if(total_player > total_Player 2)
    {
Print Results("Player 1", total_Player, "Player 2", total_Player 2);
    }
    else if(total_Player 2 > total_player)
    {
Print Results("Player 2", total_Player 2, "Player 1", total_Player);
    }
    else
    {
        // This should never happen because we quit the loop if Player 1
        // wins and don't allow Player 2 to play their last turn.
        // But we'll put this in just for completeness.
        cout << "Draw! ";
        cout << "(Note: if this happens there is something wrong with the code)";
        cout << end l;
    };

return 0;

};

// WRITE THE PROGRAM
// Function that gets the player's strategy from user input.
// This function should get the strategy for a single player and return
// the "roll until" value.
// This function checks that the user entered an integer, and
// keeps prompting the user to enter an integer until an integer is entered.
// Function that simulates a single player's turn. This function should return
// the total of the rolls for the turn.
THE NEXT OF THE END OF THE GAMAE :
// Function that prints the results of the game. See the example program output
// to see how the end of game message should look.
// This function is already called by the main program so you can look there to
// see what return type and parameters it needs.

END OF THE CODE :

One to get the strategy for a player, one to simulate a player's turn, and one to print the formatted game results. Your game should play like the game in the following figures.

Start of the game:

End of the game:

Add a comment
Know the answer?
Add Answer to:
Create a assembler(MASM) program to allow two players to play a game of pig. For learning...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The game of Pig is a simple two-player dice game in which the first player to...

    The game of Pig is a simple two-player dice game in which the first player to reach 100 or more points wins. Players take turns. On each turn, a player rolls a six-sided die: If the player rolls a 1, then the player gets no new points and it becomes the other player’s turn. If the player rolls 2 through 6, then he or she can either ROLL AGAIN or HOLD:      At this point, the sum of all rolls...

  • For your final project you will incorporate all your knowledge of Java that you learned in this class by programming the game of PIG. The game of Pig is a very simple jeopardy dice game in which two p...

    For your final project you will incorporate all your knowledge of Java that you learned in this class by programming the game of PIG. The game of Pig is a very simple jeopardy dice game in which two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn,...

  • The Rules of Pig Pig is a folk jeopardy dice game with simple rules: Two players...

    The Rules of Pig Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 (”pig”) is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player’s turn, the player is faced with two decisions: roll If the player rolls a 1: the player scores nothing and it becomes the...

  • I need to create a Tic Tac Toe program in C++. These are the requirements Write...

    I need to create a Tic Tac Toe program in C++. These are the requirements Write a program that allows the computer to play TicTacToe against a human player or allow two human players to play one another. Implement the following conditions: The player that wins the current game goes first in the next round, and their symbol is X. The other player will be O. Keep track of the number of games played, wins, and draws for each player....

  • Problem 4. (20 points) Pebbles Game. Two players play a game, starting with three piles of...

    Problem 4. (20 points) Pebbles Game. Two players play a game, starting with three piles of n pebbles each. Players alternate turns. On each turn, a player may do one of the following: take one pebble from any pile take two pebbles each from two different piles The player who takes the last pebble(s) wins the game. Write an algorithm that, given n, determines whether the first player can "force" a win. That is, can the first player choose moves...

  • JAVAFX PROGRAM Write a program that will allow two users to play a game of tic-tac-toe....

    JAVAFX PROGRAM Write a program that will allow two users to play a game of tic-tac-toe. The game area should consist of nine buttons for the play area, a reset button, and a label that will display the current player's turn. When the program starts, the game area buttons should have no values in them (i.e. they should be blank) When player one clicks on a game area button, the button should get the value X. When player two clicks...

  • Java Listed below is code to play a guessing game. In the game, two players attempt...

    Java Listed below is code to play a guessing game. In the game, two players attempt to guess a number. Your task is to extend the program with objects that represent either a human player or a computer player. boolean checkForWin (int guess, int answer) { System.out.println("You guessed" + guess +"."); if (answer == guess) { System.out.println( "You're right! You win!") ; return true; } else if (answer < guess) System.out.println ("Your guess is too high.") ; else System.out.println ("Your...

  • (Game: play a tic-tac-toe game) In a game of tic-tac-toe, two players take turns marking an...

    (Game: play a tic-tac-toe game) In a game of tic-tac-toe, two players take turns marking an available cell in a grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A draw (no winner) occurs when all the cells in the grid have been filled with tokens and neither player has achieved a win. Create...

  • Requirements: 1. You are not allowed to use global variables. 2. Must declare the following two...

    Requirements: 1. You are not allowed to use global variables. 2. Must declare the following two constants public static final int POINTS = 30; public static final int FORFEIT_POINTS = 20; 3. You can implement your own solution but you are required to break down the problem into smaller pieces. 4. You must provide the output for two rounds of game minimum. 5. Since we are using the Random number generator your output will not be exactly like mine. However,...

  • Write a c program that will allow two users to play a tic-tac-toe game. You should...

    Write a c program that will allow two users to play a tic-tac-toe game. You should write the program such that two people can play the game without any special instructions. (assue they know how to play the game). Prompt first player(X) to enter their first move. .Then draw the gameboard showing the move. .Prompt the second player(O) to enter their first move. . Then draw the gameboard showing both moves. And so on...through 9 moves. You will need to:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT