本文整理汇总了Python中vsrandom.uniform函数的典型用法代码示例。如果您正苦于以下问题:Python uniform函数的具体用法?Python uniform怎么用?Python uniform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uniform函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: reposition
def reposition(un,playa,min_distance,vel):
ex=(vsrandom.uniform(-1,1),vsrandom.uniform(-1,1),vsrandom.uniform(-1,1))
if vel[0]==0 and vel[1]==0 and vel[2]==0:
vel=(1,0,0)
dir=Vector.Scale(Vector.ScaledCross(ex,vel),min_distance)
debug.debug("offsetting you a few meters to the %s" % (str(dir)))
un.SetPosition(Vector.Add(playa.Position(),dir))
开发者ID:ermo,项目名称:privateer_wcu,代码行数:7,代码来源:unit.py
示例2: launchUnits
def launchUnits(sys):
print "Launching units for "+sys
import faction_ships
import launch_recycle
import universe
sig_units=universe.significantUnits()
ownerfac= VS.GetGalaxyFaction(sys)
jumpcount=0
planetcount=0
# asteroidcount=0
basecount=0
farlen=0
for sig in sig_units:
if sig.isJumppoint():
jumpcount+=1
elif sig.isPlanet():
planetcount+=1
# elif sig.isAsteroid():
# asteroidcount+=1
else:
basecount+=1
tmplen=Vector.Mag(sig.Position())
if tmplen>farlen:
farlen=tmplen
for factionnum in range(0,faction_ships.getMaxFactions()-1):
faction=faction_ships.intToFaction(factionnum)
fglist=filterLaunchedFGs(FGsInSystem(faction,sys))
isHostile=VS.GetRelation(ownerfac,faction)<0
isForeign=faction.find(ownerfac)==-1
if isForeign:
if basecount+jumpcount:
frac=len(fglist)/float(basecount+jumpcount)
else:
frac=0.0
else:
if basecount+planetcount+jumpcount:
frac=len(fglist)/float(planetcount+basecount+jumpcount)
else:
frac=0.0
if isHostile:
for flightgroup in fglist:
X=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen
Y=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen
Z=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen
typenumbers=ShipsInFG(flightgroup,faction)
#print "Really Far Apart around "+" "+str(X)+" "+str(Y)+" "+str(Z)+" and 10000"
debug.debug(" launching "+str(typenumbers) +" for "+faction+" at "+str((X,Y,Z)))
launch_recycle.launch_types_around(flightgroup,faction,typenumbers,'default',1,(X,Y,Z),0,'','',1,10000)
else:
for flightgroup in fglist:
#jp = sig.isJumppoint()
#if sig.isPlanet() or not isForeign:
sig = sig_units[vsrandom.randrange(0,len(sig_units))]
typenumbers=ShipsInFG(flightgroup,faction)
debug.debug(" XXlaunching "+str(typenumbers) +" for "+faction)
print "LALALAUNCHING "+str(typenumbers)+" t "+sig.getName()+":"+sig.getFullname()
launch_recycle.launch_types_around(flightgroup,faction,typenumbers,'default',sig.rSize()*vsrandom.randrange(10,100),sig,0,'','',1,10000)
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:60,代码来源:fg_util.py
示例3: teleportNPC
def teleportNPC (self,un):
pos=un.Position()
rsiz = un.rSize()
size=4*rsiz
sig = unit.getSignificant (vsrandom.randrange(0,50),0,0)
if (not sig):
return
nam = sig.getName()
if (nam.find ("lackhole")!=-1):
return
targetpos = sig.Position()
arad = sig.rSize()*2+size
targetpos = Vector.Add(targetpos,(vsrandom.uniform(arad,arad*1.5),
vsrandom.uniform(arad,arad*1.5),
vsrandom.uniform(arad,arad*1.5)))
targetpos = VS.SafeEntrancePoint (targetpos,rsiz)
if (size<1000):
size=1000
print "kill"
print un.getName()
un.SetCurPosition(targetpos)
VS.playAnimation("warp.ani",pos,size)
VS.playSound("cloak.wav",pos,(1,0,0))
VS.playAnimation("warp.ani",targetpos,size)
VS.playSound("cloak.wav",targetpos,(1,0,0))
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:25,代码来源:quest_teleport.py
示例4: launch_waves_around_area
def launch_waves_around_area(fgname, faction, type, ai, nr_ships, nr_waves, r1, r2, pos, logo="", useani=1, skipdj=0):
pos = (
(pos[0] + vsrandom.uniform(r1, r2) * vsrandom.randrange(-1, 2, 2)),
(pos[1] + vsrandom.uniform(r1, r2) * vsrandom.randrange(-1, 2, 2)),
(pos[2] + vsrandom.uniform(r1, r2) * vsrandom.randrange(-1, 2, 2)),
)
return launch(fgname, faction, type, ai, nr_ships, nr_waves, pos, logo, useani, skipdj)
开发者ID:vegastrike,项目名称:Assets-Production,代码行数:7,代码来源:launch.py
示例5: launch_waves_in_area
def launch_waves_in_area(fgname, faction, type, ai, nr_ships, nr_waves, radius, pos, logo="", useani=1, skipdj=0):
pos = (
pos[0] + vsrandom.uniform((-radius) // 2, radius / 2.0),
pos[1] + vsrandom.uniform((-radius) // 2, radius / 2.0),
pos[2] + vsrandom.uniform((-radius) // 2, radius / 2.0),
)
un = launch(fgname, faction, type, ai, nr_ships, nr_waves, pos, logo, useani, skipdj)
开发者ID:vegastrike,项目名称:Assets-Production,代码行数:7,代码来源:launch.py
示例6: AddFighterTo
def AddFighterTo(fgname,fac,isNew=False):
sys = VS.getSystemFile()
#print 'add fighter'
import generate_dyn_universe
numsystems = generate_dyn_universe.systemcount[fac]
if (VS.GetGalaxyFaction(sys)!=fac):
try:
homeworlds=faction_ships.production_centers
except:
homeworlds=faction_ships.homeworlds
if fac in homeworlds:
if type(homeworlds[fac])==type(""):
sys=homeworlds[fac]
else:
sys=homeworlds[fac][vsrandom.randrange(0,len(homeworlds[fac]))]
numfighters = int(generate_dyn_universe.XProductionRate(fac,faction_ships.fighterProductionRate)*numsystems)
try:
if fac in faction_ships.staticFighterProduction:
numfighters+=faction_ships.staticFighterProduction[fac]
except:
pass
if (numfighters<1):
if (vsrandom.uniform(0,1)<numfighters):
numfighters=1
#print "Generating "+str(numfighters)+ " fighters for "+fac+" at "+sys
if isNew:
fgk=fg_util.AllFGsInSystem(fac,sys)
if len(fgk):
fgname=fgk[vsrandom.randrange(0,len(fgk))]
stat=6
if fac in faction_ships.fightersPerFG:
stat=faction_ships.fightersPerFG[fac]
elif "default" in faction_ships.fightersPerFG:
stat=faction_ships.fightersPerFG["default"]
if fg_util.NumShipsInFG(fgname,fac)+numfighters<=numfighters+stat:
isNew=False
if isNew:
fgname=generate_dyn_universe.GetNewFGName(fac)
if numfighters>=1:
fg_util.AddShipsToFG (fgname,fac,((faction_ships.getRandomFighter(fac),int(numfighters)),),sys)
numcapships = generate_dyn_universe.XProductionRate(fac,faction_ships.capitalProductionRate)*numsystems
if (numcapships<1):
if (vsrandom.uniform(0,1)>numcapships):
return
numcapships=1
sys = fg_util.FGSystem(fgname,fac)
if (1 or VS.GetGalaxyFaction(sys)!=fac):
try:
homeworlds=faction_ships.production_centers
except:
homeworlds=faction_ships.homeworlds
if fac in homeworlds:
if type(homeworlds[fac])==type(""):
sys=homeworlds[fac]
else:
sys=homeworlds[fac][vsrandom.randrange(0,len(homeworlds[fac]))]
cap =faction_ships.getRandomCapitol(fac)
#print "Generating "+str(numcapships)+ " capship "+cap+" for "+fac+" at "+sys
fg_util.AddShipsToFG(fgname,fac,((cap,int(numcapships)),),sys)
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:59,代码来源:dynamic_battle.py
示例7: setDroneNear
def setDroneNear (self,playa):
vec = playa.Position()
vec = Vector.Add (vec,(vsrandom.uniform(-1000,1000),
vsrandom.uniform(-1000,1000),
vsrandom.uniform(-1000,1000)))
if (not self.drone.isNull()):
self.drone.SetCurPosition(vec)
self.drone.SetTarget(playa)
开发者ID:ermo,项目名称:privateer_wcu,代码行数:8,代码来源:quest_disappear.py
示例8: setDroneNear
def setDroneNear (self,playa):
global drone
vec = playa.Position()
vec = Vector.Add (vec,(vsrandom.uniform(-1000,1000),
vsrandom.uniform(-1000,1000),
vsrandom.uniform(-1000,1000)))
drone.SetCurPosition(vec)
drone.SetTarget(playa)
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:8,代码来源:quest_drone.py
示例9: reposition
def reposition(un,playa,min_distance,vel):
import Vector
import vsrandom
ex=(vsrandom.uniform(-1,1),vsrandom.uniform(-1,1),vsrandom.uniform(-1,1))
if vel[0]==0 and vel[1]==0 and vel[2]==0:
vel=(1,0,0)
dir=Vector.Scale(Vector.ScaledCross(ex,vel),min_distance)
print "offsetting you a few meters to the "+str(dir)
un.SetPosition(Vector.Add(playa.Position(),dir))
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:9,代码来源:unit.py
示例10: randDirection
def randDirection():
leng=2
while leng>1 or leng<.00001:
X = vsrandom.uniform(-1,1);
Y = vsrandom.uniform(-1,1);
Z = vsrandom.uniform(-1,1);
leng=X*X+Y*Y+Z*Z
import VS
leng=VS.sqrt(leng)
return (X/leng,Y/leng,Z/leng)
开发者ID:jowave,项目名称:Vegastrike-taose,代码行数:10,代码来源:fg_util.py
示例11: Execute
def Execute(self):
self.count+=1
if (self.count<3):
return
self.count=0
quant = (vsrandom.random()*(self.quantity-1))+1
#debug.debug("un = VS.getUnit (%d)" % (self.last_ship))
un = VS.getUnit (self.last_ship)
if (un.isNull()):
self.last_ship=0
else:
if (un.isSignificant()):
if (un.isPlayerStarship()==-1):
global production
name = un.getName()
faction= un.getFactionName()
if un.isPlanet():
name = un.getFullname();
faction="planets"
prad=production.get((name,faction))
if None==prad:
prad= getImports(name,faction)
production[(name,faction)]=prad
if len(prad):
prod=prad[vsrandom.randrange(0,len(prad))]
cargo=VS.getRandCargo(int(prod[3]+prod[4]),prod[0])
if (cargo.GetCategory()==prod[0]):
removeCargo=False
if (prod[3] or prod[4]):
ownedcargo=un.GetCargo(cargo.GetContent())
quant=ownedcargo.GetQuantity()
#if un.getName()=="mining_base" and (cargo.GetContent()=="Tungsten" or cargo.GetContent()=="Space_Salvage"):
# debug.debug("Mining "+str(quant)+" from "+str(prod[3])+" to "+str(prod[4]))
if (quant<prod[3]-prod[4] or quant==0):
quant=int(prod[3]+vsrandom.uniform(-1,1)*prod[4])
#if un.getName()=="mining_base" and (cargo.GetContent()=="Tungsten" or cargo.GetContent()=="Space_Salvage"):
# debug.debug("Will add quant "+str(quant))
if (quant>0):
cargo.SetQuantity(quant)
price = prod[1]+vsrandom.uniform(-1,1)*prod[2]
cargo.SetPrice(cargo.GetPrice()*price)
debug.debug(" adding "+str(quant)+" of "+cargo.GetContent()+" cargo for "+str(price))
un.addCargo(cargo)
else:
removeCargo=True
elif quant>prod[3]+prod[4]:
removeCargo=True
else:
removeCargo=True
if removeCargo:
ownedcargo=un.GetCargo(cargo.GetContent())
if (ownedcargo.GetQuantity()):
debug.debug("Removing one "+ownedcargo.GetContent())
un.removeCargo(ownedcargo.GetContent(), ownedcargo.GetQuantity()//3 + 1, 0)
self.last_ship+=1
开发者ID:ermo,项目名称:privateer_wcu,代码行数:55,代码来源:trading.py
示例12: _prob_round
def _prob_round(curnum):
import vsrandom
ret = int(curnum)
diff = curnum-int(curnum)
if (diff>0):
if (vsrandom.uniform (0,1)<diff):
ret+=1
else:
if (vsrandom.uniform (0,1)<-diff):
ret-=1
return ret
开发者ID:jowave,项目名称:Vegastrike-taose,代码行数:11,代码来源:fg_util.py
示例13: HowMuchDamage
def HowMuchDamage (shiptypes,defenseroll):
dam=0
for i in shiptypes:
stats=faction_ships.GetStats(i[0])
#debug.debug(str(stats[0])+ ' needs above '+str(defenseroll))
if (vsrandom.uniform(0,stats[0])>defenseroll):
dam+=stats[2]*i[1] #guns
if (len(stats)>3):
if (vsrandom.uniform(0,.05)>defenseroll):
dam+=stats[3]*i[1] #missiles
return dam
开发者ID:jowave,项目名称:Vegastrike-taose,代码行数:11,代码来源:dynamic_battle.py
示例14: randomLocation
def randomLocation(self):
for i in range (50):
vec=(vsrandom.uniform(-self.arenasize,self.arenasize),
0,
vsrandom.uniform(-self.arenasize,self.arenasize))
for i in self.flags:
if (self.toonear (vec,i)):
continue
for i in self.obstacles:
if (self.toonear (vec,i)):
continue
return vec
return vec
开发者ID:ermo,项目名称:privateer_wcu,代码行数:13,代码来源:spectre.py
示例15: SimulatedDukeItOut
def SimulatedDukeItOut (fgname,faction,enfgname,enfaction):
ally=fg_util.LandedShipsInFG(fgname,faction)
enemy=fg_util.LandedShipsInFG(enfgname,enfaction)
if (len(enemy) and len(ally)):
allyvictim = vsrandom.randrange(0,len(ally))
allystats = faction_ships.GetStats(ally[allyvictim][0])
envictim = vsrandom.randrange(0,len(enemy))
enstats = faction_ships.GetStats(enemy[envictim][0])
endam = HowMuchDamage(enemy,vsrandom.uniform(0,allystats[1]))
if (enfgname==fgname and enfaction==faction):
debug.error("FAULT FAULT FAULT")
ApplyDamage(enfgname,enfaction,enemy,envictim,enstats,HowMuchDamage(ally,vsrandom.uniform(0,enstats[1])),fgname,faction)
ApplyDamage(fgname,faction,ally,allyvictim,allystats,endam,enfgname,enfaction)
开发者ID:jowave,项目名称:Vegastrike-taose,代码行数:13,代码来源:dynamic_battle.py
示例16: floatToRand
def floatToRand(maximum):
if maximum==0:
return 0
tmp=vsrandom.randrange(0,int(maximum)+1)
if (vsrandom.uniform(0,1)<maximum-int(maximum)):
return tmp+1
return tmp
开发者ID:jowave,项目名称:Vegastrike-taose,代码行数:7,代码来源:generate_dyn_universe.py
示例17: init
def init(self,un):
self.shipiter=0;
self.speed = vsrandom.uniform (maxspeed/3,maxspeed);
print 'self.speed'
print self.speed
self.stopping=0
self.begin=1
self.restoreCruisingSpeed(self.speed)
开发者ID:jowave,项目名称:Vegastrike-taose,代码行数:8,代码来源:traffic.py
示例18: init
def init(self, un):
self.shipiter = 0
self.speed = vsrandom.uniform(maxspeed / 3, maxspeed)
print("self.speed")
print(self.speed)
self.stopping = 0
self.begin = 1
self.restoreCruisingSpeed(self.speed)
开发者ID:vegastrike,项目名称:Assets-Production,代码行数:8,代码来源:traffic.py
示例19: launchBaseOrbit
def launchBaseOrbit(type,faction,loc,orbitradius,orbitspeed,unit):
#orbitradius*=2
import Vector
import dynamic_universe
R = Vector.Vector(vsrandom.uniform(1.25*orbitradius,orbitradius),
vsrandom.uniform(1.25*orbitradius,orbitradius),
vsrandom.uniform(1.25*orbitradius,orbitradius))
RMag = Vector.Mag(R)
T = Vector.Vector(vsrandom.uniform(.5*orbitradius,orbitradius),
vsrandom.uniform(.75*orbitradius,.85*orbitradius),
vsrandom.uniform(.5*orbitradius,orbitradius))
S = Vector.Cross (T,R)
S = Vector.Scale(S,
vsrandom.uniform (1.5*orbitradius,orbitradius)
/Vector.Mag(S))
SMag = Vector.Mag(S)
bas=VS.launch("Base",type,faction,"unit","default",1,1,Vector.Add(loc,R),'')
nam=GetRandomBaseName (1,faction);
R = Vector.Scale (R,(RMag+2.0*bas.rSize())/RMag)
S = Vector.Scale (S,(SMag+2.0*bas.rSize())/SMag)
bas.orbit (unit,orbitspeed,R,S,(0.0,0.0,0.0))
#bas.SetPosition(Vector.Add(loc,R))
dynamic_universe.TrackLaunchedShip (BaseFGInSystemName(VS.getSystemFile()),
faction,
type,
bas)
开发者ID:jowave,项目名称:Vegastrike-taose,代码行数:27,代码来源:fg_util.py
示例20: launchSingleBase
def launchSingleBase (type,faction,sig):
radpct = VS.getPlanetRadiusPercent()
sigrsize=sig.rSize()
radpct = sigrsize*(1+radpct)
if radpct<200000000.+sigrsize:
radpct=200000000.+sigrsize
speed = vsrandom.uniform (0,50)
debug.debug('Lauching %s base %s by sig %s (%s)', faction, type, sig.getName(), sig.getFullname())
launchBaseOrbit (type,faction,sig.Position(),radpct,speed,sig)
开发者ID:jowave,项目名称:Vegastrike-taose,代码行数:9,代码来源:fg_util.py
注:本文中的vsrandom.uniform函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论