bool Control::check10() { vector<int> tmp; int i; if (checkSequenceOfPairs()) //连对3344556677 { typeMy=SEQUENCE_QUENCE_OF_PAIRS; return true; } for(i=0;i<3;i++) //飞机带翅膀3334445566 { tmp.assign(myOut.begin()+2*i,myOut.begin()+2*i+6); if (checkSequenceOfTriplets(tmp)) { tmp.assign(myOut.begin(),myOut.end()); tmp.erase(tmp.begin()+2*i,tmp.begin()+2*i+6); if (checkSequenceOfPairs2(tmp)) { typeMy=SEQUENCE_QUENCE_OF_TRIPLETS_WITH_TWO; return true; } } } if (checkSequence()) //单顺345678910JQ { typeMy=SEQUENCE_QUENCE; return true; } return false; }
bool Control::check12() { int i; vector<int> tmp; if (checkSequence()) { typeMy=SEQUENCE_QUENCE; return true; } if (checkSequenceOfPairs()) { typeMy=SEQUENCE_QUENCE_OF_PAIRS; return true; } if (checkSequenceOfTriplets(myOut)) { typeMy=SEQUENCE_QUENCE_OF_TRIPLETS; return true; } for (i=0;i<3;i++) { tmp.assign(myOut.begin()+i,myOut.begin()+i+9); //飞机带翅膀333444555678 if (checkSequenceOfTriplets(tmp)) { typeMy=SEQUENCE_QUENCE_OF_TRIPLETS_WITH_ONE; return true; } } return false; }
void loop(){ if(!started){ print("Program active\n\n",0); started=true; }; for(int i=0;i<11;i++){ // count over LED pairs if(i==0) { if(cycleCount < 4){ cycleCount++; } else reInit(); // reinit after 3 incomplete cycles }; if(checkCompletion() == -1 && haltUntilFirstTouch) { i=0;} // stalls the sequence on position 1 until that is touched print("Pair ",0); print(i,0); print(" is on.\n",0); killLEDs(); lightLEDpair(i); for(int j=0;j<25;j++){ // split delays in about 10-20ms to have steady timing if(fridgeUnlocked) unlock(); checkNodes(); int completedStep = checkSequence(); if((completedStep >= 0) && (completedStep != previousCycle) && (touchLEDcorrespondence[completedStep] < i+1)) { // if the LEDs are ahead of the user, restart at the user's current position previousCycle = completedStep; i = touchLEDcorrespondence[completedStep]; // it seems if i=0 here the next loop is executed with i=1 if(i == 0) revertTo0 = true; print("Reverted to pair ",0);print(i,0);print("\n",0); break; } previousCycle = completedStep; delay((LEDpairs[i][4]/25)); } if(revertTo0){ revertTo0 = false; break; // break main for loop to get i=0 } if(fridgeUnlocked){ print("Successfully unlocked!\n\n",0); lightLEDpair(10); for(int j=0;j<3;j++){ delay(2500); killLEDs(); delay(1500); lightLEDpair(10); }; delay(3000); reInit(); break; }; } }
bool Control::check7() { if (checkSequence()) { typeMy=SEQUENCE_QUENCE; return true; } return false; }
bool Control::check9() { if (checkSequenceOfTriplets(myOut)) //飞机 333444555 { typeMy=SEQUENCE_QUENCE_OF_TRIPLETS; return true; } if (checkSequence()) //单顺345678910J { typeMy=SEQUENCE_QUENCE; return true; } return false; }
bool Control::check6() { if (checkSequenceOfPairs()) { typeMy=SEQUENCE_QUENCE_OF_PAIRS; return true; } if (checkSequenceOfTriplets(myOut)) { typeMy=SEQUENCE_QUENCE_OF_TRIPLETS; return true; } if (checkSequence()) { typeMy=SEQUENCE_QUENCE; return true; } return false; }
bool Control::check5() { if (myOut[0]==myOut[1]&&myOut[1]==myOut[2]&&myOut[2]!=myOut[3]&&myOut[3]==myOut[4])//三带二,如33344 { myThree.clear(); myThree.push_back(myOut[0]); typeMy=TRIPLE_WITH_TWO; return true; } else if (myOut[0]==myOut[1]&&myOut[1]!=myOut[2]&&myOut[2]==myOut[3]&&myOut[3]==myOut[4])//三带二,如33444 { myThree.clear(); myThree.push_back(myOut[2]); typeMy=TRIPLE_WITH_TWO; return true; } else if (checkSequence()) //单顺 34567 { typeMy=SEQUENCE_QUENCE; return true; } return false; }