2013-04-20 06:39:59 -07:00
JAVA = java -Xms256M -Xmx256M
DEBUG = java -ea -Xms256M -Xmx256M -Ddebug= true
2013-03-12 05:31:34 -07:00
LIBS = .:lib/annotations.jar:lib/jsr305.jar:release/lib/groovy-all-2.1.1.jar
2013-04-20 06:39:59 -07:00
RUN = ${ DEBUG } -Dcom.sun.management.jmxremote -cp $( LIBS) :release/Magarena.jar
2011-06-09 01:23:52 -07:00
SHELL = /bin/bash
2011-05-24 20:10:09 -07:00
BUILD = build
2012-06-14 03:26:36 -07:00
SRC = $( shell find src -iname *.java)
2011-05-22 19:52:01 -07:00
MAG := release/Magarena.jar
EXE := release/Magarena.exe
2011-05-22 19:23:49 -07:00
2013-02-18 01:20:00 -08:00
all : tags $( MAG ) $( EXE )
2011-05-22 19:52:01 -07:00
2012-02-23 21:50:24 -08:00
zips :
2012-02-23 21:59:40 -08:00
make M` grep Release release/README.txt | head -1 | cut -d' ' -f2`
2012-02-23 21:50:24 -08:00
2011-08-24 23:24:57 -07:00
cubes : \
2012-08-23 06:31:54 -07:00
cards/standard_all.txt \
cards/extended_all.txt \
cards/modern_all.txt \
2011-11-18 19:30:04 -08:00
release/Magarena/mods/legacy_cube.txt \
release/Magarena/mods/extended_cube.txt \
release/Magarena/mods/standard_cube.txt \
release/Magarena/mods/modern_cube.txt
2011-06-09 19:09:19 -07:00
2011-08-25 23:40:03 -07:00
themes : \
2011-11-18 19:30:04 -08:00
release/Magarena/mods/felt_theme.zip \
2013-02-11 18:56:20 -08:00
release/Magarena/mods/brown_theme.zip \
2011-11-18 19:30:04 -08:00
release/Magarena/mods/blackswamp_theme.zip \
release/Magarena/mods/bluemarble_theme.zip \
release/Magarena/mods/darkbattle_theme.zip \
release/Magarena/mods/gothic_theme.zip \
release/Magarena/mods/greenforest_theme.zip \
release/Magarena/mods/moon_theme.zip \
release/Magarena/mods/mystic_theme.zip \
release/Magarena/mods/nature_theme.zip \
release/Magarena/mods/redfire_theme.zip \
release/Magarena/mods/whiteangel_theme.zip
2011-08-25 23:40:03 -07:00
2011-11-15 18:11:34 -08:00
cards_diff : $( MAG )
2011-11-15 18:21:14 -08:00
for i in ` hg stat -q src/magic/card release/Magarena/scripts | cut -d' ' -f2 | sort -t'/' -k4` ; do hg diff $$ i; done | flip -u - > $@
2011-11-15 18:11:34 -08:00
2012-10-14 07:43:04 -07:00
findbugs_warnings.txt : $( MAG )
2012-06-12 23:35:26 -07:00
~/App/findbugs/bin/findbugs \
2011-08-30 21:40:36 -07:00
-textui \
-progress \
-sortByClass \
-emacs \
-effort:max \
-output $@ \
-sourcepath src \
build
2012-10-14 07:43:04 -07:00
build_warnings.txt :
make clean all > $@
2012-06-20 06:09:21 -07:00
cards/legacy_banned.txt :
curl https://www.wizards.com/Magic/TCG/Resources.aspx?x= judge/resources/sfrlegacy | grep nodec | grep -o ">[^<]*</a" | sed 's/>//g;s/<\/a//;' > $@
2012-07-01 07:01:42 -07:00
release/Magarena/mods/legacy_cube.txt : cards /existing_tip .txt cards /legacy_banned .txt
2011-06-09 19:09:19 -07:00
join -v1 -t"|" <( sort $( word 1,$^) ) <( sort $( word 2,$^) ) > $@
2012-07-01 07:01:42 -07:00
release/Magarena/mods/%_cube.txt : cards /existing_tip .txt cards /%_all .txt
2011-06-09 01:23:52 -07:00
join -t"|" <( sort $( word 1,$^) ) <( sort $( word 2,$^) ) > $@
2012-08-23 06:31:54 -07:00
cards/%_all.out :
2012-08-19 08:04:51 -07:00
touch $@
2012-08-19 08:23:58 -07:00
for rarity in mythic rare uncommon common land special; do \
2012-10-31 06:20:18 -07:00
curl --compressed " http://magiccards.info/query?q=r%3A $$ rarity+f%3A $* &s=cname&v=olist&p=1 " | grep "en/" >> $@ ; \
curl --compressed " http://magiccards.info/query?q=r%3A $$ rarity+f%3A $* &s=cname&v=olist&p=2 " | grep "en/" >> $@ ; \
curl --compressed " http://magiccards.info/query?q=r%3A $$ rarity+f%3A $* &s=cname&v=olist&p=3 " | grep "en/" >> $@ ; \
2012-08-19 08:04:51 -07:00
done
2012-08-23 06:35:58 -07:00
sed -i 's/<[^>]*>//g;s/^[ ]*//g' $@
2012-05-26 00:19:22 -07:00
sed -i 's/Æ/AE/' $@
2011-06-09 01:23:52 -07:00
2012-08-23 06:31:54 -07:00
cards/%_all.txt : cards /%_all .out
sort $^ | uniq > $@
2011-06-09 01:23:52 -07:00
2012-10-27 02:21:38 -07:00
cards/new.txt : cards /existing_tip .txt
2012-10-27 02:17:53 -07:00
$( eval LAST := $( shell hg tags | grep "^[[:digit:]]" | head -1 | cut -d' ' -f1) )
make cards/new_$( LAST) .txt
mv cards/new_$( LAST) .txt $@
2012-10-27 02:21:38 -07:00
make wiki/UpcomingCards.wiki
2012-10-27 02:17:53 -07:00
2012-07-01 05:10:50 -07:00
cards/new_%.txt : cards /existing_tip .txt cards /existing_ %.txt
2012-06-12 20:27:08 -07:00
join -v1 -t"|" <( sort $( word 1,$^) ) <( sort $( word 2,$^) ) > $@
cards/new_scripts_%.txt : release /Magarena /scripts
2012-05-22 20:56:17 -07:00
grep "name=" -h $$ ( hg diff -r $* | grep -B 1 "^--- /dev/null" | grep $^ | cut -d' ' -f4) | sed 's/name=//' > $@
2012-05-22 20:48:40 -07:00
flip -u $@
2011-09-08 00:36:24 -07:00
2012-07-01 05:10:50 -07:00
cards/existing_scripts_%.txt : $( wildcard release /Magarena /scripts /*.txt )
2012-12-24 07:03:36 -08:00
hg cat -r $* release/Magarena/scripts | grep "name=" | sed 's/.*name=//' | sort > $@
2012-01-27 18:49:19 -08:00
sed -i 's/\r//' $@
2011-06-02 00:03:14 -07:00
2012-07-01 05:10:50 -07:00
cards/existing_tokens_%.txt : $( wildcard release /Magarena /scripts /*.txt )
2012-12-24 07:03:36 -08:00
hg cat -r $* release/Magarena/scripts | grep -C 1 "token=" | grep "name=" | sed 's/.*name=//' | sort > $@
2011-11-22 21:12:47 -08:00
2012-07-01 05:10:50 -07:00
cards/existing_%.txt : cards /existing_scripts_ %.txt cards /existing_tokens_ %.txt
2011-11-22 21:12:47 -08:00
join -v1 -t"|" <( sort $( word 1,$^) ) <( sort $( word 2,$^) ) > $@
2012-10-11 19:43:16 -07:00
%_full.txt : scripts /extract_candidates .awk %.txt cards /mtg -data .txt
awk -f $^ | sed 's/\t/\n/g' > $@
2011-06-02 00:03:14 -07:00
2012-10-07 22:55:29 -07:00
cards/candidates_full.txt : scripts /extract_candidates .awk cards /scored_by_dec .tsv cards /unimplementable .tsv cards /mtg -data .txt
2011-06-02 19:29:35 -07:00
awk -f $^ | sort -rg | sed 's/\t/\n/g' > $@
2012-10-07 23:19:48 -07:00
cards/unimplementable.tsv.update : cards /candidates_full .txt
grep "|" $^ | sed 's/NAME://;s/|/\t/' >> $( basename $@ )
2011-06-06 20:19:30 -07:00
%.out : $( MAG )
2011-06-10 23:03:02 -07:00
SGE_TASK_ID = $* exp/eval_mcts.sh
2012-08-25 07:09:10 -07:00
2012-01-27 18:57:20 -08:00
M1.% : clean $( EXE ) cubes release /Magarena /mods /felt_theme .zip
2012-01-27 18:26:56 -08:00
grep " VERSION.*1. $* " -Ir src/
2011-09-08 00:36:24 -07:00
grep " Release.*1. $* " release/README.txt
2012-01-27 18:26:56 -08:00
grep 1.$* -Ir Magarena.app/
2011-05-29 18:51:10 -07:00
-rm -rf Magarena-1.$*
2011-10-28 05:27:43 -07:00
-rm -rf Magarena-1.$* .app
2011-05-29 18:51:10 -07:00
-rm Magarena-1.$* .zip
2011-11-25 21:55:03 -08:00
-rm Magarena-1.$* .app.zip
2011-05-29 19:04:45 -07:00
mkdir -p Magarena-1.$* /Magarena/mods
2013-01-05 22:20:50 -08:00
cp -r \
2011-05-27 00:34:47 -07:00
release/gpl-3.0.html \
release/Magarena.exe \
release/Magarena.sh \
release/Magarena.command \
release/README.txt \
2013-01-05 22:20:50 -08:00
release/lib \
2011-05-29 18:51:10 -07:00
Magarena-1.$*
2011-05-29 18:46:41 -07:00
cp -r \
2011-11-17 17:38:37 -08:00
release/Magarena/avatars \
release/Magarena/decks \
release/Magarena/sounds \
release/Magarena/scripts \
2011-05-29 18:51:10 -07:00
Magarena-1.$* /Magarena
2011-05-29 19:04:45 -07:00
cp \
2011-11-17 17:38:37 -08:00
release/Magarena/mods/felt_theme.zip \
release/Magarena/mods/*.txt \
2011-05-29 19:04:45 -07:00
Magarena-1.$* /Magarena/mods
2011-05-29 18:51:10 -07:00
-zip -r Magarena-1.$* .zip Magarena-1.$*
2011-10-28 05:27:43 -07:00
cp -r Magarena.app Magarena-1.$* .app
cd Magarena-1.$* .app/Contents/Resources; ln -s ../../../Magarena-1.$* Java
chmod a+x Magarena-1.$* .app/Contents/MacOS/JavaApplicationStub
2012-06-14 03:26:36 -07:00
-zip -r Magarena-1.$* .app.zip Magarena-1.$* .app
2011-05-27 00:34:47 -07:00
2012-06-14 03:26:36 -07:00
$(MAG) : $( SRC )
2012-01-27 18:08:39 -08:00
ant -f build.xml
2011-05-22 19:52:01 -07:00
2011-06-10 06:43:32 -07:00
class : $( BUILD ) /javac .last
2012-06-14 03:26:36 -07:00
tags : $( SRC )
2012-03-10 01:59:23 -08:00
ctags -R src
2011-05-22 19:23:49 -07:00
2012-06-11 07:25:45 -07:00
Test%.run : $( MAG )
2013-04-20 06:39:59 -07:00
$( DEBUG) -DtestGame= Test$* -Dmagarena.dir= ` pwd ` /release -jar $^ 2>& 1 | tee Test$* .log
2011-05-28 00:47:06 -07:00
2011-05-22 19:52:01 -07:00
$(EXE) : $( MAG )
2011-05-24 19:22:08 -07:00
cd launch4j; ./launch4j ../release/magarena.xml
2011-05-22 19:40:28 -07:00
2011-05-22 19:23:49 -07:00
clean :
2011-05-24 20:10:09 -07:00
-ant clean
2012-06-14 03:26:36 -07:00
-rm -f $( BUILD) /javac.last
-rm -f $( MAG)
2011-05-28 00:47:06 -07:00
2012-08-25 07:09:10 -07:00
clean/% : Magarena -%.zip Magarena -%.app .zip
-rm -rf Magarena-$*
-rm -rf Magarena-$* .app
-rm Magarena-$* .zip
-rm Magarena-$* .app.zip
2012-09-22 05:00:36 -07:00
log.clean :
-rm -f *.log
2011-09-18 00:11:27 -07:00
inf : $( MAG )
2012-06-02 18:56:47 -07:00
-while true; do make ` date +%s` .t; done
2011-09-18 00:11:27 -07:00
2013-02-11 20:20:22 -08:00
buildhive :
2013-03-31 04:25:52 -07:00
make games = 100 ai1 = MMABC ai2 = MCTS ` date +%s` .t zips
2013-02-11 20:20:22 -08:00
2013-02-11 17:58:21 -08:00
games ?= 10000
2013-03-09 05:44:47 -08:00
str1 ?= 1
str2 ?= 1
life ?= 10
2013-03-31 04:25:52 -07:00
ai1 ?= MMABC
2013-03-24 05:12:22 -07:00
ai2 ?= MMAB2
2011-09-01 01:35:20 -07:00
%.t : $( MAG )
echo ` hg id -n` > $* .log
2013-04-20 06:39:59 -07:00
$( RUN) -Dmagarena.dir= ` pwd ` /release magic.DeckStrCal \
2012-09-26 18:59:42 -07:00
--seed $* \
2013-03-31 04:25:52 -07:00
--ai1 ${ ai1 } --str1 ${ str1 } \
2013-03-24 05:12:22 -07:00
--ai2 ${ ai2 } --str2 ${ str2 } \
2013-03-09 05:44:47 -08:00
--life ${ life } \
2012-09-26 18:59:42 -07:00
--games 1 \
2013-02-11 17:58:21 -08:00
--repeat ${ games } >> $* .log 2>& 1
2011-07-26 20:36:20 -07:00
2012-04-14 18:10:16 -07:00
test : $( MAG )
2012-06-02 18:56:47 -07:00
-make ` date +%s` .d
2012-04-14 18:10:16 -07:00
2011-06-27 02:16:19 -07:00
%.d : $( MAG )
2013-04-20 06:39:59 -07:00
$( JAVA) -DrndSeed= $* -Dmagarena.dir= ` pwd ` /release -jar $^ | & tee $* .log
2011-06-27 02:16:19 -07:00
2012-07-26 01:42:56 -07:00
# Z = 4.4172 (99.999%)
# E = 0.01
# best estimator for r is p = h / (h + t)
2012-08-05 07:18:42 -07:00
# this estimator has a margin of error E, |p - r| < E at a particular Z, p - E < r < p + E
2012-07-26 01:42:56 -07:00
# n = Z^2 / 4E^2
# = 48780
# ~ 50000
%.str : $( MAG ) release /Magarena /decks /JustRelentlessRats .dec release /Magarena /decks /LSK_G .dec
2013-04-20 06:39:59 -07:00
$( RUN) magic.DeckStrCal --deck1 $( word 2,$^) --deck2 $( word 3,$^) --ai1 $* --ai2 $* --games 50000 > $@
2012-04-14 18:10:16 -07:00
2013-04-21 19:46:51 -07:00
#exp/%.log: $(MAG)
# scripts/evaluate_ai.sh $* > $@
2011-06-01 02:06:18 -07:00
2012-12-08 04:24:31 -08:00
decks/dl :
2012-06-02 02:49:07 -07:00
for i in ` curl http://www.wizards.com/magic/magazine/archive.aspx?tag= dailydeck | grep -o mtg/daily/deck/[ 0-9] * | cut -d'/' -f4` ; do make decks/dd_$$ i.dec; done
2012-07-26 01:51:56 -07:00
for i in ` curl http://www.wizards.com/magic/magazine/archive.aspx?tag= topdeck | grep -o mtg/daily/td/[ 0-9] * | cut -d'/' -f4` ; do make decks/td_$$ i.dec; done
2013-01-18 01:27:34 -08:00
grep "name=" -r release/Magarena/incomplete | sed 's/.*name=/100 /' > decks/with_scripts.dec
2012-07-26 01:51:56 -07:00
2013-02-14 22:23:42 -08:00
decks/with_scripts.dec : $( wildcard release /Magarena /incomplete /*.txt )
cat release/Magarena/incomplete/*.txt | grep "name=" | sed 's/.*name=//;s/^/100 /' | sort > $@
2012-10-07 03:02:50 -07:00
%.fix_date :
touch $* -d " `cat $* | head -2 | tail -1 | sed 's/# //'` "
2012-07-26 01:51:56 -07:00
# Daily Deck
2012-10-06 03:42:23 -07:00
decks/dd_%.dec :
curl " http://www.wizards.com/Magic/Magazine/Article.aspx?x=mtg/daily/deck/ $* " | awk -f scripts/dailyhtml2dec.awk > $@
make $@ .fix_date
2011-06-18 08:42:56 -07:00
2012-07-26 01:51:56 -07:00
# Top Decks
2012-10-06 03:42:23 -07:00
decks/td_%.dec :
curl http://www.wizards.com/Magic/Magazine/Article.aspx?x= mtg/daily/td/$* | awk -f scripts/dailyhtml2dec.awk > $@
make $@ .fix_date
# Mike Flores
decks/mf_%.dec :
curl http://www.wizards.com/Magic/Magazine/Article.aspx?x= mtgcom/daily/mf$* | awk -f scripts/dailyhtml2dec.awk > $@
make $@ .fix_date
2011-06-19 23:06:10 -07:00
2013-02-14 21:45:23 -08:00
# Decks from magic-league.com
2012-07-26 01:51:56 -07:00
decks/ml_%.dec : scripts /apprentice 2dec .awk
wget " http://www.magic-league.com/decks/download.php?deck= $* &index=1 " -O - | flip -u - | awk -f $^ > $@
2013-02-14 21:45:23 -08:00
# Decks from www.mtgtop8.com
decks/mtgtop8_%.dec :
2013-02-14 22:23:42 -08:00
wget " http://www.mtgtop8.com/export_files/deck $* .mwDeck " -O $@
2013-02-14 21:45:23 -08:00
2011-06-19 23:06:10 -07:00
ref/rules.txt :
2012-12-08 04:24:31 -08:00
curl ` wget http://www.wizards.com/magic/rules -O - | grep txt | cut -d'"' -f4` | fmt -s > $@
2011-06-19 23:06:10 -07:00
flip -u $@
2011-06-20 18:58:22 -07:00
resources/magic/data/icons/missing_card.png :
2011-06-20 19:27:14 -07:00
convert -background gray -bordercolor black -border 5x5 -size 302x435 \
-pointsize 30 label:'\nNo card image found\n\nSelect\n\"Download images\"\nfrom Arena menu\n\nOR\n\nSwitch to text mode\nusing the Enter key' $@
2011-06-22 19:02:22 -07:00
2011-11-18 19:30:04 -08:00
release/Magarena/mods/%_theme.zip : release /Magarena /mods /%_theme
2011-06-22 19:02:22 -07:00
zip -j $@ $^/*
2011-06-24 00:01:27 -07:00
cards/evan_cube.txt :
curl http://www.cubedrafting.com/view-the-cube/ | grep jTip | sed "s/<[^>]*>//g;s/\&\#8217;/'/" > $@
cards/brett_cube.txt :
curl http://www.snazzorama.com/magic/cube/ | grep ":WizardsAutoCard" | sed "s/<\/td>.*//;s/<[^>]*>//g;s/\&\#8217;/'/" > $@
2011-06-28 19:05:50 -07:00
2011-06-28 20:07:08 -07:00
cards/tom_cube.txt :
wget -O - http://www.tomlapille.com/cube/tom_list.html | sed 's/<[^>]*>//g;s/^[ ]*//g;/^$$/d' > $@
cards/adam_cube.txt :
wget -O - http://www.tomlapille.com/cube/adam_list.html | sed 's/<[^>]*>//g;s/^[ ]*//g;/^$$/d' > $@
cards/AWinnarIsYou_cube.txt :
wget -O - http://www.tomlapille.com/cube/winnar_list.html | sed 's/<[^>]*>//g;s/^[ ]*//g;/^$$/d' > $@
2011-06-28 19:05:50 -07:00
2012-03-13 01:13:52 -07:00
cards/mtgo_cube.txt :
wget -O - https://www.wizards.com/magic/magazine/article.aspx?x= mtg/daily/arcana/927 | grep autoCard | sed 's/<[^<]*>//g;s/^[ ]*//g' > $@
2012-07-05 00:53:36 -07:00
cards/mtgo_cube2.txt :
wget -O - https://www.wizards.com/magic/magazine/article.aspx?x= mtg/daily/other/07032012d | grep autoCard | sed 's/<[^<]*>//g;s/^[ ]*//g' > $@
2011-06-28 19:05:50 -07:00
daily : $( EXE )
mv $^ Magarena_` hg id -n` .exe
2011-07-31 20:38:47 -07:00
scripts/googlecode_upload.py \
-s "build `hg id -n`" \
-p magarena \
-u melvinzhang@gmail.com \
-w ` cat ~/Modules/notes/keys/googlecode_pw.txt` \
2012-02-25 19:09:22 -08:00
-l Deprecated \
2011-07-31 20:38:47 -07:00
Magarena_` hg id -n` .exe
2011-07-01 00:39:22 -07:00
2012-08-25 06:14:05 -07:00
upload/% : Magarena -%.zip Magarena -%.app .zip
2012-07-28 22:52:49 -07:00
make upload/Magarena-$* .app.zip
make upload/Magarena-$* .zip
upload/Magarena-%.app.zip : Magarena -%.app .zip
2012-02-25 06:54:08 -08:00
scripts/googlecode_upload.py \
-p magarena \
-u melvinzhang@gmail.com \
-w ` cat ~/Modules/notes/keys/googlecode_pw.txt` \
2012-07-28 22:48:46 -07:00
-s " Magarena $* (Mac) " \
2012-02-25 06:54:08 -08:00
-l Featured,Type-Installer,OpSys-OSX \
2012-07-28 22:52:49 -07:00
$^
2012-02-25 06:54:08 -08:00
2012-07-28 22:52:49 -07:00
upload/Magarena-%.zip : Magarena -%.zip
2012-02-25 06:54:08 -08:00
scripts/googlecode_upload.py \
-p magarena \
-u melvinzhang@gmail.com \
-w ` cat ~/Modules/notes/keys/googlecode_pw.txt` \
2012-07-28 22:48:46 -07:00
-s " Magarena $* " \
2012-02-25 06:54:08 -08:00
-l Featured,Type-Archive,OpSys-Linux,OpSys-Windows \
2012-07-28 22:52:49 -07:00
$^
2012-02-25 06:54:08 -08:00
2011-10-26 20:06:12 -07:00
%.up : %
scripts/googlecode_upload.py \
-p magarena \
-u melvinzhang@gmail.com \
-w ` cat ~/Modules/notes/keys/googlecode_pw.txt` \
2012-07-28 22:48:46 -07:00
-s " $^ " \
2011-10-26 20:06:12 -07:00
$^
2011-07-10 20:02:02 -07:00
cards/scriptable.txt : scripts /analyze_cards .scala scripts /effects .txt cards /cards .xml
2012-03-25 00:05:43 -07:00
scala $^ > $@
2011-07-18 20:01:09 -07:00
2012-10-28 03:41:13 -07:00
grammar/rules.txt : scripts /normalize_rules .scala scripts /effects .txt cards /cards .xml
scala $^ > $@
2012-04-09 07:08:23 -07:00
cards/magicdraftsim-sets :
curl www.magicdraftsim.com/card-ratings | \
grep Kamigawa | \
head -1 | \
sed 's/value=/\n/g' | \
sed 's/<.*//' | \
cut -d\' -f2 | \
sed '/^$$/d' > $@
cards/magicdraftsim-rating : cards /magicdraftsim -sets
2011-07-18 20:01:09 -07:00
for i in ` cat $^` ; do \
curl http://www.magicdraftsim.com/card-ratings/$$ i | \
2012-03-03 08:40:47 -08:00
pandoc -f html -t plain | \
grep "^[ ]*[0-9]" | \
sed " s/^[ ]*[0-9]*/ $$ i/;s/[ ][ ][ ]*/\t/g " ; \
2011-07-18 20:01:09 -07:00
done > $@
2011-07-28 19:44:02 -07:00
2011-08-08 01:50:36 -07:00
cards/current-magic-excel.txt :
wget http://www.magictraders.com/pricelists/current-magic-excel.txt -O $@
2011-08-09 21:50:25 -07:00
2011-12-03 08:10:08 -08:00
up :
hg pull -u
cd wiki; hg pull -u; cd ..
2012-03-10 22:22:11 -08:00
2012-03-11 08:12:49 -07:00
code_clones :
2012-03-21 23:39:47 -07:00
~/App/pmd-bin-5.0-alpha/bin/run.sh cpd \
--minimum-tokens 100 \
--ignore-literals true \
--ignore-identifiers true \
--language java \
--files src/magic/card > $@
2012-04-09 07:14:14 -07:00
2012-04-27 20:16:31 -07:00
cards/mtg-data :
2012-07-26 01:42:56 -07:00
curl https://dl.dropbox.com/u/2771470/index.html | grep -o 'href="mtg.*.zip' | head -1 | sed 's/href="//' | xargs -I'{}' wget https://dl.dropbox.com/u/2771470/'{}'
unzip -j mtg-data*.zip -d cards
rm mtg-data*.zip
2012-04-27 20:16:31 -07:00
2012-04-09 07:14:14 -07:00
github/push :
hg gexport
git push origin master
2012-05-19 23:12:56 -07:00
unique_property :
grep "=" release/Magarena/scripts/*.txt| cut -d'=' -f1 | sort | uniq -c | sort -n
2012-05-21 22:08:09 -07:00
2013-02-14 22:23:42 -08:00
cards/scored_by_dec.tsv : cards /existing_tip .txt cards /unimplementable .tsv $( wildcard decks /*.dec )
2013-02-14 21:45:23 -08:00
./scripts/score_card.awk decks/*.dec | \
2012-05-23 07:18:41 -07:00
sort -rg | \
2013-02-14 22:23:42 -08:00
./scripts/keep_unimplemented.awk $( word 1,$^) /dev/stdin | \
./scripts/keep_unimplemented.awk <( cut -f1 $( word 2,$^) ) /dev/stdin > $@
2012-06-28 23:09:40 -07:00
cards/mtg_mana_costs :
grep -ho "\(\{[^\}]\+\}\)\+" -r cards/cards.xml | sort | uniq > $@
cards/mag_mana_costs :
grep -ho "\(\{[^\}]\+\}\)\+" -r src/magic/model/MagicManaCost.java release/Magarena/scripts | sort | uniq > $@
cards/mana_cost_graph.dot : cards /mtg_mana_costs
cat $^ | \
sed 's/{X}//g;s/{[[:digit:]]*}//g;s/{[CPQT]*}//g;/^$$/d' | \
awk -f scripts/mana_cost_graph.awk > $@
cards/mana_cost_graph.png : cards /mana_cost_graph .dot
circo $^ -Tpng -o $@
verify_mana_cost_order : cards /mtg_mana_costs cards /mag_mana_costs
join -v2 $^
2012-08-08 23:38:06 -07:00
2012-08-10 18:40:55 -07:00
%.update_value : %
if grep token = $^; then \
echo "ERROR: Not applicable to tokens" ; \
else \
name = $$ ( grep name = $^ | sed 's/name=//' | sed 's/ /%20/g' ) ; \
value = $$ ( curl -sL http://gatherer.wizards.com/pages/card/details.aspx?name= $$ name | grep "textRatingValue" | grep -o "[0-9]\.[^<]*" ) ; \
sed -i " s/value=.*/value= $$ value/ " $^; \
fi \
2012-08-18 18:05:00 -07:00
%.normalize : %
flip -u $^
make $^.update_value
vim $^
hg add $^
2012-09-07 21:18:30 -07:00
2012-10-25 19:07:13 -07:00
find_event_data : scripts /check_data .awk
2012-10-06 18:37:34 -07:00
for i in ` grep "new MagicEvent(" -lr src` ; do \
2012-09-08 19:52:21 -07:00
grep "new Object\|data\[[0-9\]" $$ i > /dev/null && echo $$ i; \
2012-09-08 19:24:29 -07:00
grep "new Object\|data\[[0-9\]" $$ i | awk -f $^ | sed 's/ //g' | sed 's/:/:\t/' ; \
done > $@
2012-09-07 21:18:30 -07:00
flip -u $@
2012-09-08 19:52:21 -07:00
2012-10-25 19:07:13 -07:00
find_literals :
grep "\"" src/magic/card/* | awk -f scripts/check_literals.awk
2012-10-26 04:34:55 -07:00
find_single_line_card_code : $( MAG )
cat src/magic/card/*.java | sed 's/\s\+//g' | sed 's/(.*)/(...)/g' | sort | uniq -c | sort -n | grep publicstaticfinal | grep ");" > $@
find_casts : $( MAG )
2012-10-26 18:17:58 -07:00
grep -n "([A-Za-z<>]\+)[A-Za-z]\+" -r src/ > $@
2012-10-26 04:34:55 -07:00
flip -u $@
find_nulls : $( MAG )
grep -n "null" -r src/ > $@
flip -u $@
2012-10-25 19:07:13 -07:00
# meta check
2013-02-15 18:28:06 -08:00
checks : check_aura check_requires_card_code check_requires_groovy_code check_script_name check_unique_key
2012-10-25 19:07:13 -07:00
2012-09-22 05:00:36 -07:00
# every aura must have an enchant property
check_aura :
2012-10-07 03:02:50 -07:00
diff \
<( grep "subtype.*Aura" -lr release/Magarena/scripts | sort) \
<( grep enchant = -lr release/Magarena/scripts | sort)
2012-09-29 08:56:38 -07:00
# every card that requires card code has a corresponding card class
# every card class has a corresponding card script that requires card code
check_requires_card_code :
diff \
<( ls -1 src/magic/card/*.java | cut -d'/' -f 4 | sed 's/.java//' | sort) \
2013-03-11 07:04:38 -07:00
<( grep requires_card_code -r release/Magarena/scripts/ | sed 's/.*=//' | sed 's/,\([^ ]\)/\n\1/' | sed 's/.*scripts\///;s/.txt.*//' | sed 's/[^A-Za-z0-9]/_/g' | sort | uniq)
2012-09-29 08:56:38 -07:00
2013-01-12 18:14:58 -08:00
# every card that requires groovy code has a corresponding groovy script file
# every groovy script file has a corresponding card script that requires groovy code
check_requires_groovy_code :
diff \
<( ls -1 release/Magarena/scripts/*.groovy | cut -d'/' -f 4 | sed 's/.groovy//' | sort) \
2013-03-11 07:04:38 -07:00
<( grep requires_groovy_code -r release/Magarena/scripts/ | sed 's/.*=//' | sed 's/,\([^ ]\)/\n\1/' | sed 's/.*scripts\///;s/.txt.*//' | sed 's/[^A-Za-z0-9]/_/g' | sort | uniq)
2013-01-12 18:14:58 -08:00
2012-10-30 02:50:30 -07:00
# script name is canonical card name
2012-10-06 00:44:55 -07:00
check_script_name :
2012-10-05 19:01:02 -07:00
diff \
2013-01-12 18:14:58 -08:00
<( ls -1 release/Magarena/scripts/ | grep txt | sort) \
2012-10-06 00:44:55 -07:00
<( grep "name=" -r release/Magarena/scripts/ | sort | sed 's/.*name=//;s/[^A-Za-z0-9]/_/g;s/$$/.txt/' )
2012-10-05 19:01:02 -07:00
2012-12-31 00:29:21 -08:00
check_unique_key :
2013-02-14 06:34:05 -08:00
grep "^[^ ]*=" -r release/Magarena/scripts | sed 's/=.*//g' | sort | uniq -d
2012-12-31 00:29:21 -08:00
2012-09-29 20:20:52 -07:00
crash.txt : $( wildcard *.log )
for i in ` grep "^Excep" -l $^` ; do \
tail -n +` grep -n "random seed" $$ i | tail -1 | cut -d':' -f1` $$ i; \
2012-09-30 23:59:46 -07:00
done >> $@
2012-11-19 23:40:16 -08:00
rm $^
2012-10-26 21:57:23 -07:00
support/ui :
for i in src/$@ /*.java; do wget https://cakehat.googlecode.com/svn/trunk/$$ i -O $$ i; done
2012-10-27 02:17:53 -07:00
wiki/UpcomingCards.wiki : cards /new .txt
echo "#summary New cards in the next release" > $@
2012-10-27 02:21:38 -07:00
cat <( echo "{{{" ) $^ <( echo "}}}" ) >> $@
2012-12-12 22:12:53 -08:00
2012-12-14 19:37:52 -08:00
parser/test : $( MAG )
2013-04-20 06:39:59 -07:00
$( RUN) magic.grammar.Check < grammar/parsable.txt
2012-12-12 22:12:53 -08:00
parser/test_all : $( MAG ) grammar /rules .txt
2013-04-20 06:39:59 -07:00
$( RUN) magic.grammar.Check < $( word 2,$^)
2012-12-12 22:12:53 -08:00
parser/run : $( MAG )
2013-04-20 06:39:59 -07:00
$( RUN) magic.grammar.Check
2012-12-12 22:12:53 -08:00
2013-02-12 20:30:51 -08:00
grammar/parsable.txt : src /magic /grammar /MagicRuleParser .java
2012-12-12 22:12:53 -08:00
make parser/test_all > grammar/test_all.out
cat grammar/test_all.out | grep PARSED | sed 's/PARSED: //' | sort | uniq > $@
cat grammar/test_all.out | grep FAILED | sort | uniq -c | sort -n > grammar/failed.txt
src/magic/grammar/MagicRuleParser.java : grammar /mtg .peg
java -cp lib/Mouse-1.5.1.jar mouse.Generate -M -G $^ -P MagicRuleParser -S MagicSyntaxTree -p magic.grammar -r magic.grammar
mv MagicRuleParser.java $@
sed -i 's/accept()/sem.action() \&\& accept()/g' $@
grammar/CounterType : grammar /rules .txt
grep -o "[^ ]* counter \(on\|from\)" $@ | cut -d' ' -f1 | sort | uniq > $@
# remove a, each, that
# add poison
2012-12-27 19:08:26 -08:00
2013-01-06 21:30:38 -08:00
fix_eol :
2013-01-07 05:58:53 -08:00
sed -i -e '$$a\' release/Magarena/**/*.txt
sed -i -e 's/\x0D$$//' release/Magarena/**/*.txt
2012-12-27 19:08:26 -08:00
sed -i -e '$$a\' src/**/*.java
2013-03-07 06:58:14 -08:00
2013-03-07 19:05:46 -08:00
cards/cards_per_set.tsv : cards /existing_tip_full .txt
2013-03-07 06:58:14 -08:00
cat <( grep -o ", [A-Z0-9]* [A-Z]" $^ | cut -d' ' -f2) \
2013-03-07 19:05:46 -08:00
<( grep -o "^[A-Z0-9]* [A-Z]" $^ | cut -d' ' -f1) \
| sort \
| uniq -c \
| sort -n \
| sed 's/^ *//g;s/ /\t/' \
> $@
2013-03-13 05:52:31 -07:00
2013-03-13 06:30:59 -07:00
smallest.convert :
make ` ls -1S src/magic/card | grep java | sed 's/.java//' | tail -1` .convert
2013-03-13 05:52:31 -07:00
%.convert :
2013-03-13 05:55:53 -07:00
hg mv src/magic/card/$* .java release/Magarena/scripts/$* .groovy
vim release/Magarena/scripts/$* .groovy
sed -i 's/card_/groovy_/' release/Magarena/scripts/$* .txt
2013-03-13 05:52:31 -07:00
hg commit -m "convert from java code to groovy code"
2013-03-13 06:30:59 -07:00
2013-04-16 01:51:33 -07:00
ai/benchmark.rnd :
2013-04-19 19:19:03 -07:00
sort -R exp/AIs.txt > exp/rnd.txt
2013-04-16 01:52:02 -07:00
ts make games = 10 life = 20 \
2013-04-16 01:51:33 -07:00
ai1 = ` cat exp/rnd.txt | tail -1` \
str1 = ` sort -R exp/STRs.txt | tail -1` \
ai2 = ` cat exp/rnd.txt | tac | tail -1` \
str2 = ` sort -R exp/STRs.txt | tail -1` \
2013-04-21 19:46:51 -07:00
` date +%s` .t
ts make ai/benchmark.rnd
2013-04-16 01:51:33 -07:00
2013-04-19 19:19:03 -07:00
exp/zermelo.tsv : $( wildcard exp /1366*.log )
awk -f exp/extract_games.awk $^ | ./exp/whr.rb | tac > $@