public SybSrhResult(bool ans, long rt, SybSrhItem item) { Answer = ans; RT = rt; for (int i = 0; i < item.Target.Length; i++) { item.Target[i].BMP = null; } for (int i = 0; i < item.Selection.Length; i++) { item.Selection[i].BMP = null; } Item = item; if (ans == SybSrhItemGenerator.hasTrueTarget(item)) { Correctness = true; } else { Correctness = false; } }
private bool targetSameType(SybSrhItem item) { bool retval = false; if (item.Target[0].Type == item.Target[1].Type) { retval = true; } return(retval); }
public static bool hasTrueTarget(SybSrhItem item) { bool retval = false; if (item.GetTrueTarIdx() != -1) { retval = true; } return(retval); }
private SybSrhItem randomPickout(ref List <SybSrhItem> source) { SybSrhItem retval = null; int pos2Get = -1; if (source.Count != 0) { pos2Get = mRDM.Next(0, source.Count); retval = source[pos2Get]; source.RemoveAt(pos2Get); } return(retval); }
private List <SybSrhItem> makeHeadTailDiff(List <SybSrhItem> items) { //head same bool noBreak = true; int noBreakCount = 0; while (noBreak) { noBreak = false; if (hasTrueTarget(items[0]) == hasTrueTarget(items[1])) { noBreak = true; } //tail same if (hasTrueTarget(items[10]) == hasTrueTarget(items[11])) { noBreak = true; } //head 2 tail if (noBreak) { SybSrhItem item = items[0]; items.RemoveAt(0); items.Add(item); noBreakCount++; if (noBreakCount >= 6) { noBreak = false; } } } //String outS = "headT: "; //for (int z = 0; z < items.Count; z++) //{ // if (hasTrueTarget(items[z])) // { // outS += "o"; // } // else // { // outS += "x"; // } //} //Console.WriteLine(outS); return(items); }
private List <SybSrhItem> gen1PosNegByHalf() { List <SybSrhItem> retval = new List <SybSrhItem>(); int typeTemp = -1; int posTarTemp = -1; int posSelectionTemp = -1; int picIndexTemp = -1; for (int i = 0; i < 12; i++) { typeTemp = mRDM.Next(0, 10); picIndexTemp = mRDM.Next(0, mFetcher.GetTypeElemCount(typeTemp)); Bitmap bmp = mFetcher.GetPic(typeTemp, picIndexTemp); posTarTemp = mRDM.Next(0, 2); posSelectionTemp = mRDM.Next(0, 5); SybSrhItem item = new SybSrhItem(); SybSrhVisualElem target = new SybSrhVisualElem(); target.BMP = bmp; target.Type = typeTemp; target.Index = picIndexTemp; //item.Targets[posTarTemp] = bmp; //item.Info.TargetsTypes[posTarTemp] = typeTemp;//save info //item.Info.TargetsPicIndex[posTarTemp] = picIndexTemp; if (i < 6)//one target has a same selection { //mark as true target.IfTrue = true; //selections SybSrhVisualElem selection = new SybSrhVisualElem(); selection.BMP = bmp; selection.IfTrue = true; selection.Type = typeTemp; selection.Index = picIndexTemp; item.Selection[posSelectionTemp] = selection; } item.Target[posTarTemp] = target; retval.Add(item); } 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 void randomFillSelectionNoOverwrite( ref SybSrhItem item, TypeAndIndex[] t0i) { int[] expList = new int[1]; expList[0] = item.GetTrueSelectionIdx(); int[] order = randomPickElemNoRepeat(t0i.Length, 5, expList); for (int i = 0; i < order.Length; i++) { SybSrhVisualElem elem = new SybSrhVisualElem(); elem.BMP = mFetcher.GetPic(t0i[i].type, t0i[i].index); elem.Type = t0i[i].type; elem.Index = t0i[i].index; item.Selection[order[i]] = elem; } }
private void loadContent(List <List <String> > tm) { List <SybSrhItem> rev = new List <SybSrhItem>(); for (int i = 0; i < tm.Count; i++) { int j = 0; mSybSrhItem = new SybSrhItem(); while (j < tm[i].Count - 3) { for (int y = 0; y < 2; y++) { tar = new SybSrhVisualElem(); tar.Type = Convert.ToInt32(tm[i][j++]); tar.Index = Convert.ToInt32(tm[i][j++]); String tem = tm[i][j++]; if (tem == "1") { tar.IfTrue = true; } else if (tem == "0") { tar.IfTrue = false; } mSybSrhItem.Target[y] = tar; } for (int p = 0; p < 5; p++) { sel = new SybSrhVisualElem(); sel.Type = Convert.ToInt32(tm[i][j++]); sel.Index = Convert.ToInt32(tm[i][j++]); String tem = tm[i][j++]; if (tem == "1") { sel.IfTrue = true; } else if (tem == "0") { sel.IfTrue = false; } mSybSrhItem.Selection[p] = sel; } }//while rev.Add(mSybSrhItem); } //for _test = rev;// } //loadcontent
private List <SybSrhItem> gen2TragetsSmaeTypeByHalf(List <SybSrhItem> source) { List <SybSrhItem> retval = new List <SybSrhItem>(); for (int i = 0; i < 12; i++) { SybSrhItem item = randomPickout(ref source); int oriTarType = -1; int oriTarIndex = -1; int oriTarAt = -1; int fillTarAt = -1; int typeElemCount = -1; int newTarIndex = -1; //to get which to fill if (item.Target[0] != null) { oriTarAt = 0; fillTarAt = 1; } else { oriTarAt = 1; fillTarAt = 0; } oriTarType = item.Target[oriTarAt].Type; oriTarIndex = item.Target[oriTarAt].Index; typeElemCount = mFetcher.GetTypeElemCount(oriTarType); if (i < 6)//from same type { while (newTarIndex == -1 || newTarIndex == oriTarIndex) { newTarIndex = mRDM.Next(0, typeElemCount); } SybSrhVisualElem tar = new SybSrhVisualElem(); tar.BMP = mFetcher.GetPic(oriTarType, newTarIndex); tar.Index = newTarIndex; tar.Type = oriTarType; item.Target[fillTarAt] = tar; } else//form different type { int newTarType = -1; while (newTarType == -1 || newTarType == oriTarType) { newTarType = mRDM.Next(0, 10); } newTarIndex = mRDM.Next(0, mFetcher.GetTypeElemCount(newTarType)); SybSrhVisualElem tar = new SybSrhVisualElem(); tar.BMP = mFetcher.GetPic(newTarType, newTarIndex); tar.Index = newTarIndex; tar.Type = newTarType; item.Target[fillTarAt] = tar; } retval.Add(item); } return(retval); }
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); }