Заменил if-else на gurads
This commit is contained in:
@@ -1,18 +1,10 @@
|
||||
forgivingStrategy :: (Ord t, Num t) => [Char] -> [Char] -> t -> [Char]
|
||||
forgivingStrategy opponentMoves generatedMoves n =
|
||||
if n <= 100 && length opponentMoves /= 1
|
||||
then
|
||||
( if n == 0
|
||||
then
|
||||
forgivingStrategy opponentMoves (generatedMoves ++ ['С']) (n + 1)
|
||||
else
|
||||
if head opponentMoves == 'С'
|
||||
then
|
||||
forgivingStrategy (tail opponentMoves) (generatedMoves ++ ['С']) (n + 1)
|
||||
else
|
||||
forgivingStrategy (tail opponentMoves) (generatedMoves ++ ['П']) (n + 1)
|
||||
)
|
||||
else generatedMoves
|
||||
forgivingStrategy opponentMoves generatedMoves n
|
||||
| n > 100 || length opponentMoves == 1 = generatedMoves
|
||||
| n == 0 = forgivingStrategy opponentMoves (generatedMoves ++ ['С']) (n + 1)
|
||||
| head opponentMoves == 'С' = forgivingStrategy (tail opponentMoves) (generatedMoves ++ ['С']) (n + 1)
|
||||
| otherwise = forgivingStrategy (tail opponentMoves) (generatedMoves ++ ['П']) (n + 1)
|
||||
|
||||
|
||||
indexOf :: (Eq t) => [t] -> t -> Int
|
||||
indexOf [] _ = -1
|
||||
@@ -35,6 +27,7 @@ nashStrategy opponentMoves generatedMoves n =
|
||||
]
|
||||
nextStep = cases !! indexOf results result !! 1
|
||||
|
||||
getScore :: Num t => [Char] -> [Char] -> t -> t -> (t, t)
|
||||
getScore moves1 moves2 score1 score2 =
|
||||
if length moves1 == 0 then (score1, score2)
|
||||
else getScore (tail moves1) (tail moves2) newScore1 newScore2
|
||||
|
||||
Reference in New Issue
Block a user