Question

In: Computer Science

PSEUDOCODE: 1. You are designing a 2 dimensional game where players shoot ​bullets​ hugs at each...

PSEUDOCODE:

1. You are designing a 2 dimensional game where players shoot ​bullets​ hugs at each other. Define a pseudocode function to determine whether a hug successfully 'hit' a player at a particular moment.

Real parameter playerX : target player's x position
Real parameter playerY : target player's y position
Real parameter bulletX : x position of bullet
Real parameter bulletY : y position of bullet
Return Boolean : True if distance between target and player within 10 False if not You may need to look up the formula for distance between points in 2d space. Do not use any library functions except 'pow' and 'sqrt' if you need them.

2.Define a pseudocode function that takes in an Integer and returns the absolute value of that integer. The solutions are notthe result of some programming trick but are more related to arithmetic and math and there are multiple solutions to this.

3.Define a function within a flow chart that has 2 Real parameters and returns the larger of them. If they are the same return either argument. DO NOT SUBMIT PSEUDOCODE FOR THIS.

4. The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here:

● When you mix red and blue, you get purple.
● When you mix red and yellow, you get orange. ● When you mix blue and yellow, you get green.

Design a program in pseudocode that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results.

Solutions

Expert Solution

Q1:#Used Euclidean Distance for calculating the distance
boolean Hit(Real_parameter_playerX,Real_parameter_playerY,Real_parameter_bulletX,Real_parameter_bulletY)
{   
x_dist=pow(Real_parameter_playerX - Real_parameter_bulletX, 2)
y_dist=pow(Real_parameter_playerY - Real_parameter_bulletY, 2)
distance =pow(x_dist+y_dist,0.5)
if distance<=10
return True
else
return False
}

Q2:

int absolute(int number)
{
if number<0
return -number
else
return number
}

Q3:

float greater(float a ,float b)
{
if(a >b)
return a;
else
return b;
}

Q4:

colour1=input('Enter the first colour')
colour2=input('Enter the second colour')

if colour1!="red" or colour1!="blue" or colour1!="yellow" or colour2!="red" or colour2!="blue" or colour2!="yellow"
{
print("Entered colour is not primary colour")
}

else
{
if colour1=="red" and colour2=="blue"
print("Purple")
else if colour1=="red" and colour2=="yellow"
print("Orange")
else if colour1=="yellow" and colour2=="blue"
print("Green")
}

NOTE:If you find the answer helpful,please like the answer. Thank You!


Related Solutions

PSEUDOCODE: 1. You are designing software for a voting booth. Please create pseudocode for a modular...
PSEUDOCODE: 1. You are designing software for a voting booth. Please create pseudocode for a modular program that: - Takes in a user inputted integer for age. If their age is below 18, display "you are too young to vote" - Only If their age is high enough, please ask them which candidate they wish to vote for. Valid options are "dog", "cat", "horse" - If they did not choose a valid option display "you did not choose a valid...
A sequential game with two-players 1 and 2, where player 1 has the first move advantage....
A sequential game with two-players 1 and 2, where player 1 has the first move advantage. Each player has two strategies, A and B. If both players choose A, each gets a payoff of 2. Both choose B, each gets a payoff of 3. For player 1 choose A and player 2 choose B, player 1 gets 4, and player 2 gets 1. If player 1 chooses B and player 2 choose A, player 1 gets a payoff of 1,...
Write pseudocode to implement the paranoid algorithm. (You vs 2 other players)
Write pseudocode to implement the paranoid algorithm. (You vs 2 other players)
Coin taking game This game is played between 2 players, player 1 and player 2. There...
Coin taking game This game is played between 2 players, player 1 and player 2. There are two piles of coins. The values of a coin can be any integer. Both players know the values of all coins in both piles. Player 1 makes the first move, and play alternates between the players. A move consists of taking a coin from the top of either of the piles (either player can take from either pile). The game ends when both...
You and your younger brother are designing an air rifle that will shoot a lead pellet...
You and your younger brother are designing an air rifle that will shoot a lead pellet with mass m = 1.20 g and cross-sectional area A = 0.0350 cm2. The rifle works by allowing high-pressure air to expand, propelling the pellet down the rifle barrel. Because this process happens very quickly, no appreciable thermal conduction occurs and the expansion is essentially adiabatic. Your design is such that, once the pressure begins pushing on the pellet, it moves a distance of...
a video-game developer as received reports of players who are cheating. all game players each have...
a video-game developer as received reports of players who are cheating. all game players each have five capabilities that are ranked on a scale of 1 to 10 points, with 10 total points available for balance. players can move these points between capabilities at any time. the programming logic is as follows: o a player asks to move points from one capability to another. o the source capability must have enough points to allow the move. o the destination capability...
1-If a static game where both players have dominant strategies was to be played sequentially, A....
1-If a static game where both players have dominant strategies was to be played sequentially, A. the outcome of the dynamically played game would be the same with the outcome of the simultaneously played game. B. the Nash equilibrium of the game will not be sub-game perfect. C. the dominant strategies will no longer exist. D. the outcome of the dynamically played game would be different than the outcome of the simultaneously played game. 2- A sub-game perfect Nash equilibrium...
You are designing a missile defense system that will shoot down incoming missiles that pass over...
You are designing a missile defense system that will shoot down incoming missiles that pass over a perimeter defense post. The set-up is shown below. An incoming missile passes directly above the defense base. Radar at the base can measure the height, hh, and speed, v1, of the incoming missile. Your Patriot Rocket is set to fire at an angle of θ=58 from vertical. You design the Patriot Rocket so the magnitude of its acceleration is given by: a2=Ae-bt where...
Consider the Stage Game below, and consider the repeated game where players play twice (T =...
Consider the Stage Game below, and consider the repeated game where players play twice (T = 2). Payoffs for each agent are simply period one plus period two payoffs. L C R T 6,6 0,7 1,2 M 7,0 1,1 2,0 B 2,1 0,1 3,3 (a) Do any strategies dominate any other? (b) What are the two NE of the Stage Game? What is the difference between the two? (c) Call the TL strategy profile (1 plays T, 2 plays L)...
Question 4: Jar Game Consider the following game: Players: 2 - We designate player #1 to...
Question 4: Jar Game Consider the following game: Players: 2 - We designate player #1 to be the one that starts with the jar. Actions: - Each round at the same time both players deposit between 1 to 4 pennies into the jar. - Then both players are able to count the pennies in the jar. - If there are 21 or more pennies, the person with the jar is the winner. - If there are 20 or less pennies,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT