Question: 2 6 . 1 2 . 2 0 2 3 CMPE 1 4 0 Final Project This is a group assignment. GRoups may include 2
CMPE Final Project
This is a group assignment. GRoups may include to students. You are not allowed to take a peek at any
solutions, including online resources, and you are not allowed to share your answers with anyone, including your
classmates. You are allowed to program together as a group. You are only allowed to use your lecture notes and
the textbook. Failure to follow these rules will result in getting only point for the project.
In this project, we will simulate a beetle bcek movements in a grid. A beetle may move towards left, right, up
down, upright, upleft, downright, and downleft on a plane. You will implement a program including some
functions, and each function is responsible for a task in this project. More details are given below:
Firstly, create an matrix of integers and then put the beetle in element ij the first I and j must be received
from the user. Then randomly move the beetle to one of the eight directions. This program will end when all
elements of this matrix have been visited at least one time. You can use a matrix for choosing the direction,
as shown below:
Eight directions:
moves Left right up down upright upleft downright downleft
i i i i i i i i i
j j j j j j j j j
When the beetle visits element ij increment the counter of that element. We want to see the number of visits
of each matrix element at the program's end. If the beetle reaches the borders, it cannot exceed them. For example,
if it is in element it can move only downward, to right, and downright, but not upward, upright, upleft or
towards left. When all elements have been visited at least one time, print the requested output below:
Output: The content of the matrix as well as the five probabilities listed below:
The probability of moving left
number of left moves
number of allmoves
The probability of moving right
number of right moves
number of all moves
The probability of moving up
number of upward moves
number of all moves
The probability of moving down
number of downward moves
number of all moves
Probability of passing the border number of unsuccessfultries to exceed the border
number of allmoves
iji jij
ijiji j
ijijij
Sample run:
Assume that the first random numbers for ij are then we start from this element and visit all elements. A
possible output can be:
Probability of moving left:
Probability of moving right:
Probability of moving up:
Probability of moving down:
Probability reaching the border:
Final matrix:
Submission Instructions
Prepare a document PDF including at least pages and explain your code and
algorithm to implement this Project.
Create a zip file named FinalProjectnamesurname.zip eg
FinalProjectMehmetErdoanzip that contains the document file and also your source
code files
Upload the zip file to Blackboard.
At the presentation day, you will run your code in your computer and each group
member will answer my questions.
Good luck,
Rahim Dehkharghani,
Kadir Has University
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
