Starting from:
$30

$24

CSC3150 Assignment 2 Solved

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:

        ◦ W: UP

        ◦ S: Down

        ◦ A: Left

        ◦ D: Right

        ◦ Q: Quit the game

The logs will move from left to right or right to left staggerly.















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 the log reaches the left/right side of the river but the frog still on it.





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





Demo output for user loses the game:





Demo output for user quits the game:




Report (10 points)

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

How did you design your program? Where did you place the mutex lock and why?
What problems you met in this assignment and what is your solution?

Environment of running your program, and the steps to execute your program. Screenshot of your program output.
What did you learn from this assignment?





Bonus (10 points)

You have to implement a graphical output of your river and frog game. ‐ You can use any library you like to show your graphical output
The length of log must be different by random generating.

You need to design a slide bar to adjust the speed of floating logs.



Submission

The report should be submitted in the format of pdf, together with your source code. Please compress all files into a single zip file and name it according to your student id. The project structure is illustrated as below:
        ◦ Assignment_2_Student ID.zip

    • Source

            o hw2.cpp

        ◦ Bonus

        ◦ Report

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.

Due on: 23:59, 25 Oct 2020



Grading rules




Completion



Marks



































Bonus



0 ~ 10 points



































Report



10 points



































Completed with good



80
~ 90












quality























Completed accurately



80
+




































Fully Submitted



60
+












(compile successfully)






















Partial submitted



0~60



































No submission



0





































Late submission



Not allowed



























More products