0

I'm doing a project for the purpose of learning more about abstraction in CS. I created a project in MIT-scratch in which four characters must have unique paths on a simple map, and not collide or pass through each other. I also want the paths to be somewhat complicated, otherwise, I could just make them all go in a circle.

To solve this problem with abstraction, I marked each of the nine possible locations on the map with a number, and control each character's path with an array which contains what map number it should be on at each interval of the cycle clock.

image of nine character locations

Using this program and some paper, I was able to find several rules for the arrays which if followed, should solve the original problem.

  1. each next item in an array must be a neighbor to the previous one, including the first and last numbers in the array, to create a complete loop.

    (1,2,5,4) OK

  2. two arrays cannot have the same number at the same location.

    (1,2) (3,2) not OK

  3. two arrays cannot have a reciprocal pair at the same location.

    (4,5) (5,4) not OK

My question is, how would I go about creating a program that would show me all possible solution paths based on paths that I input? It could be a python program which outputs array/s, or I could create it in the scratch program along with some kind of graphical path creator. Any help is appreciated, I have no idea how to go about this.

There's a bit of a complication, too. In the map, 1 and 4 are neighbors, but the abstraction, they are not. This could possibly be solved using some kind of function with a list of which numbers are neighbors.

Here's the scratch project if it's helpful: https://scratch.mit.edu/projects/321905242/

martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

0

You should first plan out how which character can go to which spots. Afterwards, you should create a function that denies the specific character, assuming that you given all the characters different variables. Maybe that will work? P.S. remember to make a table for each character!

Gamernet
  • 41
  • 6