Skip to content

Instantly share code, notes, and snippets.

@Xom
Last active December 21, 2015 03:38
Show Gist options
  • Save Xom/6243261 to your computer and use it in GitHub Desktop.
Save Xom/6243261 to your computer and use it in GitHub Desktop.
saltybayes.pl See readme.txt for excuses.
I stayed up all night with an upset stomache to make saltybayes.pl so I didn't
really bother with even DRY or whatnot.
I don't even know Perl really (for example I don't have a mental model of the
syntax for array and hash references so I basically twiddled those around
haphazardly until they worked).
It's a variant of https://en.wikipedia.org/wiki/Averaged_one-dependence_estimators
where P(y,x_i) isn't multiplied against P(x_j|y,x_i) for independent x_j;
i.e. the left character's features are independent of the right character's,
so each of their P(y,x_i) is multiplied against five P(x_j|y,x_i) including the
height-comparison feature, and the height-comparison P(y,x_i) is multiplied
against all ten P(x_j|y,x_i) representing each character's five feature.
It's also totally useless because even with helper.html it takes too long to
bubble in all the circles to get a prediction in time.
BTW despite some bet history data in input.txt I never got around to editing the
perl script to parse it.
--
Explanation of tags:
a_yes: name has gratuitous adjective
a_no: opposite of a_yes
e_yes: is in http://fightersgeneration.com/characters.html
e_no: opposite of e_yes
g_male: character appears male
g_female: character appears female (incl. Bridget)
g_other: character appears neither male nor female
w_tech: guns, bombs, electronics, etc. visible when idle
w_polearm: non-tech, non-improvised polearm
w_blade: non-tech, non-polearm bladed weapon
w_misc: other weapon
w_unarmed: unarmed humanoid
w_mech: character is mechanical (e.g. robot); edit: now includes all mounted characters
w_other: non-humanoid, non-mechanical character
s_multi: multiple characters onscreen even when idle; overrides other s-tags
s_3d: 3D sprites copy-pasted from a fighting game
s_chibi: chibi sprites
s_mspaint: MSPaint-tier sprites
s_photo: Mortal Kombat and other photo-derived sprites
// s-tags override c-tags
c_db: Dragon Ball
c_mvc: Marvel universe plus non-SF Vs. characters
c_sf: Street Fighter
c_snk: all SNK fighters
c_tokusatsu: Power Rangers and other tokusatsu
c_moe: other moe girl characters from fighting games; overrides c_gglike
c_gglike: other characters from Guilty-Gear-like games
c_game: all other characters from videogames
c_comics: DC and other non-Marvel western comics
c_other: none of the above (MUGEN originals are this)
<html>
<head>
<title>SaltyBayes Helper</title>
<script type="text/javascript">
function heightcomp()
{
if (document.getElementById("hc_same").checked) {
return " = ";
} else if (document.getElementById("hc_mtt").checked) {
return " } ";
} else if (document.getElementById("hc_tt").checked) {
return " > ";
} else if (document.getElementById("hc_st").checked) {
return " < ";
} else {
return " { ";
}
}
function replaceline(n, s)
{
var myCommands = document.getElementById("commands");
var myLines = myCommands.value.split("\n");
myLines[n] = s;
myCommands.value = myLines.join("\n");
}
function replacenames()
{
var myCommands = document.getElementById("commands");
var myLines = myCommands.value.split("\n");
myLines[2] = document.getElementById("l_name").value;
myLines[9] = document.getElementById("r_name").value;
myLines[16] = "> " + myLines[2] + heightcomp() + myLines[9]
myCommands.value = myLines.join("\n");
}
</script>
</head>
<body onload="loadQuery()">
<h1><font color="#005d2f">SaltyBayes Helper</font></h1>
<form>
<p style="border: 1px solid #005d2f;"><b>Left:</b> <input type="text" size="120" id="l_name" onkeydown="window.setTimeout( function(){ replacenames() }, 1)" value="l_name" /><br><table><tr>
<td style="border: 1px solid #005d2f;">
<input type=radio name="l_a" id="l_a_yes" onChange="replaceline(3, 'a_yes')"><label for="l_a_yes" style="border: 1px solid #005d2f;">a_yes</label><br>
<input type=radio name="l_a" id="l_a_no" onChange="replaceline(3, 'a_no')" checked><label for="l_a_no" style="border: 1px solid #005d2f;">a_no</label>
</td>
<td style="border: 1px solid #005d2f;">
<input type=radio name="l_e" id="l_e_yes" onChange="replaceline(4, 'e_yes')"><label for="l_e_yes" style="border: 1px solid #005d2f;">e_yes</label><br>
<input type=radio name="l_e" id="l_e_no" onChange="replaceline(4, 'e_no')" checked><label for="l_e_no" style="border: 1px solid #005d2f;">e_no</label>
</td>
<td style="border: 1px solid #005d2f;">
<input type=radio name="l_g" id="l_g_male" onChange="replaceline(5, 'g_male')" checked><label for="l_g_male" style="border: 1px solid #005d2f;">g_male</label><br>
<input type=radio name="l_g" id="l_g_female" onChange="replaceline(5, 'g_female')"><label for="l_g_female" style="border: 1px solid #005d2f;">g_female</label><br>
<input type=radio name="l_g" id="l_g_other" onChange="replaceline(5, 'g_other')"><label for="l_g_other" style="border: 1px solid #005d2f;">g_other</label>
</td>
<td style="border: 1px solid #005d2f;">
<input type=radio name="l_w" id="l_w_tech" onChange="replaceline(6, 'w_tech')"><label for="l_w_tech" style="border: 1px solid #005d2f;">w_tech</label><br>
<input type=radio name="l_w" id="l_w_polearm" onChange="replaceline(6, 'w_polearm')"><label for="l_w_polearm" style="border: 1px solid #005d2f;">w_polearm</label><br>
<input type=radio name="l_w" id="l_w_blade" onChange="replaceline(6, 'w_blade')"><label for="l_w_blade" style="border: 1px solid #005d2f;">w_blade</label><br>
<input type=radio name="l_w" id="l_w_misc" onChange="replaceline(6, 'w_misc')"><label for="l_w_misc" style="border: 1px solid #005d2f;">w_misc</label><br>
<input type=radio name="l_w" id="l_w_unarmed" onChange="replaceline(6, 'w_unarmed')" checked><label for="l_w_unarmed" style="border: 1px solid #005d2f;">w_unarmed</label><br>
<input type=radio name="l_w" id="l_w_mech" onChange="replaceline(6, 'w_mech')"><label for="l_w_mech" style="border: 1px solid #005d2f;">w_mech</label><br>
<input type=radio name="l_w" id="l_w_other" onChange="replaceline(6, 'w_other')"><label for="l_w_other" style="border: 1px solid #005d2f;">w_other</label>
</td>
<td><table style="border: 1px solid #005d2f;"><tr>
<td>
<input type=radio name="l_s" id="l_s_multi" onChange="replaceline(7, 's_multi')"><label for="l_s_multi" style="border: 1px solid #005d2f;">s_multi</label><br>
<input type=radio name="l_s" id="l_s_3d" onChange="replaceline(7, 's_3d')"><label for="l_s_3d" style="border: 1px solid #005d2f;">s_3d</label><br>
<input type=radio name="l_s" id="l_s_chibi" onChange="replaceline(7, 's_chibi')"><label for="l_s_chibi" style="border: 1px solid #005d2f;">s_chibi</label><br>
<input type=radio name="l_s" id="l_s_mspaint" onChange="replaceline(7, 's_mspaint')"><label for="l_s_mspaint" style="border: 1px solid #005d2f;">s_mspaint</label><br>
<input type=radio name="l_s" id="l_s_photo" onChange="replaceline(7, 's_photo')"><label for="l_s_photo" style="border: 1px solid #005d2f;">s_photo</label><br>
</td><td>
<input type=radio name="l_s" id="l_c_db" onChange="replaceline(7, 'c_db')"><label for="l_c_db" style="border: 1px solid #005d2f;">c_db</label><br>
<input type=radio name="l_s" id="l_c_mvc" onChange="replaceline(7, 'c_mvc')"><label for="l_c_mvc" style="border: 1px solid #005d2f;">c_mvc</label><br>
<input type=radio name="l_s" id="l_c_sf" onChange="replaceline(7, 'c_sf')"><label for="l_c_sf" style="border: 1px solid #005d2f;">c_sf</label><br>
<input type=radio name="l_s" id="l_c_snk" onChange="replaceline(7, 'c_snk')"><label for="l_c_snk" style="border: 1px solid #005d2f;">c_snk</label><br>
<input type=radio name="l_s" id="l_c_tokusatsu" onChange="replaceline(7, 'c_tokusatsu')"><label for="l_c_tokusatsu" style="border: 1px solid #005d2f;">c_tokusatsu</label><br>
</td><td>
<input type=radio name="l_s" id="l_c_moe" onChange="replaceline(7, 'c_moe')"><label for="l_c_moe" style="border: 1px solid #005d2f;">c_moe</label><br>
<input type=radio name="l_s" id="l_c_gglike" onChange="replaceline(7, 'c_gglike')"><label for="l_c_gglike" style="border: 1px solid #005d2f;">c_gglike</label><br>
<input type=radio name="l_s" id="l_c_game" onChange="replaceline(7, 'c_game')" checked><label for="l_c_game" style="border: 1px solid #005d2f;">c_game</label><br>
<input type=radio name="l_s" id="l_c_comics" onChange="replaceline(7, 'c_comics')"><label for="l_c_comics" style="border: 1px solid #005d2f;">c_comics</label><br>
<input type=radio name="l_s" id="l_c_other" onChange="replaceline(7, 'c_other')"><label for="l_c_other" style="border: 1px solid #005d2f;">c_other</label>
</td>
</tr></table></td>
</tr></table></p>
<input type=radio name="hc" id="hc_mtt" onChange="replacenames()"><label for="hc_mtt" style="border: 1px solid #005d2f;">is Much Taller than</label>
<input type=radio name="hc" id="hc_tt" onChange="replacenames()"><label for="hc_tt" style="border: 1px solid #005d2f;">is Taller than</label>
<input type=radio name="hc" id="hc_same" onChange="replacenames()" checked><label for="hc_same" style="border: 1px solid #005d2f;">is the Same Height as</label>
<input type=radio name="hc" id="hc_st" onChange="replacenames()"><label for="hc_st" style="border: 1px solid #005d2f;">is Shorter than</label>
<input type=radio name="hc" id="hc_mst" onChange="replacenames()"><label for="hc_mst" style="border: 1px solid #005d2f;">is Much Shorter than</label>
<p style="border: 1px solid #005d2f;"><b>Right:</b> <input type="text" size="120" id="r_name" onkeydown="window.setTimeout( function(){ replacenames() }, 1)" value="r_name" /><br><table><tr>
<td style="border: 1px solid #005d2f;">
<input type=radio name="r_a" id="r_a_yes" onChange="replaceline(10, 'a_yes')"><label for="r_a_yes" style="border: 1px solid #005d2f;">a_yes</label><br>
<input type=radio name="r_a" id="r_a_no" onChange="replaceline(10, 'a_no')" checked><label for="r_a_no" style="border: 1px solid #005d2f;">a_no</label>
</td>
<td style="border: 1px solid #005d2f;">
<input type=radio name="r_e" id="r_e_yes" onChange="replaceline(11, 'e_yes')"><label for="r_e_yes" style="border: 1px solid #005d2f;">e_yes</label><br>
<input type=radio name="r_e" id="r_e_no" onChange="replaceline(11, 'e_no')" checked><label for="r_e_no" style="border: 1px solid #005d2f;">e_no</label>
</td>
<td style="border: 1px solid #005d2f;">
<input type=radio name="r_g" id="r_g_male" onChange="replaceline(12, 'g_male')" checked><label for="r_g_male" style="border: 1px solid #005d2f;">g_male</label><br>
<input type=radio name="r_g" id="r_g_female" onChange="replaceline(12, 'g_female')"><label for="r_g_female" style="border: 1px solid #005d2f;">g_female</label><br>
<input type=radio name="r_g" id="r_g_other" onChange="replaceline(12, 'g_other')"><label for="r_g_other" style="border: 1px solid #005d2f;">g_other</label>
</td>
<td style="border: 1px solid #005d2f;">
<input type=radio name="r_w" id="r_w_tech" onChange="replaceline(13, 'w_tech')"><label for="r_w_tech" style="border: 1px solid #005d2f;">w_tech</label><br>
<input type=radio name="r_w" id="r_w_polearm" onChange="replaceline(13, 'w_polearm')"><label for="r_w_polearm" style="border: 1px solid #005d2f;">w_polearm</label><br>
<input type=radio name="r_w" id="r_w_blade" onChange="replaceline(13, 'w_blade')"><label for="r_w_blade" style="border: 1px solid #005d2f;">w_blade</label><br>
<input type=radio name="r_w" id="r_w_misc" onChange="replaceline(13, 'w_misc')"><label for="r_w_misc" style="border: 1px solid #005d2f;">w_misc</label><br>
<input type=radio name="r_w" id="r_w_unarmed" onChange="replaceline(13, 'w_unarmed')" checked><label for="r_w_unarmed" style="border: 1px solid #005d2f;">w_unarmed</label><br>
<input type=radio name="r_w" id="r_w_mech" onChange="replaceline(13, 'w_mech')"><label for="r_w_mech" style="border: 1px solid #005d2f;">w_mech</label><br>
<input type=radio name="r_w" id="r_w_other" onChange="replaceline(13, 'w_other')"><label for="r_w_other" style="border: 1px solid #005d2f;">w_other</label>
</td>
<td><table style="border: 1px solid #005d2f;"><tr>
<td>
<input type=radio name="r_s" id="r_s_multi" onChange="replaceline(14, 's_multi')"><label for="r_s_multi" style="border: 1px solid #005d2f;">s_multi</label><br>
<input type=radio name="r_s" id="r_s_3d" onChange="replaceline(14, 's_3d')"><label for="r_s_3d" style="border: 1px solid #005d2f;">s_3d</label><br>
<input type=radio name="r_s" id="r_s_chibi" onChange="replaceline(14, 's_chibi')"><label for="r_s_chibi" style="border: 1px solid #005d2f;">s_chibi</label><br>
<input type=radio name="r_s" id="r_s_mspaint" onChange="replaceline(14, 's_mspaint')"><label for="r_s_mspaint" style="border: 1px solid #005d2f;">s_mspaint</label><br>
<input type=radio name="r_s" id="r_s_photo" onChange="replaceline(14, 's_photo')"><label for="r_s_photo" style="border: 1px solid #005d2f;">s_photo</label><br>
</td><td>
<input type=radio name="r_s" id="r_c_db" onChange="replaceline(14, 'c_db')"><label for="r_c_db" style="border: 1px solid #005d2f;">c_db</label><br>
<input type=radio name="r_s" id="r_c_mvc" onChange="replaceline(14, 'c_mvc')"><label for="r_c_mvc" style="border: 1px solid #005d2f;">c_mvc</label><br>
<input type=radio name="r_s" id="r_c_sf" onChange="replaceline(14, 'c_sf')"><label for="r_c_sf" style="border: 1px solid #005d2f;">c_sf</label><br>
<input type=radio name="r_s" id="r_c_snk" onChange="replaceline(14, 'c_snk')"><label for="r_c_snk" style="border: 1px solid #005d2f;">c_snk</label><br>
<input type=radio name="r_s" id="r_c_tokusatsu" onChange="replaceline(14, 'c_tokusatsu')"><label for="r_c_tokusatsu" style="border: 1px solid #005d2f;">c_tokusatsu</label><br>
</td><td>
<input type=radio name="r_s" id="r_c_moe" onChange="replaceline(14, 'c_moe')"><label for="r_c_moe" style="border: 1px solid #005d2f;">c_moe</label><br>
<input type=radio name="r_s" id="r_c_gglike" onChange="replaceline(14, 'c_gglike')"><label for="r_c_gglike" style="border: 1px solid #005d2f;">c_gglike</label><br>
<input type=radio name="r_s" id="r_c_game" onChange="replaceline(14, 'c_game')" checked><label for="r_c_game" style="border: 1px solid #005d2f;">c_game</label><br>
<input type=radio name="r_s" id="r_c_comics" onChange="replaceline(14, 'c_comics')"><label for="r_c_comics" style="border: 1px solid #005d2f;">c_comics</label><br>
<input type=radio name="r_s" id="r_c_other" onChange="replaceline(14, 'c_other')"><label for="r_c_other" style="border: 1px solid #005d2f;">c_other</label>
</td>
</tr></table></td>
</tr></table></p>
<input type=radio name="cat_destination" id="cd_query" onChange="replaceline(0, 'cat > query.txt <<ENDHEREDOC')" checked><label for="cd_query" style="border: 1px solid #005d2f;">QUERY</label>
<input type=radio name="cat_destination" id="cd_input" onChange="replaceline(0, 'cat >> input.txt <<ENDHEREDOC')"><label for="cd_input" style="border: 1px solid #005d2f;">INPUT</label> (Please add fight result manually.)
<p><textarea cols="70" rows="20" id="commands">cat > query.txt <<ENDHEREDOC
l_name
a_no
e_no
g_male
w_unarmed
c_game
r_name
a_no
e_no
g_male
w_unarmed
c_game
> l_name = r_name
ENDHEREDOC
perl saltybayes.pl
</textarea></p>
</form>
<p><a href="http://fightersgeneration.com/characters.html">http://fightersgeneration.com/characters.html</a></p>
</body>
</html>
hol_horse
e_yes
g_male
w_tech
c_gglike
charlotte
e_yes
g_female
w_blade
c_snk
> hol_horse > charlotte 03
reptile
e_yes
g_male
s_photo
haggar
e_yes
g_male
c_mvc
> reptile < haggar 03
ultraman
g_male
c_tokusatsu
namek_gohan
a_yes
g_male
c_db
> ultraman } namek_gohan 31
modoi_san
g_female
c_other
p_chunli
e_yes
g_female
s_chibi
> modoi_san > p_chunli 03
saiki
e_yes
g_male
c_snk
son_trunks
a_yes
g_male
c_db
> saiki } son_trunks 30
goku_sb1
g_male
c_db
bullseye
g_male
c_mvc
> goku_sb1 { bullseye 03
ibuki
e_yes
g_female
s_3d
meirin
g_female
c_moe
> ibuki > meirin 30
eiji_kisaragi
e_yes
g_male
c_snk
vivi_ornitier
g_other
w_polearm
c_game
> eiji_kisaragi > vivi_ornitier 03
roll
e_yes
g_female
c_mvc
axl
e_yes
g_male
w_blade
c_gglike
> roll { axl 30
adon
e_yes
g_male
s_3d
catwoman
e_yes
g_female
c_comics
> adon > catwoman 30
silver_samurai
e_yes
g_male
w_blade
c_mvc
fordy
g_other
w_mech
c_game
> silver_samurai } fordy 03
lord_zedd
g_male
w_polearm
c_tokusatsu
princess_peach
g_female
c_game
> lord_zedd > princess_peach 30
hisui_kohaku
g_female
w_misc
s_multi
grover
g_other
s_mspaint
> hisui_kohaku < grover 23
vega
e_yes
g_male
c_sf
mai_k
g_female
w_blade
c_moe
> vega > mai_k 03
rogue
e_yes
g_female
c_mvc
electro
g_male
c_mvc
> rogue = electro 30
leela
g_female
s_mspaint
viuda_negra
g_female
c_mvc
> leela = viuda_negra 23
pikachu
g_other
w_other
c_game
kanmi_chan
g_female
w_misc
s_mspaint
> pikachu = kanmi_chan 13
shermie
e_yes
g_female
c_snk
elongated_man
g_male
c_comics
> shermie < elongated_man 31
pyro
g_male
w_tech
c_mvc
spenoza
g_female
c_game
> pyro > spenoza 30
syo_hayate
e_yes
g_male
w_misc
c_snk
symbiote_spider_man
a_yes
e_yes
g_male
c_mvc
> syo_hayate > symbiote_spider_man 03
fio
e_yes
g_female
c_snk
makoto
e_yes
g_female
c_sf
> fio = makoto 13
sakura_kinomoto
g_female
w_polearm
s_multi
thanoseid
g_male
c_mvc
> sakura_kinomoto { thanoseid 31
megazord
g_other
w_mech
c_tokusatsu
kid_gohan_ssj1
a_yes
g_male
c_db
> megazord } kid_gohan_ssj1 03
ella
g_female
c_other
recoom
g_male
c_db
> ella = recoom 31
juggernaut
e_yes
g_male
c_mvc
yukari_yakumo
g_female
w_misc
c_moe
> juggernaut > yukari_yakumo 03
jo_jo
e_yes
g_male
c_gglike
wriggle
g_female
c_moe
> jo_jo > wriggle 30
hobgoblin
g_male
w_mech
c_mvc
jean_grey
e_yes
g_female
c_mvc
> hobgoblin > jean_grey 03
brian_griffin
g_male
w_other
s_mspaint
> brian_griffin < vega 31
iggy
e_yes
g_other
w_other
c_gglike
dhalsim
e_yes
g_male
c_sf
> iggy { dhalsim 30
polaris
a_no
e_no
g_female
w_unarmed
c_mvc
dodgers
a_no
e_no
g_male
w_tech
c_other
> polaris = dodgers 03
jon_talbain
a_no
e_yes
g_male
w_other
c_gglike
kuroko
a_no
e_yes
g_other
w_unarmed
c_snk
> jon_talbain > kuroko 30
tenma_sama
a_no
e_no
g_female
w_blade
c_moe
ironpatriot
a_no
e_no
g_male
w_unarmed
c_mvc
> tenma_sama < ironpatriot 30
gray_fly
a_no
e_no
g_male
w_unarmed
c_gglike
captain_marvel
a_no
e_yes
g_male
w_unarmed
c_mvc
> gray_fly { captain_marvel 31
yuriesbyfe
a_yes
e_no
g_female
w_misc
c_gglike
nightwing
a_no
e_yes
g_male
w_unarmed
c_comics
> yuriesbyfe = nightwing 30
annie_murakami
a_no
e_yes
g_female
w_unarmed
c_snk
poison
a_no
e_yes
g_female
w_unarmed
c_sf
> annie_murakami < poison 30 1155030 102653
zettaiaku
a_no
e_no
g_other
w_mech
c_other
gogeta_ssj4
a_no
e_no
g_male
w_other
c_db
> zettaiaku > gogeta_ssj4 32 144581 1039912
morrigan
a_no
e_yes
g_female
w_unarmed
s_chibi
nrvnsqr_chaos
a_no
e_no
g_male
w_unarmed
c_gglike
> morrigan { nrvnsqr_chaos 13 376408 2245828
drdoom
a_no
e_yes
g_male
w_unarmed
c_mvc
trunks
a_no
e_no
g_male
w_unarmed
c_db
> drdoom } trunks 30 11706406 135143
tibigintou
a_yes
e_no
g_female
w_unarmed
c_moe
toramaru_syou
a_no
e_no
g_female
w_polearm
c_moe
> tibigintou { toramaru_syou 23 179445 791606
spiderman
a_no
e_yes
g_male
w_unarmed
c_mvc
> spiderman } iggy 30 712840 259419
robo_rock
a_yes
e_yes
g_male
w_unarmed
c_snk
hato_sabure
a_no
e_no
g_other
w_other
c_other
> robo_rock { hato_sabure 03 136670 5458613
lucca
a_no
e_no
g_female
w_unarmed
s_mspaint
firebrand
a_no
e_yes
g_other
w_other
c_mvc
> lucca = firebrand 03 130693 840788
simonkin2006
a_no
e_no
g_other
w_other
c_tokusatsu
rajaamaki
a_no
e_no
g_female
w_misc
c_snk
> simonkin2006 > rajaamaki 03 166625 5347150
spider_man_2099
a_no
e_yes
g_male
w_unarmed
c_mvc
heika
a_no
e_no
g_male
w_mech
c_other
> spider_man_2099 < heika 32 1064534 89458
pyron
a_no
e_yes
g_other
w_other
c_gglike
son_gohan
a_no
e_no
g_male
w_unarmed
c_db
> pyron > son_gohan 30 1094136 164431
morph
a_no
e_no
g_male
w_tech
c_mvc
> morph < hobgoblin 30 2918912 137413
maxima
a_no
e_yes
g_male
w_unarmed
c_snk
chameleon
a_no
e_yes
g_male
w_unarmed
s_photo
> maxima > chameleon 03 17528 2890975
saisyuu_dokusyo_bouei_system
a_no
e_no
g_female
w_tech
c_moe
> firebrand < saisyuu_dokusyo_bouei_system 03 85965 5651846
fox_mccloud
a_no
e_no
g_male
w_other
s_mspaint
yoko_yuki
a_no
e_no
g_female
w_unarmed
c_game
> fox_mccloud = yoko_yuki 03
> hol_horse = silver_samurai 03 305656 3407119
rajaayuri
a_yes
e_yes
g_female
w_unarmed
c_snk
lobo
a_no
e_yes
g_male
w_unarmed
c_comics
> rajaayuri < lobo 31 1757474 158505
beast
a_no
e_no
g_male
w_unarmed
c_mvc
ultimat_goku
a_yes
e_no
g_male
w_unarmed
c_db
> beast > ultimat_goku 23 285187 396966
i_no
a_no
e_yes
g_female
w_misc
c_gglike
crilin_sposato
a_no
e_no
g_male
w_unarmed
c_db
> i_no } crilin_sposato 03 350425 535262
hulk
a_no
e_yes
g_male
w_unarmed
c_mvc
death13
a_no
e_no
g_other
w_polearm
c_gglike
> hulk = death13 30 2423772 82489
joseph_the_b_b
a_no
e_yes
g_male
w_unarmed
c_gglike
dr_gero
a_no
e_no
g_male
w_unarmed
s_multi
> joseph_the_b_b > dr_gero 03 73560 2625550
ken
a_no
e_yes
g_male
w_unarmed
c_sf
masta_gambit
a_yes
e_yes
g_male
w_polearm
c_mvc
> ken = masta_gambit 03 164573 739568
nenaikodareda
a_no
e_no
g_other
w_other
s_mspaint
onpu_segawa
a_no
e_no
g_female
w_polearm
c_moe
> nenaikodareda < onpu_segawa 03 42916 3996712
goku_db
a_no
e_no
g_male
w_unarmed
c_db
red_ranger
a_no
e_no
g_other
w_unarmed
c_tokusatsu
> goku_db { red_ranger 13 98710 784267
m_bison
a_no
e_yes
g_male
w_unarmed
c_sf
saiki
a_no
e_yes
g_male
w_unarmed
c_snk
> m_bison < saiki 03 94431 1273278
ken
a_no
e_yes
g_male
w_unarmed
c_snk
maxima
a_no
e_yes
g_male
w_unarmed
c_snk
> ken < maxima 30 1220749 63412
vanilla_h
a_no
e_no
g_female
w_misc
c_moe
mega_weapon
a_no
e_no
g_male
w_mech
c_game
> vanilla_h = mega_weapon 03 130052 2137847
orchid
a_no
e_no
g_female
w_unarmed
c_game
myuu
a_no
e_no
g_female
w_unarmed
c_moe
> orchid > myuu 30 328972 90905
ultimate_cap
a_yes
e_yes
g_male
w_misc
c_mvc
babidi
a_no
e_no
g_other
w_other
c_game
> ultimate_cap } babidi 30 3185941 26726
robin
a_no
e_no
g_male
w_polearm
c_comics
chise
a_no
e_no
g_female
w_tech
c_moe
> robin < chise 30 190226 132835
dark_psylocke
a_yes
e_yes
g_female
w_unarmed
c_mvc
master_ryu
a_yes
e_yes
g_male
w_unarmed
c_sf
> dark_psylocke = master_ryu 03 65339 1016436
great_gohan
a_yes
e_no
g_male
w_unarmed
c_db
kaori_shiori
a_no
e_no
g_female
w_unarmed
c_moe
> great_gohan = kaori_shiori 30 100159 714716
ramon_71113
a_no
e_yes
g_male
w_unarmed
c_snk
trunks
a_no
e_no
g_male
w_blade
c_db
> ramon_71113 = trunks 30 3284756 120349
chris_sakurigan
a_no
e_no
g_female
w_unarmed
c_gglike
super_mario
a_no
e_no
g_male
w_unarmed
c_game
> chris_sakurigan = super_mario 03 117845 2686455
l_name
a_no
e_no
g_male
w_unarmed
c_game
r_name
a_no
e_no
g_male
w_unarmed
c_game
> l_name = r_name
#!/usr/bin/env perl
use strict;
my $input_file = 'input.txt';
my $query_file = 'query.txt';
my @tags = ('a', 'e', 'g', 'w', 's');
my %hcrev = ('{' => '}', '<' => '>', '=' => '=', '>' => '<', '}' => '{');
my %counts = (
'a_no' => {'TOTAL' => [0, 0]},
'e_no' => {'TOTAL' => [0, 0]},
'g_male' => {'TOTAL' => [0, 0]},
'w_unarmed' => {'TOTAL' => [0, 0]},
'c_game' => {'TOTAL' => [0, 0]}
);
my $total_rounds = 0;
my %mugenizenry = ();
my %recent_mugs = ();
my $reading_mug = 0;
if (open INPT, '<', $input_file) {
foreach my $line (<INPT>) {
chomp($line);
if ($line) {
if ($reading_mug) {
if (! exists $counts{$line}) {
$counts{$line} = {'TOTAL' => [0, 0]};
}
my $c = substr($line, 0, 1);
if ($c eq 'c') {
$c = 's';
}
$mugenizenry{$reading_mug}{$c} = $line;
$recent_mugs{$reading_mug}{$c} = $line;
} elsif (substr($line, 0, 1) eq '>') {
if ($line =~ m/> ([^ ]+) ([{<=>}]) ([^ ]+) ([0-9])([0-9])/) {
my ($left, $height_comp, $right, $lwins, $rwins) = ($1, $2, $3, $4, $5);
my %lmug = ();
my %rmug = ();
if (exists $recent_mugs{$left}) {
%lmug = %{$recent_mugs{$left}};
} elsif (exists $mugenizenry{$left}) {
%lmug = %{$mugenizenry{$left}};
} else {
print "Mugizen $left not found!\n";
exit 1;
}
if (exists $recent_mugs{$right}) {
%rmug = %{$recent_mugs{$right}};
} elsif (exists $mugenizenry{$right}) {
%rmug = %{$mugenizenry{$right}};
} else {
print "Mugizen $right not found!\n";
exit 1;
}
$total_rounds += 2 * ($lwins + $rwins);
$counts{$height_comp}{'TOTAL'}[0] += $lwins;
$counts{$height_comp}{'TOTAL'}[1] += $rwins;
$counts{$hcrev{$height_comp}}{'TOTAL'}[0] += $rwins;
$counts{$hcrev{$height_comp}}{'TOTAL'}[1] += $lwins;
for (my $i = 0; $i < @tags; $i++) {
$counts{$lmug{$tags[$i]}}{'TOTAL'}[0] += $lwins;
$counts{$lmug{$tags[$i]}}{'TOTAL'}[1] += $rwins;
$counts{$rmug{$tags[$i]}}{'TOTAL'}[0] += $rwins;
$counts{$rmug{$tags[$i]}}{'TOTAL'}[1] += $lwins;
$counts{$lmug{$tags[$i]}}{$height_comp}[0] += $lwins;
$counts{$lmug{$tags[$i]}}{$height_comp}[1] += $rwins;
$counts{$height_comp}{$lmug{$tags[$i]}}[0] += $lwins;
$counts{$height_comp}{$lmug{$tags[$i]}}[1] += $rwins;
$counts{$rmug{$tags[$i]}}{$hcrev{$height_comp}}[0] += $rwins;
$counts{$rmug{$tags[$i]}}{$hcrev{$height_comp}}[1] += $lwins;
$counts{$hcrev{$height_comp}}{$rmug{$tags[$i]}}[0] += $rwins;
$counts{$hcrev{$height_comp}}{$rmug{$tags[$i]}}[1] += $lwins;
}
for (my $i = 0; $i + 1 < @tags; $i++) {
for (my $j = $i + 1; $j < @tags; $j++) {
if ($i != $j) {
$counts{$lmug{$tags[$i]}}{$lmug{$tags[$j]}}[0] += $lwins;
$counts{$lmug{$tags[$i]}}{$lmug{$tags[$j]}}[1] += $rwins;
$counts{$lmug{$tags[$j]}}{$lmug{$tags[$i]}}[0] += $lwins;
$counts{$lmug{$tags[$j]}}{$lmug{$tags[$i]}}[1] += $rwins;
$counts{$rmug{$tags[$i]}}{$rmug{$tags[$j]}}[0] += $rwins;
$counts{$rmug{$tags[$i]}}{$rmug{$tags[$j]}}[1] += $lwins;
$counts{$rmug{$tags[$j]}}{$rmug{$tags[$i]}}[0] += $rwins;
$counts{$rmug{$tags[$j]}}{$rmug{$tags[$i]}}[1] += $lwins;
}
}
}
%recent_mugs = ();
} else {
print "Failed parsing $line\n";
}
} else {
$reading_mug = $line;
%{$mugenizenry{$reading_mug}} = (
'a' => 'a_no',
'e' => 'e_no',
'g' => 'g_male',
'w' => 'w_unarmed',
's' => 'c_game'
);
%{$recent_mugs{$reading_mug}} = (
'a' => 'a_no',
'e' => 'e_no',
'g' => 'g_male',
'w' => 'w_unarmed',
's' => 'c_game'
);
}
} else {
$reading_mug = 0;
}
}
close INPT;
} else {
print "Failed reading $input_file\n";
}
# The prior is a hypothetical pair of rounds, one won,
# one lost, where every tag is simultaneously active.
$total_rounds += 2;
foreach my $tag1 (keys %counts) {
$counts{$tag1}{'TOTAL'}[0]++;
$counts{$tag1}{'TOTAL'}[1]++;
foreach my $tag2 (keys %counts) {
my $c1 = substr($tag1, 0, 1);
my $c2 = substr($tag2, 0, 1);
if ($c1 eq 'c') {
$c1 = 's';
}
if ($c2 eq 'c') {
$c2 = 's';
}
if (! ($c1 eq $c2 || (exists $hcrev{$c1} && exists $hcrev{$c2}))) {
$counts{$tag1}{$tag2}[0]++;
$counts{$tag1}{$tag2}[1]++;
}
}
}
print "\n$total_rounds\n";
#foreach my $tag1 (keys %counts) {
# foreach my $tag2 (keys $counts{$tag1}) {
# print "$tag1 $tag2 $counts{$tag1}{$tag2}[0] $counts{$tag1}{$tag2}[1]\n";
# }
#}
$reading_mug = 0;
if (open QUERY, '<', $query_file) {
foreach my $line (<QUERY>) {
chomp($line);
if ($line) {
if ($reading_mug) {
my $c = substr($line, 0, 1);
if ($c eq 'c') {
$c = 's';
}
$mugenizenry{$reading_mug}{$c} = $line;
$recent_mugs{$reading_mug}{$c} = $line;
} elsif (substr($line, 0, 1) eq '>') {
if ($line =~ m/> ([^ ]+) ([{<=>}]) ([^ ]+)/) {print "$line\n";
my ($left, $height_comp, $right) = ($1, $2, $3);
my %lmug = ();
my %rmug = ();
if (exists $recent_mugs{$left}) {
%lmug = %{$recent_mugs{$left}};
} elsif (exists $mugenizenry{$left}) {
%lmug = %{$mugenizenry{$left}};
} else {
print "Mugizen $left not found!\n";
exit 1;
}
if (exists $recent_mugs{$right}) {
%rmug = %{$recent_mugs{$right}};
} elsif (exists $mugenizenry{$right}) {
%rmug = %{$mugenizenry{$right}};
} else {
print "Mugizen $right not found!\n";
exit 1;
}
my $leftodds = 0;
for (my $i = 0; $i < @tags; $i++) {
my $pyxi = $counts{$lmug{$tags[$i]}}{'TOTAL'}[0];
my $prod = $counts{$lmug{$tags[$i]}}{$height_comp}[0]; # *= $pyxi /= $pyxi
for (my $j = 0; $j < @tags; $j++) {
if ($i != $j) {
$prod *= $counts{$lmug{$tags[$i]}}{$lmug{$tags[$j]}}[0];
}
}
$leftodds += $prod / ($pyxi * $pyxi * $pyxi * $pyxi);
}
for (my $i = 0; $i < @tags; $i++) {
my $pyxi = $counts{$rmug{$tags[$i]}}{'TOTAL'}[1];
my $prod = $counts{$rmug{$tags[$i]}}{$hcrev{$height_comp}}[1];
for (my $j = 0; $j < @tags; $j++) {
if ($i != $j) {
$prod *= $counts{$rmug{$tags[$i]}}{$rmug{$tags[$j]}}[1];
}
}
$leftodds += $prod / ($pyxi * $pyxi * $pyxi * $pyxi);
}
my $pyxi = $counts{$height_comp}{'TOTAL'}[0];
my $prod = 1;
for (my $j = 0; $j < @tags; $j++) {
$prod *= $counts{$lmug{$tags[$j]}}{$height_comp}[0];
$prod *= $counts{$rmug{$tags[$j]}}{$hcrev{$height_comp}}[1];
}
$leftodds += $prod / ($pyxi * $pyxi * $pyxi
* $pyxi * $pyxi * $pyxi
* $pyxi * $pyxi * $pyxi);
my $rightodds = 0;
for (my $i = 0; $i < @tags; $i++) {
my $pyxi = $counts{$lmug{$tags[$i]}}{'TOTAL'}[1];
my $prod = $counts{$lmug{$tags[$i]}}{$height_comp}[1]; # *= $pyxi /= $pyxi
for (my $j = 0; $j < @tags; $j++) {
if ($i != $j) {
$prod *= $counts{$lmug{$tags[$i]}}{$lmug{$tags[$j]}}[1];
}
}
$rightodds += $prod / ($pyxi * $pyxi * $pyxi * $pyxi);
}
for (my $i = 0; $i < @tags; $i++) {
my $pyxi = $counts{$rmug{$tags[$i]}}{'TOTAL'}[0];
my $prod = $counts{$rmug{$tags[$i]}}{$hcrev{$height_comp}}[0];
for (my $j = 0; $j < @tags; $j++) {
if ($i != $j) {
$prod *= $counts{$rmug{$tags[$i]}}{$rmug{$tags[$j]}}[0];
}
}
$rightodds += $prod / ($pyxi * $pyxi * $pyxi * $pyxi);
}
my $pyxi = $counts{$height_comp}{'TOTAL'}[1];
my $prod = 1;
for (my $j = 0; $j < @tags; $j++) {
$prod *= $counts{$lmug{$tags[$j]}}{$height_comp}[1];
$prod *= $counts{$rmug{$tags[$j]}}{$hcrev{$height_comp}}[0];
}
$rightodds += $prod / ($pyxi * $pyxi * $pyxi
* $pyxi * $pyxi * $pyxi
* $pyxi * $pyxi * $pyxi);
my $leftroundprob = $leftodds / ($leftodds + $rightodds);
my $rightroundprob = 1 - $leftroundprob;
my $leftmatchprob = ($leftroundprob * $leftroundprob * $leftroundprob)
* (1 + (3 * $rightroundprob) + (6 * $rightroundprob * $rightroundprob));
print "Predicted round win probability: $leftroundprob\n";
print "Predicted match win probability: $leftmatchprob\n";
%recent_mugs = ();
} else {
print "Failed parsing $line\n";
}
} else {
$reading_mug = $line;
%{$mugenizenry{$reading_mug}} = (
'a' => 'a_no',
'e' => 'e_no',
'g' => 'g_male',
'w' => 'w_unarmed',
's' => 'c_game'
);
%{$recent_mugs{$reading_mug}} = (
'a' => 'a_no',
'e' => 'e_no',
'g' => 'g_male',
'w' => 'w_unarmed',
's' => 'c_game'
);
}
} else {
$reading_mug = 0;
}
}
close QUERY;
} else {
print "Failed reading $query_file\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment