/// <summary> /// Finds the shakespeare thinking and returns a list of move to play /// </summary> /// <returns></returns> public List <Move> FindShakespeare() { List <Move> moves = new List <Move>(); List <Move> shakespeareMoves = ShakespeareAI.CreateSequence(); int correct = 0, alignementIndex = -1; if (CurrentRound >= 8) { for (int index = 0; index < shakespeareMoves.Count; index++) { correct = 0; for (int j = 0; j < OpponentMoves.Count; j++) { int shakespearePointer = index + j; if (shakespearePointer >= shakespeareMoves.Count) { shakespearePointer = (index + j) - shakespeareMoves.Count; } if (shakespeareMoves[shakespearePointer] == OpponentMoves[j]) { correct++; } } if ((correct * 100f) / OpponentMoves.Count >= 50f) { alignementIndex = index; } } if (alignementIndex == -1) { return(null); } for (int z = 0; z < MaxRound; z++) { int ptr = alignementIndex + z; if (ptr >= shakespeareMoves.Count) { ptr = (alignementIndex + z) - shakespeareMoves.Count; } foreach (MoveInfo info in MoveInfos) { if (info.WinAgainst[0] == shakespeareMoves[ptr] || info.WinAgainst[1] == shakespeareMoves[ptr]) { moves.Add(info.Move); break; } } } return(moves); } return(null); }
public LastSolution() { Nickname = "Sensei"; sonnetSequence = ShakespeareAI.CreateSequence(); int n = sonnetSequence.Count; for (int i = 0; i < n; i++) { sonnetSequence.Add(sonnetSequence[i]); } }
public BOLU() { Nickname = "Baba is Mittens Two"; CourseSection = Section.S07049; for (int i = 0; i < 5; i++) { posMoves.Add(new List <int[]>()); for (int j = 0; j < 5; j++) { posMoves[i].Add(new int[5]); } } poetMove = ShakespeareAI.CreateSequence(); }
public void rangeListShake() { foreach (char c in ShakespeareAI.SonnetXVII) { if (c >= 'A' && c <= 'z') { ListShakespeare.Add(ShakespeareAI.CharToMove(c)); } } //for(int i =0; i < ListShakespeare.Count; i++) //{ // Console.Write(ListShakespeare[i]+" "); // Console.Write(i + " "); //} }
private Move AgainstShakespeare() { if (!listInitialized) { listInitialized = true; enemyMoveSequence = ShakespeareAI.CreateSequence(); moveStartIndexFrequency = new int[enemyMoveSequence.Count]; } if (currentEnemyMove < 0) { return(RandomMove()); } for (var i = 0; i < moveStartIndexFrequency.Length; i++) { if (i + currentEnemyMove < enemyMoveSequence.Count && enemyMoveSequence[i + currentEnemyMove] == EnemyMoves[currentEnemyMove]) { moveStartIndexFrequency[i]++; } } var maxIndex = -1; var maxTimes = -1; for (var i = 0; i < moveStartIndexFrequency.Length; i++) { if (moveStartIndexFrequency[i] >= maxTimes) { maxTimes = moveStartIndexFrequency[i]; maxIndex = i; } } //if (currentEnemyMove == 98) Console.WriteLine("Max times = " + maxTimes); if (maxIndex + currentEnemyMove + 1 > enemyMoveSequence.Count - 1) { return(RandomMove()); } return(CounterMove(enemyMoveSequence[maxIndex + currentEnemyMove + 1])); }
private Move Virgil() { string currentJet; switch (felixAi[felixAi.Count - 1]) { case Move.Rock: currentJet = "edfb"; break; case Move.Paper: currentJet = "thmgxz"; break; case Move.Scissors: currentJet = "aruwkj"; break; default: case Move.Spock: currentJet = "oslpq"; break; case Move.Lizard: currentJet = "incyv"; break; } theArtist.Add(currentJet); if (turns > 5) { divines.Clear(); var amateurPeotry = ShakespeareAI.SonnetXVII.ToLower(); string divineComedy = ""; foreach (var item in amateurPeotry) { if (Char.IsLetter(item)) { divineComedy += item; } } string verse; for (int letter = 0; letter < divineComedy.Length - 1; letter++) { verse = ""; int tempCount = letter; int validationCount = 0; for (int artI = 0; artI < theArtist.Count - 1; artI++) { string test = verse; foreach (var item in theArtist[artI]) { if (tempCount > divineComedy.Length - 1) { tempCount -= divineComedy.Length; } if (divineComedy[tempCount] == item) { validationCount++; tempCount++; verse += item; break; } } if (verse == test) { tempCount++; } if (validationCount > (theArtist.Count * .40) & !bannedIndexes.Contains(letter)) { divines.Add(new Divine(verse, tempCount, validationCount)); divines[divines.Count - 1].Verse = verse; divines[divines.Count - 1].TempCount = tempCount; divines[divines.Count - 1].Validation = validationCount; } } } divines.Sort((a, b) => (a.Validation.CompareTo(b.Validation))); if (divines.Count > 0) { int c = divines[divines.Count - 1].TempCount; // Console.WriteLine(divines[divines.Count - 1].Verse); c++; if (c < divineComedy.Length) { char d = divineComedy[c]; return(choiceC(ShakespeareAI.CharToMove(d))); } } } return(Move.Rock); }