Add various capabilities for generating graphs, fixes to lasgun
This commit is contained in:
@@ -16,41 +16,38 @@ import LensHelp
|
||||
|
||||
itemCombinations :: [([(IcAmount,ItemBaseType)],Item)]
|
||||
itemCombinations =
|
||||
[ po [CRAFT PIPE, CRAFT HARDWARE] (bangStick 1)
|
||||
[ po [CRAFT PIPE, CRAFT HARDWARE] (bangStick 1)
|
||||
, po [BANGSTICK 1, CRAFT TIN] pistol
|
||||
, po [PISTOL, CRAFT SPRING, cr HARDWARE] autoPistol
|
||||
, po [AUTOPISTOL, cr PLANK, cr HARDWARE] smg
|
||||
, po [AUTOPISTOL, cr HARDWARE] machinePistol
|
||||
, po [PISTOL, CRAFT SPRING] autoPistol
|
||||
, po [AUTOPISTOL, cr PLANK] smg
|
||||
, po [AUTOPISTOL, cr SPRING] machinePistol
|
||||
, po [BANGSTICK 1,cr CAN] revolver
|
||||
, po [REVOLVER, cr SPRING, cr HARDWARE] $ revolverX 1
|
||||
, po [REVOLVER, cr SPRING] $ revolverX 1
|
||||
|
||||
, po [cr TUBE,cr HARDWARE] bangCone
|
||||
, po [cr CAN,cr HARDWARE] bangCone
|
||||
, po [BANGCONE,cr PLANK] blunderbuss
|
||||
, po [BLUNDERBUSS,cr TUBE] bigBlunderbuss
|
||||
, po [BIGBLUNDERBUSS,cr TUBE] biggerBlunderbuss
|
||||
, po [BIGGERBLUNDERBUSS,cr TUBE] biggestBlunderbuss
|
||||
, po [BLUNDERBUSS,cr DRUM] (grapeCannon 1)
|
||||
-- , po [BANGCONE,PUMP,HARDWARE] $ grenadeLauncher 1
|
||||
-- , po [GRENADELAUNCHER 1,MOTOR,DRUM] $ grenadeLauncher 2
|
||||
|
||||
, p [p 2 $ cr PIPE,o $ cr HARDWARE] (bangCaneX 1)
|
||||
, p [p 2 $ cr PIPE,o $ BANGCANEX 1] (bangCaneX 2)
|
||||
, po [BANGCANEX 1,cr TIN] rifle
|
||||
, po [RIFLE,cr PLANK] repeater
|
||||
, po [REPEATER,cr SPRING,cr HARDWARE] autoRifle
|
||||
, po [REPEATER,cr SPRING,cr CAN] burstRifle
|
||||
, po [BURSTRIFLE,cr SPRING,cr HARDWARE] fastBurstRifle
|
||||
, po [FASTBURSTRIFLE,cr SPRING,cr HARDWARE] completeBurstRifle
|
||||
, po [cr MOTOR,BANGCANEX 3] $ miniGunX 3
|
||||
, po [cr MOTOR,BANGCANEX 4] $ miniGunX 4
|
||||
, po [cr MOTOR,BANGCANEX 5] $ miniGunX 5
|
||||
, po [cr MOTOR,BANGCANEX 6] $ miniGunX 6
|
||||
-- , po [cr PIPE, cr HARDWARE] (volleyGun 1)
|
||||
, po [BANGSTICK 1,cr PLANK] rifle
|
||||
, p [p 3 $ BANGSTICK 1] (volleyGun 3)
|
||||
, po [RIFLE,cr TIN] repeater
|
||||
, po [REPEATER,cr SPRING] autoRifle
|
||||
, po [REPEATER,cr CAN] burstRifle
|
||||
-- , po [BURSTRIFLE,cr SPRING,cr HARDWARE] fastBurstRifle
|
||||
-- , po [FASTBURSTRIFLE,cr SPRING,cr HARDWARE] completeBurstRifle
|
||||
, po [cr MOTOR,VOLLEYGUN 3] $ miniGunX 3
|
||||
, po [cr MOTOR,VOLLEYGUN 4] $ miniGunX 4
|
||||
, po [cr MOTOR,VOLLEYGUN 5] $ miniGunX 5
|
||||
, po [cr MOTOR,VOLLEYGUN 6] $ miniGunX 6
|
||||
|
||||
, p [p 3 $ cr PIPE,o $ cr HARDWARE] bangRod
|
||||
, po [BANGROD,cr PLANK,cr HARDWARE] elephantGun
|
||||
, po [ELEPHANTGUN,cr HARDWARE,cr PRISM] sniperRifle
|
||||
, po [ELEPHANTGUN,cr HARDWARE,cr TIN] amr
|
||||
, po [AMR,cr HARDWARE,cr SPRING] autoAmr
|
||||
, po [BANGROD,cr PLATE,cr DRUM,cr MOTOR] machineGun
|
||||
-- , po [BANGSTICK 1,cr TUBE] elephantGun
|
||||
, po [AMR,cr PIPE] sniperRifle
|
||||
, po [RIFLE,cr PIPE] amr
|
||||
, po [AMR,cr SPRING] autoAmr
|
||||
, po [AMR,cr MOTOR] machineGun
|
||||
|
||||
, p [p 2 $ cr TUBE,o $ cr HARDWARE] launcher
|
||||
, p [p 2 $ cr TUBE,o LAUNCHER] (launcherX 2)
|
||||
@@ -86,12 +83,13 @@ itemCombinations =
|
||||
|
||||
, p [p 2 $ cr PLATE] flatShield
|
||||
]
|
||||
++ map (\i -> po [LASGUNWIDE i,cr TRANSFORMER,cr PRISM] $ lasWide (i+1)) [1..9]
|
||||
++ map (\i -> po [LASGUNWIDE i,cr HARDWARE] $ lasFocus i) [1..10]
|
||||
++ map (\i -> po [LASGUNWIDE i,cr TRANSFORMER,cr PRISM] $ lasWide (i+1)) [2..9]
|
||||
-- ++ map (\i -> po [LASGUNWIDE i,cr HARDWARE] $ lasFocus i) [2..10]
|
||||
++ map (\i -> po [cr PIPE,BANGSTICK i] $ bangStick (i+1)) [1..8]
|
||||
++ map (\i -> po [REVOLVERX i,cr CAN] $ revolverX (i+1)) [1..5]
|
||||
++ map (\i -> p [o (BANGCANEX i),p 2 $ cr PIPE] $ bangCaneX (i+1)) [1..5]
|
||||
++ map (\i -> po [MINIGUNX i,BANGCANEX 1] $ miniGunX (i+1)) [3..15]
|
||||
++ map (\i -> po [VOLLEYGUN i,BANGSTICK 1] $ volleyGun (i+1)) [3..5]
|
||||
++ map (\i -> po [MINIGUNX i,BANGSTICK 1] $ miniGunX (i+1)) [3..15]
|
||||
++ map (\i -> po [GRAPECANNON i,cr DRUM] $ grapeCannon (i+1)) [1,2,3]
|
||||
|
||||
++ [ po (_iyBase (_itType it):mtype) $ it & itType . iyModules . ix modtype .~ m
|
||||
| (modtype,is,ms) <- moduleCombinations
|
||||
@@ -109,8 +107,8 @@ moduleCombinations =
|
||||
[ ( ModRifleMag
|
||||
, [repeater
|
||||
,autoRifle
|
||||
,burstRifle
|
||||
,fastBurstRifle
|
||||
-- ,burstRifle
|
||||
-- ,fastBurstRifle
|
||||
]
|
||||
, [amod [cr DRUM,cr HARDWARE] DRUMMAG
|
||||
,amod [cr MOTOR,cr HARDWARE] BELTMAG
|
||||
@@ -185,19 +183,22 @@ batteryGuns =
|
||||
, lasSwing
|
||||
] ++
|
||||
[ lasWide i | i <- [1..10]
|
||||
] ++
|
||||
[ lasFocus i | i <- [1..10]]
|
||||
]
|
||||
-- ++
|
||||
-- [ lasFocus i | i <- [1..10]]
|
||||
|
||||
teleportableWeapons :: [Item]
|
||||
teleportableWeapons = bulletWeapons ++ batteryGuns ++ homingLaunchers
|
||||
|
||||
bulletWeapons :: [Item]
|
||||
bulletWeapons = [bangStick i | i <- [1..9] ]
|
||||
++ [bangCaneX i | i <- [1..6] ]
|
||||
bulletWeapons
|
||||
= [bangStick i | i <- [1..9] ]
|
||||
++ [volleyGun i | i <- [3..6] ]
|
||||
++ [revolverX i | i <- [1..5] ]
|
||||
++ [miniGunX i | i <- [3..16] ]
|
||||
++ [bangCane
|
||||
,pistol
|
||||
++ [grapeCannon i | i <- [1,2,3,4] ]
|
||||
++
|
||||
[pistol
|
||||
,autoPistol
|
||||
,smg
|
||||
,machinePistol
|
||||
@@ -206,11 +207,14 @@ bulletWeapons = [bangStick i | i <- [1..9] ]
|
||||
,repeater
|
||||
,autoRifle
|
||||
,burstRifle
|
||||
,fastBurstRifle
|
||||
,completeBurstRifle
|
||||
-- ,fastBurstRifle
|
||||
-- ,completeBurstRifle
|
||||
,bangCone
|
||||
,blunderbuss
|
||||
,bigBlunderbuss
|
||||
,biggerBlunderbuss
|
||||
,biggestBlunderbuss
|
||||
,machineGun
|
||||
,elephantGun
|
||||
,sniperRifle
|
||||
,amr
|
||||
,autoAmr
|
||||
,bangRod
|
||||
]
|
||||
|
||||
@@ -72,31 +72,27 @@ data ItemBaseType
|
||||
| EFFGUN String
|
||||
| AUTOEFFGUN String
|
||||
-- Weapons
|
||||
| BANGSTICK Int
|
||||
| BANGSTICK {_xNum :: Int}
|
||||
| PISTOL
|
||||
| REVOLVER
|
||||
| REVOLVERX Int
|
||||
| REVOLVERX {_xNum :: Int}
|
||||
| MACHINEPISTOL
|
||||
| AUTOPISTOL
|
||||
| SMG
|
||||
| BANGCONE
|
||||
| BLUNDERBUSS
|
||||
| BIGBLUNDERBUSS
|
||||
| BIGGERBLUNDERBUSS
|
||||
| BIGGESTBLUNDERBUSS
|
||||
-- | GRAPESHOTCANNON
|
||||
| GRAPECANNON {_xNum :: Int}
|
||||
-- | GRENADELAUNCHER Int -- number of chambers that can be reloaded
|
||||
-- | MORTARCONE / HANDMORTAR
|
||||
| BANGCANE
|
||||
-- | MINIGUN
|
||||
| MINIGUNX Int
|
||||
| BANGCANEX Int
|
||||
| MINIGUNX {_xNum :: Int}
|
||||
| VOLLEYGUN {_xNum :: Int}
|
||||
| RIFLE
|
||||
| REPEATER
|
||||
| AUTORIFLE
|
||||
| BURSTRIFLE
|
||||
| FASTBURSTRIFLE
|
||||
| COMPLETEBURSTRIFLE
|
||||
-- | FASTBURSTRIFLE
|
||||
-- | COMPLETEBURSTRIFLE
|
||||
| BANGROD
|
||||
| ELEPHANTGUN
|
||||
| AMR
|
||||
@@ -122,7 +118,7 @@ data ItemBaseType
|
||||
| SONICGUN
|
||||
| TRACTORGUN
|
||||
| LAUNCHER
|
||||
| LAUNCHERX Int
|
||||
| LAUNCHERX {_xNum :: Int}
|
||||
-- | TRACKINGLAUNCHER
|
||||
| REMOTELAUNCHER
|
||||
| POISONSPRAYER
|
||||
@@ -205,3 +201,4 @@ data ModuleSlot
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
makeLenses ''ItemType
|
||||
makeLenses ''ItemBaseType
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
--{-# LANGUAGE TypeSynonymInstances #-}
|
||||
--{-# LANGUAGE FlexibleInstances #-}
|
||||
module Dodge.Combine.Graph where
|
||||
import Dodge.Data hiding (East,West,North,South)
|
||||
import Dodge.Combine.Combinations
|
||||
import LensHelp
|
||||
import GraphHelp
|
||||
|
||||
import Data.Text (Text)
|
||||
import Data.Text.Lazy (toStrict,pack)
|
||||
import qualified Data.Graph.Inductive as FGL
|
||||
import GraphVizHelp
|
||||
import Data.GraphViz.Attributes.Complete
|
||||
import Data.Bifunctor
|
||||
|
||||
data CombClust
|
||||
= CraftClust
|
||||
| ItemClust
|
||||
| JoinClust
|
||||
deriving (Eq,Ord,Show,Enum,Bounded)
|
||||
|
||||
newtype CombNode = CombNode {_unCombNode :: Either ItemBaseType [(IcAmount,ItemBaseType)]}
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
instance Labellable CombNode where
|
||||
toLabelValue (CombNode Right{}) = StrLabel (pack "")
|
||||
toLabelValue (CombNode (Left ibt)) = StrLabel (pack $ show ibt)
|
||||
|
||||
newtype CombEdge = CombEdge {_unCombEdge :: Int}
|
||||
deriving (Eq,Ord,Show)
|
||||
instance Labellable CombEdge where
|
||||
toLabelValue (CombEdge 0) = StrLabel (pack "")
|
||||
toLabelValue (CombEdge x) = StrLabel (pack $ show x)
|
||||
|
||||
bulletCombinations :: [([(IcAmount,ItemBaseType)],Item)]
|
||||
bulletCombinations = filter
|
||||
( (`elem` map totype bulletWeapons)
|
||||
. totype
|
||||
. snd
|
||||
) itemCombinations
|
||||
where
|
||||
totype = _iyBase . _itType
|
||||
|
||||
maxShowX :: ItemBaseType -> Maybe Int
|
||||
maxShowX bt = case bt of
|
||||
BANGSTICK _ -> Just 2
|
||||
REVOLVERX _ -> Just 1
|
||||
VOLLEYGUN _ -> Just 3
|
||||
MINIGUNX _ -> Just 3
|
||||
GRAPECANNON _ -> Just 1
|
||||
LAUNCHERX _ -> Just 2
|
||||
-- LASGUNWIDE _ -> Just 2
|
||||
-- LASGUNFOCUS _ -> Just 2
|
||||
_ -> Nothing
|
||||
|
||||
itemCombinationsEdges :: [(CombNode,CombNode,Int)]
|
||||
itemCombinationsEdges = concatMap (f . over _2 (_iyBase . _itType)) itemCombinations
|
||||
--itemCombinationsEdges = concatMap (f . over _2 (_iyBase . _itType)) bulletCombinations
|
||||
where
|
||||
f (abts,bt)
|
||||
| bt `elem` bts = []
|
||||
| any (not . belowNumX) bts = []
|
||||
| otherwise = (CombNode $ Right abts,CombNode $ Left bt,0) : map g abts
|
||||
where
|
||||
bts = map snd abts
|
||||
g (am,bt') = (CombNode $ Left bt',CombNode $ Right abts,_toInt am)
|
||||
|
||||
combinationsGraph :: FGL.Gr CombNode CombEdge
|
||||
combinationsGraph = FGL.labnfilter (f . _unCombNode . snd)
|
||||
. second CombEdge $ mkGraphFromEdges itemCombinationsEdges
|
||||
where
|
||||
f Right {} = True
|
||||
f (Left (CRAFT _)) = False
|
||||
f (Left bt) = case maxShowX bt of
|
||||
Nothing -> True
|
||||
Just i -> _xNum bt <= i
|
||||
|
||||
belowNumX :: ItemBaseType -> Bool
|
||||
belowNumX bt = case maxShowX bt of
|
||||
Nothing -> True
|
||||
Just i -> _xNum bt <= i
|
||||
|
||||
toCombNodeLabel :: CombNode -> String
|
||||
toCombNodeLabel (CombNode (Left ibt)) = show ibt
|
||||
toCombNodeLabel (CombNode Right{}) = ""
|
||||
|
||||
combinationsDotGraph :: Text
|
||||
--combinationsDotGraph = toStrict . printDotGraph . graphToDot nonClusteredParams $ combinationsGraph
|
||||
combinationsDotGraph = toStrict . printDotGraph . graphToDot myParams
|
||||
$ combinationsGraph
|
||||
-- $ first toCombNodeLabel combinationsGraph
|
||||
|
||||
myParams :: GraphvizParams Int CombNode CombEdge CombClust CombNode
|
||||
myParams = defaultParams -- {globalAttributes = [GraphAttrs [RankDir FromLeft]]}
|
||||
& isDirectedL .~ True
|
||||
-- & globalAttributesL .~ [GraphAttrs [RankDir FromLeft,Splines PolyLine]]
|
||||
& globalAttributesL .~ [GraphAttrs [RankDir FromLeft]]
|
||||
& clusterByL .~ clusterFunc
|
||||
& isDotClusterL .~ (const False)
|
||||
& clusterIDL .~ setClusterID
|
||||
& fmtClusterL .~ clusterFormatting
|
||||
& fmtEdgeL .~ edgeFormatting
|
||||
& fmtNodeL .~ nodeFormatting
|
||||
|
||||
setClusterID :: CombClust -> GraphID
|
||||
setClusterID = Num . Int . fromEnum
|
||||
|
||||
clusterFunc :: (Int,CombNode) -> NodeCluster CombClust (Int,CombNode)
|
||||
clusterFunc n@(_,CombNode (Left bt)) = case bt of
|
||||
CRAFT _ -> C CraftClust (N n)
|
||||
_ -> C ItemClust (N n)
|
||||
clusterFunc n = C JoinClust (N n)
|
||||
|
||||
clusterFormatting :: CombClust -> [GlobalAttributes]
|
||||
clusterFormatting cl = case cl of
|
||||
-- CraftClust -> [GraphAttrs [Rank SameRank]]
|
||||
_ -> []
|
||||
|
||||
edgeFormatting :: (Int,Int,CombEdge) -> Attributes
|
||||
--edgeFormatting (_,_,CombEdge 0) = []
|
||||
-- [ArrowHead (AType [(ArrMod OpenArrow BothSides ,NoArrow)])
|
||||
-- ,SameTail (pack "b")
|
||||
-- ]
|
||||
edgeFormatting (_,_,ce) = case _unCombEdge ce of
|
||||
0 -> [ xLabel ce
|
||||
, TailPort (CompassPoint East)
|
||||
]
|
||||
_ -> [ xLabel ce
|
||||
, ArrowHead (AType [(ArrMod OpenArrow BothSides ,NoArrow)])
|
||||
, HeadPort (CompassPoint West)
|
||||
]
|
||||
|
||||
|
||||
nodeFormatting :: (Int,CombNode) -> Attributes
|
||||
nodeFormatting (_,CombNode Right {}) = [Shape PointShape]
|
||||
nodeFormatting (_,CombNode cn@(Left bt)) = case bt of
|
||||
--CRAFT _ -> [Shape DiamondShape,toLabel (CombNode cn)]
|
||||
CRAFT _ -> [Color [WC (X11Color Green) Nothing],toLabel (CombNode cn)]
|
||||
_ -> [Shape BoxShape,toLabel (CombNode cn)]
|
||||
@@ -0,0 +1,19 @@
|
||||
module Dodge.Combine.Trie where
|
||||
import Dodge.Combine.Combinations
|
||||
import Dodge.Data
|
||||
--import Dodge.Combine.Module
|
||||
--import Dodge.Combine.Data
|
||||
--import Multiset
|
||||
import SimpleTrie
|
||||
|
||||
import Data.Bifunctor
|
||||
--import qualified Data.IntSet as IS
|
||||
--import Data.Map.Merge.Strict
|
||||
import Data.List (sort)
|
||||
|
||||
combinationsTrie :: Trie (IcAmount,ItemBaseType) Item
|
||||
{-# INLINE combinationsTrie #-}
|
||||
combinationsTrie = foldr
|
||||
(uncurry insertInTrie . first sort)
|
||||
emptyTrie
|
||||
itemCombinations
|
||||
Reference in New Issue
Block a user