public static bool hasTrueTarget(SybSrhItem item) { bool retval = false; if (item.GetTrueTarIdx() != -1) { retval = true; } return(retval); }
private void appendItemInfo2QRec(ref QRecSymbolSearch rec, SybSrhItem item) { for (int i = 0; i < rec.TarIdx.Length; i++) { rec.TarIdx[i] = item.Target[i].Index; rec.TarType[i] = item.Target[i].Type; } rec.TrueTarAt = item.GetTrueTarIdx(); for (int i = 0; i < rec.SelIdx.Length; i++) { rec.SelIdx[i] = item.Selection[i].Index; rec.SelType[i] = item.Selection[i].Type; } rec.TrueSelAt = item.GetTrueSelectionIdx(); }
private SybSrhItem make234Types(SybSrhItem item, int typeCount) { int trueSelIdx = -1; if (targetSameType(item)) { //determine how many same type 2 random int abCount = -1; trueSelIdx = item.GetTrueSelectionIdx(); if (trueSelIdx != -1)//has true sel { switch (typeCount) { case 2: abCount = 3; break; case 3: abCount = mRDM.Next(1, 3); break; case 4: abCount = mRDM.Next(0, 2); break; } } else//has no true sel { switch (typeCount) { case 2: abCount = 4; break; case 3: abCount = mRDM.Next(2, 4); break; case 4: abCount = mRDM.Next(1, 3); break; } } //build fill in index TypeAndIndex[] t0i = null; //random same type ones int[] exceptionIndex = new int[2]; exceptionIndex[0] = item.Target[0].Index; exceptionIndex[1] = item.Target[1].Index; TypeAndIndex[] sameTypeOnes = genElemsOfType(item.Target[0].Type, exceptionIndex, abCount); //random diff type ones int diffTypeCount = -1; switch (typeCount) { case 2: diffTypeCount = 1; break; case 3: diffTypeCount = 2; break; case 4: diffTypeCount = 3; break; } TypeAndIndex[] diffTypeOnes = gen1ElemsFromEachType(new int[1] { item.Target[0].Type }, diffTypeCount); //combine and fill t0i = Join2ArraysOfT0I(sameTypeOnes, diffTypeOnes); randomFillSelectionNoOverwrite(ref item, t0i); //one supplementary for (int i = 0; i < item.Selection.Length; i++) { if (item.Selection[i] == null) { TypeAndIndex[] oneSupp = genElemsOfType(diffTypeOnes[0].type, new int[1] { diffTypeOnes[0].index }, 1); SybSrhVisualElem ssvi = new SybSrhVisualElem(); ssvi.Type = oneSupp[0].type; ssvi.Index = oneSupp[0].index; ssvi.BMP = mFetcher.GetPic(oneSupp[0].type, oneSupp[0].index); item.Selection[i] = ssvi; } } } else { //get count int aCount = 0, bCount = 0, randomCount = 0; switch (typeCount) { case 2: aCount = mRDM.Next(2, 4); bCount = 5 - aCount; break; case 3: aCount = mRDM.Next(2, 4); bCount = mRDM.Next(0, 5 - aCount); randomCount = 5 - aCount - bCount; break; case 4: aCount = mRDM.Next(1, 3); bCount = mRDM.Next(1, 4 - aCount); randomCount = 5 - aCount - bCount; break; } //get if has true int trueTarIdx = item.GetTrueTarIdx(); if (trueTarIdx != -1) { if (trueTarIdx == 0) { aCount--; } else { if (bCount > 0) { bCount--; } else { randomCount--; } } } //gen, join & fill TypeAndIndex[] aTA = genElemsOfType(item.Target[0].Type, new int[1] { item.Target[0].Index }, aCount); TypeAndIndex[] bTA = genElemsOfType(item.Target[1].Type, new int[1] { item.Target[1].Index }, bCount); TypeAndIndex[] rTA = gen1ElemsFromEachType( new int[2] { item.Target[0].Type, item.Target[0].Type }, randomCount); TypeAndIndex[] a0b = Join2ArraysOfT0I(aTA, bTA); TypeAndIndex[] all = Join2ArraysOfT0I(a0b, rTA); randomFillSelectionNoOverwrite(ref item, all); ////undefined //for (int i = 0; i < item.Selection.Length; i++) //{ // if (item.Selection[i] == null) // { // int a = 0; // } //} } return(item); }