0

good evening,

I'm trying to solve an algorithm problem, I can't. A problem that looks like a cellular automaton.

I can not find a good algorithm, I try bruteforce; A lot of things...

If anyone has a solution; which algorithm would fit best?

Explanation of the game

The object of the game is to reverse the value of the cells (except for -1 which will have to keep its location).

Indeed, each cell contains a value:

gray = -1
white = 0
red = 1

This game is performed per round, and each round is associated with a value (1 or 0), for example:

(The associated values ​​are known in advance and start with 0, then 1, then 0 then 1, then 0 ..)

Round 1 X = 0
Round 2 X = 1
Round 3 X = 0
Round 4 X = 1

I can exchange the value -1, with a linked cell that is equal to the value of the turn. The two values of the cells are exchanged.

I can only exchange one cell per turn in the nodes of your choice. enter image description here No limit of turn is imposed.

ken
  • 127
  • 3
  • 8
  • So in the second graph, on the first turn, it's permissible to make `V` Red/-1, and `S` Grey/0, because "the value of the turn" is `0`, and `V` is currently coloured Grey/0 ? – Kingsley Dec 12 '19 at 00:33
  • @Kingsley Exactly, that's it – ken Dec 12 '19 at 00:33
  • 1
    This does not look like a cellular automaton to me. It seems more like a game tree search or a pathfinding problem. Anyway, a few clarifications might be helpful: 1) do you just want to know if a solution exists, or do you want an optimal (= fewest rounds?) solution; 2) is the number of rounds limited; 3) do you know the "values" of the rounds in advance, and do they follow some pattern (e.g. odd-numbered rounds are 0, even-numbered are 1)? – Ilmari Karonen Dec 12 '19 at 12:08
  • 1
    (Also, I feel like it would be a lot clearer if you renumbered the cell values as e.g. gray = -1, red = 0, white = +1, since then you could actually say that the goal of the game was to negate the value of each cell. Or just omit the numeric values entirely and say that the goal is to swap the gray and white cells.) – Ilmari Karonen Dec 12 '19 at 12:10
  • @Ilmari Karonen I want to know if a solution exists, and that can be checked quickly. No number of limited turns. Yes the turns are known, 0, then 1, then 0, then 1 .... – ken Dec 12 '19 at 12:23
  • @IlmariKaronen I actually update the subject, thanks – ken Dec 12 '19 at 12:32
  • 1
    One more question: your diagram shows an arrow from cell P to cell M without a corresponding reverse arrow. What does that mean? Can I only swap cells P and M if P is red? Or only if M is red? Or is it just a mistake in the diagram? – Ilmari Karonen Dec 12 '19 at 12:41
  • @IlmariKaronen I can indeed permutate P and M. I will specify in the subject. Sorry for this last point – ken Dec 12 '19 at 12:43

0 Answers0