Wolfram 语言

知识库扩展

找到强大的口袋妖怪

除了涵盖科学、地理等严肃领域的数百个实体类型外,版本 11 还纳入了一些趣味实体的内置数据,如口袋妖怪(Pokémon)实体的姓名、进化路径、能力和进攻和防守的统计信息.

求皮卡丘的身高.

In[1]:=
Click for copyable input
Entity["Pokemon", "Pokedex0025:Pikachu"][ EntityProperty["Pokemon", "Height"]]
Out[1]=

得到关于喵喵怪的数据关联.

In[2]:=
Click for copyable input
Entity["Pokemon", "Pokedex0052:Meowth"]["PropertyAssociation"]
Out[2]=

找到与给定身高和体制密切匹配的口袋妖怪.

显示完整的 Wolfram 语言输入
In[3]:=
Click for copyable input
Manipulate[ Grid@Partition[ Normal@EntityValue[ Entity["Pokemon", {"Weight" -> Quantity[ Interval[{w - 5, w + 5}], "Kilograms"], "Height" -> Quantity[ Interval[{h - 5, h + 5}], "Centimeters"]}], "Image", "EntityAssociation"] /. r_Rule :> Tooltip[r[[2]], r[[1]]], UpTo[3]], {{w, 30, "weight (kg)"}, 10, 200, 1, Appearance -> "Open"}, {{h, 130, "height (cm)"}, 100, 200, 1, Appearance -> "Open"}, ContinuousAction -> False, SynchronousUpdating -> False, SynchronousInitialization -> False]
播放动画
停止播放动画

从这里出发,你可以计算特定神奇宝贝的战斗破坏度.

显示完整的 Wolfram 语言输入
In[4]:=
Click for copyable input
Style[Manipulate[DynamicModule[{damage}, damage = ((((2*level*(criticalHit /. {True -> 2, False -> 1})/5 + 2)*attack*power/defense)/50 + 2)*(MatchQ[ Intersection @@ EntityValue[{attPokemon, defPokemon}, "Type"], {}] /. {True -> 1, False -> 1.5})*typeModifier)* Interval[{85, 100}]/100; Column[{Row[{"base statistics:"}, BaseStyle -> Bold], Grid[{{Null, "attacker", "defender"}, {"image", attPokemon["Image"], defPokemon["Image"]}, {"name", attPokemon["Name"], defPokemon["Name"]}, {"HP", attPokemon["HitPoints"], defPokemon["HitPoints"]}, {"attack", attPokemon["Attack"], defPokemon["Attack"]}, {"defense", attPokemon["Attack"], defPokemon["Defense"]}, {"special attack", attPokemon["Attack"], defPokemon["SpecialAttack"]}, {"special defense", attPokemon["Attack"], defPokemon["SpecialDefense"]}}, Background -> {None, {Lighter[Yellow, .9], {White, Lighter[Gray, .8]}}}, Frame -> All, FrameStyle -> Directive[Gray, Thick], Spacings -> {1, 1}], Row[{Null}], Row[{"damage:"}, BaseStyle -> Bold], Grid[{{"min", "average", "max"}, {N[Min[#]], N[Mean @@ #], N[Max[#]]} &@damage}, Frame -> All, FrameStyle -> Directive[Gray, Thick], Spacings -> {1, 1}, Background -> {None, {Lighter[Yellow, .9], White}}] }, BaseStyle -> {FontFamily -> "Helvetica"}] ], {{level, 50, "level"}, 1, 100, ControlType -> InputField}, {{attPokemon, Entity["Pokemon", "Pokedex0025:Pikachu"], "attacking Pokemon"}, pm, ControlType -> PopupMenu}, {{attack, 35, "attack"}, 1, 1000, ControlType -> InputField}, {{power, 90, "power"}, 1, 300, ControlType -> InputField}, {{defPokemon, Entity["Pokemon", "Pokedex0052:Meowth"], "defensing Pokemon"}, pm, ControlType -> PopupMenu}, {{defense, 35, "defense"}, 1, 1000, ControlType -> InputField}, {{typeModifier, 1, "type modifier"}, {4, 2, 1, 0.5, 0.25, 0}, ControlType -> PopupMenu}, {{criticalHit, False, "critical hit"}, {True, False}, ControlType -> Setter}, ContinuousAction -> False, SynchronousUpdating -> False, ControlPlacement -> Bottom, SynchronousInitialization -> False, Initialization :> {pm = First /@ SortBy[Normal@ EntityValue[EntityClass["Pokemon", All], "Name", "EntityAssociation"], Last]}], DynamicEvaluationTimeout -> Infinity]
播放动画
停止播放动画

然后,就可以找到基于总统计点数的最强大的神奇宝贝.

In[5]:=
Click for copyable input
powerful = EntityList[ Entity["Pokemon", { "Generation" -> Entity["PokemonGeneration", "GenerationI"], "StatTotal" -> TakeLargest[10]}]]
Out[5]=

找到攻击点大于 50 且防御点少于 40 的火型神奇宝贝.

In[6]:=
Click for copyable input
EntityValue[EntityList[ Entity["Pokemon", { "Type" -> "Fire", "Attack" -> GreaterThan[50], "Defense" -> LessThan[40]}]], "Image", "EntityAssociation"]
Out[6]=

找到重量大于 250 磅的粉红神奇宝贝.

In[7]:=
Click for copyable input
EntityValue[EntityList[ Entity["Pokemon", { "PokedexColor" -> Entity["PokemonPokedexColor", "Pink"], "Weight" -> GreaterThan[ Quantity[250, "Pounds"]]}]], "Image", "EntityAssociation"]
Out[7]=

相关范例

de en es fr ja ko pt-br ru