A
A
Andrey Ovchinnikov2019-12-11 17:34:12
Algorithms
Andrey Ovchinnikov, 2019-12-11 17:34:12

How to create an adjacency matrix based on a 2D map?

Hello. The problem is the following, there is a map (as in the picture). You need to build an adjacency matrix, where 1 row is the cell where the monster is. What algorithm can do this?
5df0fdf46186c923640513.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2019-12-11
@Jailpy

Since there are no "portals", any cell can be accessed from a maximum of 4 adjacent ones.
Number the cells, go around each, count how many of the four neighbors are available - not a wall, not outside the map.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question