Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 6 . 1 2 . 2 0 2 3 CMPE 1 4 0 Final Project This is a group assignment. GRoups may include 2

26.12.2023
CMPE 140 Final Project
This is a group assignment. GRoups may include 2 to 4 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 1 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, up-right, up-left, down-right, and down-left 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 8*8 matrix of integers and then put the beetle in element (i,j). 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 2*8 matrix for choosing the direction,
as shown below:
Eight directions:
moves Left right up down upright upleft downright downleft
i i i i-1 i+1 i-1 i-1 i+1 i+1
j j-1 j+1 j j j+1 j-1 j+1 j-1
When the beetle visits element (i,j), 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 (0,0), it can move only downward, to right, and down-right, but not upward, up-right, up-left or
towards left. When all elements have been visited at least one time, print the requested output below:
Output: The content of the 8*8 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 (unsuccessful)tries to exceed the border
number of allmoves
(i-1,j-1)(i-1, j)(i-1,j+1)
(i,j-1)(i,j)(i, j+1)
(i-1,j+1)(i+1,j)(i+1,j+1)
Sample run:
Assume that the first random numbers for (i,j) are (3,4), then we start from this element and visit all elements. A
possible output can be:
Probability of moving left: 23%
Probability of moving right: 26%
Probability of moving up: 20%
Probability of moving down: 31%
Probability reaching the border: 4%
Final matrix:
35212893
321232215164
4511102223347
41491124173110
22481915111321
11216171820342
2128252216182510
27395882
Submission Instructions
- Prepare a document (PDF) including at least 10 pages and explain your code and
algorithm to implement this Project.
- Create a zip file named FinalProject_name_surname.zip e.g.
FinalProject_Mehmet_Erdoan.zip that contains the document file and also your source
code file(s).
- 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

denigration of emotional outbursts; being reserved;

Answered: 1 week ago