Lots of rubocop

This commit is contained in:
Maruno17
2023-01-28 15:21:12 +00:00
parent 2d056052ce
commit 13aab8d911
159 changed files with 1679 additions and 1931 deletions

View File

@@ -4,10 +4,10 @@
class BattleChallenge
attr_reader :currentChallenge
BattleTowerID = 0
BattlePalaceID = 1
BattleArenaID = 2
BattleFactoryID = 3
BATTLE_TOWER_ID = 0
BATTLE_PALACE_ID = 1
BATTLE_ARENA_ID = 2
BATTLE_FACTORY_ID = 3
def initialize
@bc = BattleChallengeData.new
@@ -20,17 +20,17 @@ class BattleChallenge
@numRounds = numrounds
@rules = rules
register(id, id[/double/], 3,
id[/^factory/] ? BattleFactoryID : BattleTowerID,
id[/^factory/] ? BATTLE_FACTORY_ID : BATTLE_TOWER_ID,
id[/open$/] ? 1 : 0)
pbWriteCup(id, rules)
end
def register(id, doublebattle, numPokemon, battletype, mode = 1)
ensureType(id)
if battletype == BattleFactoryID
if battletype == BATTLE_FACTORY_ID
@bc.setExtraData(BattleFactoryData.new(@bc))
numPokemon = 3
battletype = BattleTowerID
battletype = BATTLE_TOWER_ID
end
@rules = modeToRules(doublebattle, numPokemon, battletype, mode) if !@rules
end
@@ -47,9 +47,9 @@ class BattleChallenge
rules = PokemonChallengeRules.new
# Set the battle type
case battletype
when BattlePalaceID
when BATTLE_PALACE_ID
rules.setBattleType(BattlePalace.new)
when BattleArenaID
when BATTLE_ARENA_ID
rules.setBattleType(BattleArena.new)
doublebattle = false
else # Factory works the same as Tower
@@ -82,8 +82,7 @@ class BattleChallenge
@bc.pbStart(t, @numRounds)
end
def pbStart(challenge)
end
def pbStart(challenge); end
def pbEnd
if @currentChallenge != -1
@@ -98,8 +97,8 @@ class BattleChallenge
opponent = pbGenerateBattleTrainer(self.nextTrainer, self.rules)
bttrainers = pbGetBTTrainers(@id)
trainerdata = bttrainers[self.nextTrainer]
opponent.lose_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesLose, trainerdata[4])
opponent.win_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesWin, trainerdata[3])
opponent.lose_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_LOSE, trainerdata[4])
opponent.win_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_WIN, trainerdata[3])
ret = pbOrganizedBattleEx(opponent, self.rules)
return ret
end
@@ -166,6 +165,8 @@ class BattleChallenge
return ensureType(challenge).maxSwaps
end
#-----------------------------------------------------------------------------
private
def ensureType(id)
@@ -284,6 +285,8 @@ class BattleChallengeData
return @trainers[@battleNumber - 1]
end
#-----------------------------------------------------------------------------
private
def reset
@@ -373,23 +376,23 @@ class BattleFactoryData
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[@trainerid]
@opponent = NPCTrainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, trainerdata[1]),
trainerdata[0]
)
@opponent.lose_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesLose, trainerdata[4])
@opponent.win_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesWin, trainerdata[3])
@opponent.lose_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_LOSE, trainerdata[4])
@opponent.win_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_WIN, trainerdata[3])
opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, @rentals)
@opponent.party = opponentPkmn.sample(3)
end
def pbChooseRentals
pbFadeOutIn {
pbFadeOutIn do
scene = BattleSwapScene.new
screen = BattleSwapScreen.new(scene)
@rentals = screen.pbStartRent(@rentals)
@bcdata.pbAddSwap
@bcdata.setParty(@rentals)
}
end
end
def pbPrepareSwaps
@@ -398,11 +401,11 @@ class BattleFactoryData
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[trainerid]
@opponent = NPCTrainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, trainerdata[1]),
trainerdata[0]
)
@opponent.lose_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesLose, trainerdata[4])
@opponent.win_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesWin, trainerdata[3])
@opponent.lose_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_LOSE, trainerdata[4])
@opponent.win_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_WIN, trainerdata[3])
opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps,
[].concat(@rentals).concat(@oldopponent))
@opponent.party = opponentPkmn.sample(3)
@@ -410,19 +413,17 @@ class BattleFactoryData
def pbChooseSwaps
swapMade = true
pbFadeOutIn {
pbFadeOutIn do
scene = BattleSwapScene.new
screen = BattleSwapScreen.new(scene)
swapMade = screen.pbStartSwap(@rentals, @oldopponent)
@bcdata.pbAddSwap if swapMade
@bcdata.setParty(@rentals)
}
end
return swapMade
end
def pbBattle(challenge)
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[@trainerid]
return pbOrganizedBattleEx(@opponent, challenge.rules)
end
end

View File

@@ -37,7 +37,7 @@ end
#===============================================================================
def pbEntryScreen(*arg)
retval = false
pbFadeOutIn {
pbFadeOutIn do
scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene, $player.party)
ret = screen.pbPokemonMultipleEntryScreenEx(pbBattleChallenge.rules.ruleset)
@@ -45,7 +45,7 @@ def pbEntryScreen(*arg)
pbBattleChallenge.setParty(ret) if ret
# Continue (return true) if Pokémon were chosen
retval = (ret && ret.length > 0)
}
end
return retval
end
@@ -92,7 +92,7 @@ def pbBattleChallengeBeginSpeech
return "..." if !pbBattleChallenge.pbInProgress?
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
tr = bttrainers[pbBattleChallenge.nextTrainer]
return (tr) ? pbGetMessageFromHash(MessageTypes::FrontierIntroSpeeches, tr[2]) : "..."
return (tr) ? pbGetMessageFromHash(MessageTypes::FRONTIER_INTRO_SPEECHES, tr[2]) : "..."
end
#===============================================================================
@@ -184,16 +184,14 @@ class PBPokemon
return "#{species},#{item},#{nature},#{move1},#{move2},#{move3},#{move4},#{ev}"
end
=begin
def _dump(depth)
return [@species, @item, @nature, @move1, @move2, @move3, @move4, @ev].pack("vvCvvvvC")
end
# def _dump(depth)
# return [@species, @item, @nature, @move1, @move2, @move3, @move4, @ev].pack("vvCvvvvC")
# end
def self._load(str)
data = str.unpack("vvCvvvvC")
return self.new(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7])
end
=end
# def self._load(str)
# data = str.unpack("vvCvvvvC")
# return self.new(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7])
# end
def convertMove(move)
move = :FRUSTRATION if move == :RETURN && GameData::Move.exists?(:FRUSTRATION)

View File

@@ -43,7 +43,7 @@ def pbGenerateBattleTrainer(idxTrainer, rules)
# Create the trainer
trainerdata = bttrainers[idxTrainer]
opponent = NPCTrainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, trainerdata[1]),
trainerdata[0]
)
# Determine how many IVs the trainer's Pokémon will have

View File

@@ -62,11 +62,9 @@ def pbOrganizedBattleEx(opponent, challengedata)
BattleCreationHelperMethods.prepare_battle(battle)
# Perform the battle itself
decision = 0
pbBattleAnimation(pbGetTrainerBattleBGM(opponent)) {
pbSceneStandby {
decision = battle.pbStartBattle
}
}
pbBattleAnimation(pbGetTrainerBattleBGM(opponent)) do
pbSceneStandby { decision = battle.pbStartBattle }
end
Input.update
# Restore both parties to their original levels
challengedata.unadjustLevels($player.party, opponent.party, oldlevels)
@@ -116,19 +114,17 @@ def pbPlayBattle(battledata)
scene.abortable = true
lastbattle = Marshal.restore(battledata)
case lastbattle[0]
when BattleChallenge::BattleTowerID
when BattleChallenge::BATTLE_TOWER_ID
battleplayer = RecordedBattle::PlaybackBattle.new(scene, lastbattle)
when BattleChallenge::BattlePalaceID
when BattleChallenge::BATTLE_PALACE_ID
battleplayer = RecordedBattle::BattlePalacePlaybackBattle.new(scene, lastbattle)
when BattleChallenge::BattleArenaID
when BattleChallenge::BATTLE_ARENA_ID
battleplayer = RecordedBattle::BattleArenaPlaybackBattle.new(scene, lastbattle)
end
bgm = RecordedBattle::PlaybackHelper.pbGetBattleBGM(lastbattle)
pbBattleAnimation(bgm) {
pbSceneStandby {
battleplayer.pbStartBattle
}
}
pbBattleAnimation(bgm) do
pbSceneStandby { battleplayer.pbStartBattle }
end
end
#===============================================================================
@@ -140,9 +136,7 @@ def pbDebugPlayBattle
params.setInitialValue(0)
params.setCancelValue(-1)
num = pbMessageChooseNumber(_INTL("Choose a battle."), params)
if num >= 0
pbPlayBattleFromFile(sprintf("Battles/Battle%03d.dat", num))
end
pbPlayBattleFromFile(sprintf("Battles/Battle%03d.dat", num)) if num >= 0
end
def pbPlayBattleFromFile(filename)

View File

@@ -91,7 +91,7 @@ class BattleSwapScene
# Processes the scene
def pbChoosePokemon(canCancel)
pbActivateWindow(@sprites, "list") {
pbActivateWindow(@sprites, "list") do
loop do
Graphics.update
Input.update
@@ -109,7 +109,7 @@ class BattleSwapScene
end
end
end
}
end
end
def pbUpdateChoices(choices)

View File

@@ -26,7 +26,7 @@ class SafariState
def pbGoToStart
if $scene.is_a?(Scene_Map)
pbFadeOutIn {
pbFadeOutIn do
$game_temp.player_transferring = true
$game_temp.transition_processing = true
$game_temp.player_new_map_id = @start[0]
@@ -35,7 +35,7 @@ class SafariState
$game_temp.player_new_direction = 2
pbDismountBike
$scene.transfer_player
}
end
end
end
@@ -129,11 +129,9 @@ def pbSafariBattle(pkmn, level = 1)
BattleCreationHelperMethods.prepare_battle(battle)
# Perform the battle itself
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) {
pbSceneStandby {
decision = battle.pbStartBattle
}
}
pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) do
pbSceneStandby { decision = battle.pbStartBattle }
end
Input.update
# Update Safari game data based on result of battle
pbSafariState.ballcount = battle.ballCount

View File

@@ -68,14 +68,14 @@ class PokemonChallengeRules
end
def adjustLevelsBilateral(party1, party2)
if @levelAdjustment && @levelAdjustment.type == LevelAdjustment::BothTeams
if @levelAdjustment && @levelAdjustment.type == LevelAdjustment::BOTH_TEAMS
return @levelAdjustment.adjustLevels(party1, party2)
end
return nil
end
def unadjustLevelsBilateral(party1, party2, adjusts)
if @levelAdjustment && adjusts && @levelAdjustment.type == LevelAdjustment::BothTeams
if @levelAdjustment && adjusts && @levelAdjustment.type == LevelAdjustment::BOTH_TEAMS
@levelAdjustment.unadjustLevels(party1, party2, adjusts)
end
end

View File

@@ -134,9 +134,9 @@ class PokemonRuleSet
def hasRegistrableTeam?(list)
return false if !list || list.length < self.minTeamLength
pbEachCombination(list, self.maxTeamLength) { |comb|
pbEachCombination(list, self.maxTeamLength) do |comb|
return true if canRegisterTeam?(comb)
}
end
return false
end
@@ -156,7 +156,7 @@ class PokemonRuleSet
return false if !rule.isValid?(team)
end
if @subsetRules.length > 0
pbEachCombination(team, teamNumber) { |comb|
pbEachCombination(team, teamNumber) do |comb|
isValid = true
@subsetRules.each do |rule|
next if rule.isValid?(comb)
@@ -164,7 +164,7 @@ class PokemonRuleSet
break
end
return true if isValid
}
end
return false
end
return true

View File

@@ -2,10 +2,10 @@
#
#===============================================================================
class LevelAdjustment
BothTeams = 0
EnemyTeam = 1
MyTeam = 2
BothTeamsDifferent = 3
BOTH_TEAMS = 0
ENEMY_TEAM = 1
MY_TEAM = 2
BOTH_TEAMS_DIFFERENT = 3
def initialize(adjustment)
@adjustment = adjustment
@@ -48,14 +48,14 @@ class LevelAdjustment
adj1 = nil
adj2 = nil
ret = [getOldExp(team1, team2), getOldExp(team2, team1)]
if @adjustment == BothTeams || @adjustment == MyTeam
if @adjustment == BOTH_TEAMS || @adjustment == MY_TEAM
adj1 = getAdjustment(team1, team2)
elsif @adjustment == BothTeamsDifferent
elsif @adjustment == BOTH_TEAMS_DIFFERENT
adj1 = getMyAdjustment(team1, team2)
end
if @adjustment == BothTeams || @adjustment == EnemyTeam
if @adjustment == BOTH_TEAMS || @adjustment == ENEMY_TEAM
adj2 = getAdjustment(team2, team1)
elsif @adjustment == BothTeamsDifferent
elsif @adjustment == BOTH_TEAMS_DIFFERENT
adj2 = getTheirAdjustment(team2, team1)
end
if adj1
@@ -81,7 +81,7 @@ end
#===============================================================================
class FixedLevelAdjustment < LevelAdjustment
def initialize(level)
super(LevelAdjustment::BothTeams)
super(LevelAdjustment::BOTH_TEAMS)
@level = level.clamp(1, GameData::GrowthRate.max_level)
end
@@ -97,7 +97,7 @@ end
#===============================================================================
class TotalLevelAdjustment < LevelAdjustment
def initialize(minLevel, maxLevel, totalLevel)
super(LevelAdjustment::EnemyTeam)
super(LevelAdjustment::ENEMY_TEAM)
@minLevel = minLevel.clamp(1, GameData::GrowthRate.max_level)
@maxLevel = maxLevel.clamp(1, GameData::GrowthRate.max_level)
@totalLevel = totalLevel
@@ -129,7 +129,7 @@ end
#===============================================================================
class CombinedLevelAdjustment < LevelAdjustment
def initialize(my, their)
super(LevelAdjustment::BothTeamsDifferent)
super(LevelAdjustment::BOTH_TEAMS_DIFFERENT)
@my = my
@their = their
end
@@ -159,7 +159,7 @@ end
#===============================================================================
class CappedLevelAdjustment < LevelAdjustment
def initialize(level)
super(LevelAdjustment::BothTeams)
super(LevelAdjustment::BOTH_TEAMS)
@level = level.clamp(1, GameData::GrowthRate.max_level)
end
@@ -175,7 +175,7 @@ end
#===============================================================================
class LevelBalanceAdjustment < LevelAdjustment
def initialize(minLevel)
super(LevelAdjustment::BothTeams)
super(LevelAdjustment::BOTH_TEAMS)
@minLevel = minLevel
end
@@ -193,7 +193,7 @@ end
#===============================================================================
class EnemyLevelAdjustment < LevelAdjustment
def initialize(level)
super(LevelAdjustment::EnemyTeam)
super(LevelAdjustment::ENEMY_TEAM)
@level = level.clamp(1, GameData::GrowthRate.max_level)
end
@@ -209,7 +209,7 @@ end
#===============================================================================
class OpenLevelAdjustment < LevelAdjustment
def initialize(minLevel = 1)
super(LevelAdjustment::EnemyTeam)
super(LevelAdjustment::ENEMY_TEAM)
@minLevel = minLevel
end

View File

@@ -128,9 +128,7 @@ class BugContestState
score = pbBugContestScore(pokemon)
judgearray.push([cont, pokemon.species, score])
end
if judgearray.length < 3
raise _INTL("Too few bug catching contestants")
end
raise _INTL("Too few bug catching contestants") if judgearray.length < 3
judgearray.sort! { |a, b| b[2] <=> a[2] } # sort by score in descending order
@places.push(judgearray[0])
@places.push(judgearray[1])
@@ -156,7 +154,7 @@ class BugContestState
@decision = 1
pbJudge
if $scene.is_a?(Scene_Map)
pbFadeOutIn {
pbFadeOutIn do
$game_temp.player_transferring = true
$game_temp.player_new_map_id = @start[0]
$game_temp.player_new_x = @start[1]
@@ -165,7 +163,7 @@ class BugContestState
pbDismountBike
$scene.transfer_player
$game_map.need_refresh = true # in case player moves to the same map
}
end
end
end
@@ -386,7 +384,7 @@ def pbBugContestBattle(pkmn, level = 1)
BattleCreationHelperMethods.prepare_battle(battle)
# Perform the battle itself
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) {
pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) do
decision = battle.pbStartBattle
BattleCreationHelperMethods.after_battle(decision, true)
if [2, 5].include?(decision) # Lost or drew
@@ -394,7 +392,7 @@ def pbBugContestBattle(pkmn, level = 1)
$game_system.bgs_unpause
pbBugContestStartOver
end
}
end
Input.update
# Update Bug Contest game data based on result of battle
pbBugContestState.ballcount = battle.ballCount

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