Action ChooseRandStep(Direction dir) { Action step = null; Random rnd = new Random(); do { //перебор направлений движения не закончится, пока мы знаем, что предполагаемое направление наверно. step = actArr[rnd.Next(0, actArr.Count())]; } while (Machine.IsOutputWrongForInput(dir.symbol, step.symbol)); return step; }
void LearnToMove(Direction dir) { Action step; do { step = ChooseRandStep(dir); rob.MakeStep(step, learnDelay); Interface.LrnStepAdd(); //плюс шаг, потраченный на обучение if (IsLastStepRight(dir.axis)) Machine.SetRightOutputForInput(dir.symbol, step.symbol); else Machine.SetWrongOutputForInput(dir.symbol, step.symbol); } while (!Machine.RightOutputExistsForInput(dir.symbol));//пока не подобрано верное соответствие Interface.RefreshList(dir.name + " (" + dir.symbol + ')' , step.name + " (" + step.symbol + ')'); }
void AttemptMove(Direction dir) { if (Machine.RightOutputExistsForInput(dir.symbol)) rob.MakeStep((Action)Machine.GetRightOutputForInput(dir.symbol), normalDelay); else LearnToMove(dir); }