Merge branch 'dev' into ai

This commit is contained in:
Maruno17
2023-02-05 19:10:25 +00:00
208 changed files with 3123 additions and 3331 deletions

View File

@@ -40,20 +40,18 @@ end
#===============================================================================
#
#===============================================================================
=begin
[3/10]
0-266 - 0-500
[106]
267-372 - 380-500
[95]
373-467 - 400-555 (nonlegendary)
468-563 - 400-555 (nonlegendary)
564-659 - 400-555 (nonlegendary)
660-755 - 400-555 (nonlegendary)
756-799 - 580-600 [legendary] (compat1==15 or compat2==15, genderbyte=255)
800-849 - 500-
850-881 - 580-
=end
# [3/10]
# 0-266 - 0-500
# [106]
# 267-372 - 380-500
# [95]
# 373-467 - 400-555 (nonlegendary)
# 468-563 - 400-555 (nonlegendary)
# 564-659 - 400-555 (nonlegendary)
# 660-755 - 400-555 (nonlegendary)
# 756-799 - 580-600 [legendary] (compat1==15 or compat2==15, genderbyte=255)
# 800-849 - 500-
# 850-881 - 580-
def withRestr(_rule, minbs, maxbs, legendary)
ret = PokemonChallengeRules.new.addPokemonRule(BaseStatRestriction.new(minbs, maxbs))
@@ -99,11 +97,11 @@ def pbArrangeByTier(pokemonlist, rule)
# Now for each tier, sort the Pokemon in that tier by their BST (lowest first).
ret = []
tiers.length.times do |i|
tierPokemon[i].sort! { |a, b|
tierPokemon[i].sort! do |a, b|
bstA = baseStatTotal(a.species)
bstB = baseStatTotal(b.species)
(bstA == bstB) ? a.species <=> b.species : bstA <=> bstB
}
end
ret.concat(tierPokemon[i])
end
return ret
@@ -323,7 +321,7 @@ def pbWriteCup(id, rules)
return if !pbConfirmMessage(_INTL("This may take a long time. Are you sure?"))
mw = pbCreateMessageWindow
t = Time.now
pbGenerateChallenge(rules, id) { |message|
pbGenerateChallenge(rules, id) do |message|
if Time.now - t >= 5
Graphics.update
t = Time.now
@@ -333,7 +331,7 @@ def pbWriteCup(id, rules)
Graphics.update
t = Time.now
end
}
end
pbDisposeMessageWindow(mw)
pbMessage(_INTL("Team generation complete."))
end

View File

@@ -115,9 +115,7 @@ def addMove(moves, move, base)
[:REFLECT, :LIGHTSCREEN, :SAFEGUARD, :SUBSTITUTE, :FAKEOUT].include?(data.id)
count = base + 2
end
if data.base_damage >= 80 && data.type == :NORMAL
count = base + 3
end
count = base + 3 if data.base_damage >= 80 && data.type == :NORMAL
if [:PROTECT, :DETECT, :TOXIC, :AERIALACE, :WILLOWISP, :SPORE, :THUNDERWAVE,
:HYPNOSIS, :CONFUSERAY, :ENDURE, :SWORDSDANCE].include?(data.id)
count = base + 3
@@ -345,9 +343,7 @@ def pbRandomPokemonFromRule(rules, trainer)
types = GameData::Species.get(species).types
item = :LEFTOVERS if !types.include?(:POISON)
end
if item == :HEATROCK && moves.none? { |m| m == :SUNNYDAY }
item = :LEFTOVERS
end
item = :LEFTOVERS if item == :HEATROCK && moves.none? { |m| m == :SUNNYDAY }
if item == :DAMPROCK && moves.none? { |m| m == :RAINDANCE }
item = :LEFTOVERS
end

View File

@@ -40,11 +40,11 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
bttrainers.push(tr)
end
# Sort all the randomly chosen trainers by their base money (smallest first)
bttrainers.sort! { |a, b|
bttrainers.sort! do |a, b|
money1 = GameData::TrainerType.get(a[0]).base_money
money2 = GameData::TrainerType.get(b[0]).base_money
next (money1 == money2) ? a[0].to_s <=> b[0].to_s : money1 <=> money2
}
end
end
yield(nil) if block_given?
# Set all Pokémon in pokemonlist to the appropriate level, and determine their
@@ -119,14 +119,14 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
# anyway (more likely to add it if the trainer has access to more
# Pokémon of the same type(s) as this Pokémon)
t = pkmntypes[index]
t.each { |typ|
t.each do |typ|
weight = [32, 12, 5, 2, 1, 0, 0, 0][[absDiff, 7].min]
weight *= types[typ]
if rand(40) < weight
numbers.push(index)
numbersPokemon.push(pokemonlist[index])
end
}
end
end
end
numbers |= [] # Remove duplicates

View File

@@ -237,6 +237,8 @@ class PlayerRating
setVolatility2(volatility)
end
#-----------------------------------------------------------------------------
private
attr_writer :volatility
@@ -286,7 +288,7 @@ class PlayerRating
squVariance = variance + variance
squDevplusVar = squDeviation + variance
x0 = a
100.times { # Up to 100 iterations to avoid potentially infinite loops
100.times do # Up to 100 iterations to avoid potentially infinite loops
e = Math.exp(x0)
d = squDevplusVar + e
squD = d * d
@@ -297,7 +299,7 @@ class PlayerRating
x1 = x0
x0 -= h1 / h2
break if (x1 - x0).abs < 0.000001
}
end
return Math.exp(x0 / 2.0)
end
end