Assignment 2 Solved

$24.99 $18.99

Environment WARNING!!! Before starting on this assignment, make sure you have set up your VM properly. We would test all students’ homework using the following environment. You can type the following command in terminal on your VM to see if your configuration matches the test environment. If not, you are still good to go, but…

Rate this product

You’ll get a: zip file solution

 

Description

Rate this product

Environment

WARNING!!! Before starting on this assignment, make sure you have set up your VM properly. We would test all

students’ homework using the following environment. You can type the following command in terminal on your

VM to see if your configuration matches the test environment. If not, you are still good to go, but please try to

test your program with the following environment for at least once. Because you may be able to run your

program on your environment, but not on TAs’ environment, causng inconvenience or even grade deduction.

If you follow the tutorials then your VM setting should be fine, though verify your environment again is

recommended.

Linux Version

main@ubuntu:/$ cat /etc/issue

Ubuntu 16.04.5 LTS \n \l

 

GCC Version

main@ubuntu:/$ gcc –version

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609

Copyright (C) 2015 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 

Submission

Due on: 23 59, 25 Oct 2021

Please note that, teaching assistants may ask you to explain the meaning of your program, to ensure that the

codes are indeed written by yourself. Please also note that we would check whether your program is too similar

to your fellow students’ code using plagiarism detectors.

Violation against the format requirements will lead to grade deduction.

tree
Here is the format guide. The project structure is illustrated as below. You can also use command to check if

your structure is fine. Structure mismatch would cause grade deduction.

Note that NO EXTRA BONUS FILE/FOLDER is needed for this assignment. Please mark whether you have finished

bonus in your report.

main@ubuntu:~/Desktop/Assignment_2_<student_id>$ tree

.

├── Report.pdf

└── source

└── hw2.cpp

1 directory, 2 files

 

Please compress all files in the file structure root folder into a single zip file and name it using your student id as

the code showing below and above, for example, Assignment_2_119010001.zip. The report should be submitted
in the format of pdf, together with your source code. Format mismatch would cause grade deduction. Here is the

sample step for compress your code.

main@ubuntu:~/Desktop$ zip -q -r Assignment_2_<student_id>.zip Assignment_2_<student_id> main@ubuntu:~/Desktop$ ls

Assignment_2_<student_id> Assignment_2_<student_id>.zip

 

 

Task Description

 

In Assignment 2, you are required to complete the multithread program to implement the game “Frog crosses river”.

Game rules:

A river has logs floating on it, and a frog must cross the river by jumping on the logs as they pass by.

Objects:

Log: =================

Frog: 0

River bank: |||||||||||||||||||||

 

 

 

 

 

 

 

 

 

 

 

When the game starts, the frog stands in the middle of bottom bank of river. The user can control the frog

jumps by keyboards. The logs will move from left to right or right to left staggerly. Please take care of the edge cases.

 

W: UP

S: Down

A: Left

D: Right

Q: Quit the game

 

 

 

 

 

 

 

You will win if the frog jumps to the other bank of river successfully.

You will lose if the frog lands in the river, or reaches the left/right side of the river.

Please note that this is a game. If the player suffers from extereme difficulty, high latency, and other unexpected situations for a game, your grade will suffer as well.

 

Function Requirements (90 points):

To run the template, you will see the frog stands in the middle at bottom bank of river. There are 9 blank rows which means the river. Compile the program to see the static output. (5 points)

 

 

 

 

 

 

 

 

 

 

You should complete the function named “logs_move” to let the logs can move staggerly from left to right or

from right to left. (20 points)

You should create pthread and use mutex lock for logs and frog movement control. (30 points)

“kbhit” function is provided for keyboard capture. You should complete the jump rules for keyboard actions. And the frog’s position should be updated when keyboard hits. (15 points)

 

When the logs are moving, the program should be able to judge the game status (win, lost or quit). Print out the message for user whether he/she wins or lost the game. (15 points)

 

If the user quits the game, print the message. (5 points)

Demo Output

Demo output for user wins the game

You win the game!!

main@ubuntu:~/Desktop/Assignment_2_example/source$
Demo output for user loses the game:

You lose the game!!

main@ubuntu:~/Desktop/Assignment_2_example/source$

 

Demo output for user quits the game:

You exit the game.

main@ubuntu:~/Desktop/Assignment_2_example/source$

 

 

Bonus Task (10 pionts)

 

You have to implement a graphical output of your river and frog game. (5 points)

You can use any library you like to show your graphical output

The length of log must be different by random generating. (2 points)

You need to design a slide bar to adjust the speed of floating logs. (3 points)

 

 

Report (10 points)

 

Write a report for your assignment, which should include main information as below:

Your name and student id.

How did you design your program?

The environment of running your program. (E.g., version of OS and kernel)

The steps to execute your program.

Screenshot of your program output.

What did you learn from the tasks?

 

 

Grading rules

 

Here is a sample grading scheme. Different from the points specified above, this is the general guide when TA’s

grading.

Completion
Marks

Bonus
10 points

Report
10 points

 

Completed with good quality
80
~ 90

 

Completed accurately
80
+

 

Fully Submitted (compile successfully)
60
+

Partial submitted
0~60

 

No submission
0

 

Completion
Marks

Late submission

Not allowed

Assignment 2 Solved
$24.99 $18.99