1. Since the above scenario can be translated to a Directed graph with V vertices (V = n*m) and M edges (M = total possible moves).
We need to find path, if it exists, from one vertex to another in the graph.
We can use the Breadth First Search (BFS) or Depth First Search (DFS) to find if there exists a path by starting from one vertex and check if other one comes during the search.
Description of BFS
Let Q be a queue, S be the starting vertex and D be the destination vertex
For all the vertices that are directly connected to S, insert them into the Q
Now for all the vertices in Q, check if D is one of them. If it is, then path exists else repeat the same process as done with the starting vertex i.e. insert all the vertices that are connected to it and havent been visited yet, to the queue.
In the end, if D is not encountered then report that path does not exists else path exists.
Time Complexity = O(V+E) = O(k^4) where k is the side of the grid.
V is O(k*k) since there can be k*k vertices at max
E is O(k^4) since there can be at max k*(k-1)/2 edges
2 Super Mario Run A Mario World M consists of a k xk grid. Each field...
2 Super Mario Run A Mario World M consists of a k xk grid. Each field in the grid is either empty or brick. Two empty fields are marked as start and goal (see Fig. 2(a)). The goal of the game is to move the player, called Mario, from the start field to the goal field. When Mario is in field (x,y) he has the following options: Forward Mario moves to the field (x+1, y). This move is possible if...
Big O run time of algorithm 2 Super Mario Run A Mario world M consists of a k × k grid. Each field in the grid is either empty or brick. Two empty fields are marked as start and goal (see Fig. 2(a)). The goal of the game is to move the player, called Mario, from the start field to the goal field. When Mario is in field (x, y) he has the following options Forward Mario moves to the...
Figure 1: An 8 x & Mario world and corresponding Mario graph. 2 Super Mario Run A Mario world M consists of a k xk gid. Each field in the grid is either empy or brick. Two empty fields are marked as start and goal (see Fig. 21a). The goal ot the game s to move the playe, called Mario, irom the start field to the goal field. When Mario is in field (x,y) he has the following options: Forward...
2. Super Mario must travel through a landscape made up of n spaces each filled with a mushroom, a spike or nothing. He wishes to reach the princess who is on space n. Super Mario can choose to advance 1 step or jump J steps. To start, J- 2, if he lands on a space that has a mushroom then J increases by You are given an array of the landscape L1,.., n] such that L] N if there is...
I need help with my programming assignment. The language used should be java and the algorithm should use search trees so that you play against the computer and he chooses the best move. The tree should have all possibilities on the leaves and you could use recursion to so that it populates itself. The game can be a 3*3 board (no need the make it n*n). Please put comments so that I can understand it. Thanks The game of ‘Walls’...
This lab will use 2D arrays, recursive algorithms, and logical thinking. The following grid of hashes(#) and dots(.) is a 2D array representation of a maze # # # # # # # # # # # # # . . . # . . . . . . # . . # . # . # # # # . # # # # . # . . . . # . # # . . . . #...
The Problem A robot is asked to navigate a maze. It is placed at a certain position (the starting position) in the maze and is asked to try to reach another position (the goal position). Positions in the maze will either be open or blocked with an obstacle. Positions are identified by (x,y) coordinates. At any given moment, the robot can only move 1 step in one of 4 directions. Valid moves are: ● Go North: (x,y) -> (x,y-1) ●...
I have to make a Reversi game in C++ where 2 algorithms play against eachother and I do not know how to even start it. In this project you are required to: 1. Implement Reversi for a board size of n x n where 4 ≤ n ≤ 16 and n is always even. 2. Implement two different algorithms that will play Reversi against each other e.g. an algorithm that randomly chooses a valid move may be one of your...
Question 2* Consider th following twelve diagrams A,... , L C: G: I: K: (a) Each diagram represents a simple graph of order 6 with exactly one circuit, but not all graphs are different. When X, Y represent the same graph we write XY. For example, A B. Partition the set {A, B,, Ly using the equivalence relation. (b) Any hydrocarbon molecule consists of joined-up carbon and hydrogen atoms, and can be represented by a connected graph in which each...
I have already finished most of this assignment. I just need some help with the canMove and main methods; pseudocode is also acceptable. Also, the programming language is java. Crickets and Grasshoppers is a simple two player game played on a strip of n spaces. Each space can be empty or have a piece. The first player plays as the cricket pieces and the other plays as grasshoppers and the turns alternate. We’ll represent crickets as C and grasshoppers as...