Fix combination bug with small inventories
This commit is contained in:
@@ -48,12 +48,10 @@ lookupItemsUsingTrie ((mods,ct,i,n):xs) t = do
|
||||
let is = replicate n' (mods,i)
|
||||
concatMap (map (first (is ++)) . lookupItemsUsingTrie xs) $ maybeToList (_trieChildren t M.!? (n',ct))
|
||||
|
||||
invertListInvMult :: IM.IntMap Item
|
||||
-> [[(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]]
|
||||
invertListInvMult :: IM.IntMap Item -> [[(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]]
|
||||
invertListInvMult = powlistUpToN 4 . invertListInv
|
||||
|
||||
invertListInv :: IM.IntMap Item
|
||||
-> [(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]
|
||||
invertListInv :: IM.IntMap Item -> [(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]
|
||||
invertListInv = IM.foldrWithKey
|
||||
(\k it -> ((_itModules it,_itType it, k, itStackAmount it) :) )
|
||||
[]
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module Dodge.Initialisation where
|
||||
import Dodge.Default.World
|
||||
--import Dodge.Combine
|
||||
--import Dodge.Base.You
|
||||
--import Dodge.Base
|
||||
--import Dodge.Save
|
||||
import Dodge.Data
|
||||
@@ -39,4 +41,5 @@ initialWorld = defaultWorld
|
||||
}
|
||||
|
||||
testStringInit :: World -> [String]
|
||||
testStringInit w = [show $ length $ _magnets w]
|
||||
--testStringInit = map (concatMap $ \(_,ct,_,_) -> show ct) . invertListInvMult . yourInv
|
||||
testStringInit = const []
|
||||
|
||||
+12
-2
@@ -18,9 +18,19 @@ powlistUpToN' n (x:xs)
|
||||
-- there is a (probably) faster SO answer that produces power lists of size
|
||||
-- exactly N, but that answer is harder to adapt
|
||||
powlistUpToN :: Int -> [a] -> [[a]]
|
||||
powlistUpToN n xs =
|
||||
powlistUpToN n xs = concat $ drop (length xs-n) (subseqsBySize xs)
|
||||
where
|
||||
subseqsBySize [] = [[[]]]
|
||||
subseqsBySize (y:ys) =
|
||||
let next = subseqsBySize ys
|
||||
in zipWith (++) ([]:next) (map (map (y:)) next ++ [[]])
|
||||
powlistUpToN'' :: Int -> [a] -> [[a]]
|
||||
powlistUpToN'' n xs =
|
||||
let l = length xs
|
||||
in if n > l then [] else concat $ drop (l-n) (subseqsBySize xs)
|
||||
-- in if n > l then [] else concat $ drop (l-n) (subseqsBySize xs)
|
||||
in if n > l
|
||||
then concat $ subseqsBySize xs
|
||||
else concat $ drop (l-n) (subseqsBySize xs)
|
||||
where
|
||||
subseqsBySize [] = [[[]]]
|
||||
subseqsBySize (y:ys) =
|
||||
|
||||
Reference in New Issue
Block a user