Пример #1
0
 def __init__(self, startAP, areaGraph, restrictions):
     self.startAP = startAP
     self.areaGraph = areaGraph
     self.restrictions = restrictions
     self.settings = restrictions.settings
     self.smbm = SMBoolManager()
     self.log = log.get('MiniSolver')
Пример #2
0
 def __init__(self, graphSettings, locations, services):
     self.sm = SMBoolManager()
     self.settings = services.settings
     self.graphSettings = graphSettings
     self.startAP = graphSettings.startAP
     self.superFun = self.settings.superFun
     self.container = None
     self.services = services
     self.restrictions = services.restrictions
     self.areaGraph = services.areaGraph
     self.allLocations = locations
     self.locations = self.areaGraph.getAccessibleLocations(
         locations, self.startAP)
     #        print("nLocs Setup: "+str(len(self.locations)))
     self.itemManager = self.settings.getItemManager(
         self.sm, len(self.locations))
     self.forbiddenItems = []
     self.restrictedLocs = []
     self.lastRestricted = []
     self.bossesLocs = sorted(
         ['Draygon', 'Kraid', 'Ridley', 'Phantoon', 'Mother Brain'])
     self.suits = ['Varia', 'Gravity']
     # organized by priority
     self.movementItems = [
         'SpaceJump', 'HiJump', 'SpeedBooster', 'Bomb', 'Grapple',
         'SpringBall'
     ]
     # organized by priority
     self.combatItems = ['ScrewAttack', 'Plasma', 'Wave', 'Spazer']
     # OMG
     self.bossChecks = {
         'Kraid': self.sm.enoughStuffsKraid,
         'Phantoon': self.sm.enoughStuffsPhantoon,
         'Draygon': self.sm.enoughStuffsDraygon,
         'Ridley': self.sm.enoughStuffsRidley,
         'Mother Brain': self.sm.enoughStuffsMotherbrain
     }
     self.okay = lambda: SMBool(True, 0)
     exclude = self.settings.getExcludeItems(self.locations)
     # we have to use item manager only once, otherwise pool will change
     self.itemManager.createItemPool(exclude)
     self.basePool = self.itemManager.getItemPool()[:]
     self.log = log.get('RandoSetup')
     if len(locations) != len(self.locations):
         self.log.debug("inaccessible locations :" + getLocListStr(
             [loc for loc in locations if loc not in self.locations]))
 def __copy__(self):
     def copyLoc(loc):
         ret = {}
         for key, value in loc.items():
             # create new smbool
             if key == 'difficulty':
                 ret[key] = SMBool(value.bool, value.difficulty, value.knows, value.items)
             else:
                 ret[key] = value
         return ret
     locs = [copyLoc(loc) for loc in self.unusedLocations]
     # we don't copy restriction state on purpose: it depends on
     # outside context we don't want to bring to the copy
     ret = ItemLocContainer(SMBoolManager(),
                            self.itemPoolBackup[:] if self.itemPoolBackup != None else self.itemPool[:],
                            locs)
     ret.currentItems = self.currentItems[:]
     ret.unrestrictedItems = copy.copy(self.unrestrictedItems)
     ret.itemLocations = [ {
         'Item': il['Item'],
         'Location': copyLoc(il['Location'])
     } for il in self.itemLocations ]
     ret.sm.addItems([item.Type for item in ret.currentItems])
     return ret
Пример #4
0
#!/usr/bin/env python3

import sys

sys.path.append('RandomMetroidSolver')

from graph_locations import locations
from smboolmanager import SMBoolManager
import json
import copy


def convert(loc, sm):
    d = {}
    for key in loc:
        value = loc[key]
        if type(value) is dict:
            value = convert(value, sm)
        elif callable(value):
            value = None  # TODO
        d[key] = value
    return d


out = open('locations.json', 'w')
sm = SMBoolManager()
json.dump([convert(loc, sm) for loc in locations], out)
Пример #5
0
import sys

from utils import randGaussBounds
from itemrandomizerweb.Items import ItemManager
from smboolmanager import SMBoolManager
import random
from smboolmanager import SMBoolManager

fun = [
    'HiJump', 'SpeedBooster', 'Plasma', 'ScrewAttack', 'Wave', 'Spazer',
    'SpringBall'
]

if __name__ == "__main__":
    sm = SMBoolManager()
    with open("itemStats.csv", "w") as csvOut:
        csvOut.write(
            "energyQty;minorQty;nFun;strictMinors;MissProb;SuperProb;PowerProb;nItems;nTanks;nTanksTotal;nMinors;nMissiles;nSupers;nPowers;MissAccuracy;SuperAccuracy;PowerAccuracy\n"
        )
        for i in range(10000):
            if (i + 1) % 100 == 0:
                print(i + 1)
            isVanilla = random.random() < 0.5
            strictMinors = bool(random.getrandbits(1))
            minQty = 100
            energyQty = 'vanilla'
            forbidden = []
            if not isVanilla:
                minQty = random.randint(1, 99)
                if random.random() < 0.5:
 def transferCollected(self, dest):
     dest.currentItems = self.currentItems[:]
     dest.sm = SMBoolManager()
     dest.sm.addItems([item.Type for item in dest.currentItems])
     dest.itemLocations = copy.copy(self.itemLocations)
     dest.unrestrictedItems = copy.copy(self.unrestrictedItems)