Auto generate dot file with base item combinations

This commit is contained in:
2022-07-05 12:05:41 +01:00
parent 22ac8feb37
commit cd3463d3d8
8 changed files with 48 additions and 31 deletions
+1
View File
@@ -24,6 +24,7 @@ dependencies:
- containers - containers
- unordered-containers - unordered-containers
- bitwise-enum - bitwise-enum
- graphviz
#- heap #- heap
- sdl2 - sdl2
- sdl2-mixer - sdl2-mixer
+2 -8
View File
@@ -7,7 +7,7 @@ module Dodge.Combine
, toggleCombineInv , toggleCombineInv
, enterCombineInv , enterCombineInv
) where ) where
import Dodge.Combine.Combinations import Dodge.Combine.Trie
import Dodge.Base.You import Dodge.Base.You
import Dodge.Data import Dodge.Data
import Dodge.Item.Amount import Dodge.Item.Amount
@@ -27,13 +27,7 @@ import qualified Data.IntMap.Strict as IM
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
--import Data.Map.Merge.Strict --import Data.Map.Merge.Strict
import Data.Maybe import Data.Maybe
import Data.List (scanl',sortOn,sort) import Data.List (scanl',sortOn)
combinationsTrie :: Trie (IcAmount,ItemBaseType) Item
combinationsTrie = foldr
(uncurry insertInTrie . first sort)
emptyTrie
itemCombinations
invertInventory :: IM.IntMap Item -> [(ItemBaseType,IcAmount,Int)] invertInventory :: IM.IntMap Item -> [(ItemBaseType,IcAmount,Int)]
invertInventory = IM.foldrWithKey invertInventory = IM.foldrWithKey
+4 -4
View File
@@ -32,9 +32,9 @@ itemCombinations =
-- , po [BANGCONE,PUMP,HARDWARE] $ grenadeLauncher 1 -- , po [BANGCONE,PUMP,HARDWARE] $ grenadeLauncher 1
-- , po [GRENADELAUNCHER 1,MOTOR,DRUM] $ grenadeLauncher 2 -- , po [GRENADELAUNCHER 1,MOTOR,DRUM] $ grenadeLauncher 2
, p [p 2 $ cr PIPE,o $ cr HARDWARE] bangCane , p [p 2 $ cr PIPE,o $ cr HARDWARE] (bangCaneX 1)
, p [p 2 $ cr PIPE,o BANGCANE] (bangCaneX 2) , p [p 2 $ cr PIPE,o $ BANGCANEX 1] (bangCaneX 2)
, po [BANGCANE,cr TIN] rifle , po [BANGCANEX 1,cr TIN] rifle
, po [RIFLE,cr PLANK] repeater , po [RIFLE,cr PLANK] repeater
, po [REPEATER,cr SPRING,cr HARDWARE] autoRifle , po [REPEATER,cr SPRING,cr HARDWARE] autoRifle
, po [REPEATER,cr SPRING,cr CAN] burstRifle , po [REPEATER,cr SPRING,cr CAN] burstRifle
@@ -91,7 +91,7 @@ itemCombinations =
++ map (\i -> po [cr PIPE,BANGSTICK i] $ bangStick (i+1)) [1..8] ++ 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 -> 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 -> p [o (BANGCANEX i),p 2 $ cr PIPE] $ bangCaneX (i+1)) [1..5]
++ map (\i -> po [MINIGUNX i,BANGCANE] $ miniGunX (i+1)) [3..15] ++ map (\i -> po [MINIGUNX i,BANGCANEX 1] $ miniGunX (i+1)) [3..15]
++ [ po (_iyBase (_itType it):mtype) $ it & itType . iyModules . ix modtype .~ m ++ [ po (_iyBase (_itType it):mtype) $ it & itType . iyModules . ix modtype .~ m
| (modtype,is,ms) <- moduleCombinations | (modtype,is,ms) <- moduleCombinations
+1 -1
View File
@@ -48,7 +48,7 @@ pictureWeaponOnAimItem p' cr posInInv
= handD holsteredOneHandWep = handD holsteredOneHandWep
| isSelected | isSelected
= handD holsteredWep = handD holsteredWep
| otherwise = emptyBlank | otherwise = mempty
where where
shoulderD = translateSPz 18 shoulderD = translateSPz 18
handD = translateSPz 15 handD = translateSPz 15
+15 -4
View File
@@ -76,8 +76,8 @@ bangCane = defaultBulletWeapon
& itConsumption . laMax .~ 1 & itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadPartialInsert 10 1] & itConsumption . laCycle .~ [loadPartialInsert 10 1]
bangCaneX :: Int -> Item bangCaneX :: Int -> Item
bangCaneX i = bangCane bangCaneX i = defaultBulletWeapon
{ _itUse = ruseAmmoParamsRate 6 upHammer & itUse .~ ruseAmmoParamsRate 6 upHammer
[ ammoHammerCheck [ ammoHammerCheck
, useTimeCheck , useTimeCheck
, withSoundItemChoiceStart caneStickSoundChoice , withSoundItemChoiceStart caneStickSoundChoice
@@ -88,7 +88,7 @@ bangCaneX i = bangCane
, withMuzFlareI , withMuzFlareI
, withRecoil , withRecoil
] ]
, _itDimension = ItemDimension & itDimension .~ ItemDimension
{ _dimRad = 8 { _dimRad = 8
, _dimCenter = V3 5 0 0 , _dimCenter = V3 5 0 0
, _dimPortage = HeldItem , _dimPortage = HeldItem
@@ -101,11 +101,22 @@ bangCaneX i = bangCane
. (\k -> fromIntegral k * 5 - ((fromIntegral i - 1) * 2.5))) [0..i-1] . (\k -> fromIntegral k * 5 - ((fromIntegral i - 1) * 2.5))) [0..i-1]
) <> caneClipX i it ) <> caneClipX i it
} }
} & itUse . useAim . aimWeight .~ 6 & itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1 & itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat & itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5} & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . laMax .~ i & itConsumption . laMax .~ i
& itParams .~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels = SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itParams . gunBarrels .~ MultiBarrel & itParams . gunBarrels .~ MultiBarrel
{_brlSpread = AlignedBarrels {_brlSpread = AlignedBarrels
,_brlNum = i ,_brlNum = i
+1 -1
View File
@@ -239,7 +239,7 @@ throwRemoteBomb cr w = setLocation
| otherwise = v' | otherwise = v'
j = crSel cr j = crSel cr
-- resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE" -- resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
removePict = set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> emptyBlank removePict = set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> mempty
resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse) resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse)
$ \_ -> explodeRemoteBomb itid i $ \_ -> explodeRemoteBomb itid i
p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0) p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
+3
View File
@@ -10,6 +10,7 @@ import Dodge.Initialisation
--import Dodge.LevelGen.Data --import Dodge.LevelGen.Data
import Dodge.Tree import Dodge.Tree
import Geometry.ConvexPoly import Geometry.ConvexPoly
import Dodge.Combine.Graph
--import Dodge.LevelGen.LevelStructure --import Dodge.LevelGen.LevelStructure
import Data.Foldable import Data.Foldable
@@ -18,6 +19,7 @@ import System.Random
import Control.Lens import Control.Lens
import Control.Monad.State import Control.Monad.State
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
import qualified Data.Text.IO as TIO
generateWorldFromSeed :: Int -> IO World generateWorldFromSeed :: Int -> IO World
generateWorldFromSeed i = do generateWorldFromSeed i = do
@@ -25,6 +27,7 @@ generateWorldFromSeed i = do
writeFile "log/attemptedSeeds" "" writeFile "log/attemptedSeeds" ""
writeFile "log/treeCluster" "" writeFile "log/treeCluster" ""
writeFile "log/aGeneratedRoomLayout" "" writeFile "log/aGeneratedRoomLayout" ""
TIO.writeFile "log/itemCombinations.gv" combinationsDotGraph
(roomList,bounds) <- layoutLevelFromSeed 0 i (roomList,bounds) <- layoutLevelFromSeed 0 i
return $ saveLevelStartSlot return $ saveLevelStartSlot
$ postGenerationProcessing $ postGenerationProcessing
+18 -10
View File
@@ -1,15 +1,15 @@
{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
module ShapePicture module ShapePicture
( emptyBlank ( --emptyBlank
, translateSP translateSP
, translateSPf , translateSPf
, translateSPz , translateSPz
, rotateSP , rotateSP
, SPic , SPic
, noPic , noPic
, noShape , noShape
, _spShape -- , _spShape
, _spPicture -- , _spPicture
, mirrorSPyz , mirrorSPyz
, mirrorSPxz , mirrorSPxz
) where ) where
@@ -25,37 +25,45 @@ type SPic = (Shape, Picture)
-- should all this be inlined/inlinable? -- should all this be inlined/inlinable?
noPic :: Shape -> SPic noPic :: Shape -> SPic
{-# INLINE noPic #-}
noPic = (,mempty) noPic = (,mempty)
noShape :: Picture -> SPic noShape :: Picture -> SPic
{-# INLINE noShape #-}
noShape = (mempty,) noShape = (mempty,)
_spShape :: SPic -> Shape --_spShape :: SPic -> Shape
_spShape = fst --_spShape = fst
_spPicture :: SPic -> Picture --_spPicture :: SPic -> Picture
_spPicture = snd --_spPicture = snd
emptyBlank :: SPic --emptyBlank :: SPic
emptyBlank = mempty --emptyBlank = mempty
translateSPf :: Float -> Float -> SPic -> SPic translateSPf :: Float -> Float -> SPic -> SPic
{-# INLINE translateSPf #-}
translateSPf x y = bimap (translateSH (V3 x y 0)) (translate x y) translateSPf x y = bimap (translateSH (V3 x y 0)) (translate x y)
translateSPz :: Float -> SPic -> SPic translateSPz :: Float -> SPic -> SPic
{-# INLINE translateSPz #-}
translateSPz z = bimap (translateSH (V3 0 0 z)) (translate3 (V3 0 0 z)) translateSPz z = bimap (translateSH (V3 0 0 z)) (translate3 (V3 0 0 z))
translateSP :: Point3 -> SPic -> SPic translateSP :: Point3 -> SPic -> SPic
{-# INLINE translateSP #-}
translateSP v = bimap (translateSH v) (translate3 v) translateSP v = bimap (translateSH v) (translate3 v)
rotateSP :: Float -> SPic -> SPic rotateSP :: Float -> SPic -> SPic
{-# INLINE rotateSP #-}
rotateSP a = bimap (rotateSH a) (rotate a) rotateSP a = bimap (rotateSH a) (rotate a)
mirrorSPxz :: SPic -> SPic mirrorSPxz :: SPic -> SPic
{-# INLINE mirrorSPxz #-}
mirrorSPxz = bimap (S.map (over shVs reverse) . overPosSH flipy) mirrorxz mirrorSPxz = bimap (S.map (over shVs reverse) . overPosSH flipy) mirrorxz
where where
flipy (V3 x y z) = V3 x (negate y) z flipy (V3 x y z) = V3 x (negate y) z
mirrorSPyz :: SPic -> SPic mirrorSPyz :: SPic -> SPic
{-# INLINE mirrorSPyz #-}
mirrorSPyz = bimap (S.map (over shVs reverse) . overPosSH flipx) mirroryz mirrorSPyz = bimap (S.map (over shVs reverse) . overPosSH flipx) mirroryz
where where
flipx (V3 x y z) = V3 (negate x) y z flipx (V3 x y z) = V3 (negate x) y z