A
A
Alexander Wolf2016-02-12 16:08:05
JavaScript
Alexander Wolf, 2016-02-12 16:08:05

Finite automata and their practical application?

Good afternoon! We have a section on the site with logic. After the user programs it (by setting the parameters he needs), he proceeds to a small test. When he enters the answer to the question "aaa", then depending on the given parameters, he will go to the question "2. q" or somewhere else. There can be any number of such blocks. They are connected using the logical OR.

[]
(aaa == qa || aaa == qb || ... || aaa === qw) => 2. q
[]
(...) => 3. w 
[]
(...) => 4. d
[]
 ...
[]
(...) = x. что-то

JSON representation
[{
  "conditions": [{
    "expected": "FC3fbfZiRMxCL7Aq8"
  }, {
    "type": "or",
    "expected": "5zEsXWBLLRGEH9p2D"
  }, {
    "type": "or",
    "expected": "MqNeEER2KT662ySdR"
  }, {
    "type": "or",
    "expected": "HgyiSGnxTn8vEqp9t"
  }],
  "next": "SJkQW7phpwKomnSuz"
}, {
  "conditions": [{
    "expected": "38mpdXFf6p85LjENb"
  }, {
    "type": "and",
    "expected": "mht4gaX4CrJqGKRN2"
  }, {
    "type": "or",
    "expected": "Sg3AzPCoZ5aHJ6jCL"
  }, {
    "type": "or",
    "expected": "yCBMdkyTv626BJpxW"
  }],
  "next": "N4TAxk5crpLSoHzTx"
}]

Тут приведены 2 блока (на скриншоте виден только первый).
Где "next" - переход если блок возвращает true

Thus, there was a desire to organize it all with the help of finite state machines, but there is not enough practice and experience in this. Is it worth digging in this direction or am I missing something?
2b2357febcd74eb2b37741aca538e024

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Beloshitsky, 2016-02-14
@mannaro

So you have already organized the state machine, where your MqNeEER2KT662ySdR, HgyiSGnxTn8vEqp9t, SJkQW7phpwKomnSuzare its states, and the transitions between them are:
You just need to be careful about who can make what transitions. For example, let's say you're building a site with quizzes. Your site server should only make its own transitions and should not be responsible for the user, and the user, on the contrary, can only answer questions, but cannot switch between them himself. Naturally, with a different original intention, the rules may be different.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question