private string upDateChanseAfterUse(string MoveUp, MovingXml currentObject, int value) { var index = fullMoves.IndexOf(currentObject); var dictCurrentObj = currentObject.Chanse; if (last != null) { var indexprev = fullMoves.IndexOf(fullMoves.FirstOrDefault(n => n.possiton == last)); var PrevObject = fullMoves[indexprev]; if (!currentObject.PrevPossiton.Select(n => n.Position).Contains(last)) { currentObject.PrevPossiton.Add(new PrevChoes { Position = last, Move = lastChoese }); } } dictCurrentObj[MoveUp] = currentObject.Chanse[MoveUp] + value; currentObject.Chanse = dictCurrentObj; fullMoves[index] = currentObject; FileContorl file = new FileContorl(_fileName); file.update(fullMoves); return(dictCurrentObj.ProbablityRandom()); }
public void GetSetTests() { MovingXml xml = new MovingXml(); xml.Chanse = generateValues(); Assert.NotEmpty(xml.moves); Assert.NotEmpty(xml.chanses); var dic = xml.Chanse; dic["10"] = 21; xml.Chanse = dic; Assert.Equal(21, xml.Chanse["10"]); }
private MovingXml shareForOne(List <MovingXml> nextMoves, out int value) { value = 0; MovingXml best = nextMoves[0]; foreach (var item in nextMoves) { if (best == item) { continue; } else { best = whoIsTheBest(item, best, out value); } } return(best); }
private MovingXml whoIsTheBest(MovingXml item, MovingXml best, out int value) { var valueItem = figureCounting(item.possiton); var valueBest = figureCounting(best.possiton); if (valueBest > valueItem) { value = valueBest - valueItem; } if (valueBest < valueItem) { value = valueItem - valueBest; } else { value = 0; } return(valueItem > valueBest ? item : best); }
public void ChanseSetTest() { MovingXml ob = new MovingXml(); }
private bool findConnection(MovingXml one, MovingXml two, out string move) { move = two.PrevPossiton.FirstOrDefault(n => n.Position == one.possiton).Move; return(!string.IsNullOrEmpty(move)); }