SoccerFun 0.4.2 → 0.4.3
raw patch · 5 files changed
+78/−9 lines, 5 files
Files
- SoccerFun.cabal +4/−2
- SoccerFun/MatchGame.hs +11/−7
- tournament/Makefile +19/−0
- tournament/makeAll.sh +38/−0
- tournament/makeLoop.sh +6/−0
SoccerFun.cabal view
@@ -1,5 +1,5 @@ Name: SoccerFun-Version: 0.4.2+Version: 0.4.3 Copyright: (c) 2010, Jan Rochel License: BSD3 License-File: LICENSE@@ -13,7 +13,9 @@ This is a Haskell port of the the SoccerFun framework originally implemented in Clean. From the website: Soccer-Fun is an educational project to stimulate functional programming by thinking about, designing, implementing, running, and competing with the brains of football players! It is open for participation by everybody who likes to contribute. It is not restricted to a particular functional programming language. Category: Game, Education, AI Cabal-Version: >= 1.6-Data-Files: template/Main.hs template/Makefile template/Children/Child.hs template/Children/Team.hs+Data-Files:+ template/Main.hs template/Makefile template/Children/Child.hs template/Children/Team.hs+ tournament/makeAll.sh tournament/makeLoop.sh tournament/Makefile Library Extensions:
SoccerFun/MatchGame.hs view
@@ -71,12 +71,11 @@ let (loc,name) = case findIndices isSlash t of [ ] → (".", t) ixs → let (loc,slash:name) = splitAt (last ixs) t in (loc, name)- waitForProcess =<< runProcess "ghc" ["--make", name ⧺ ".Team"] (Just loc) Nothing Nothing Nothing Nothing- oldLoc ← getCurrentDirectory- setCurrentDirectory loc- putStrLn $ "Loading module " ⧺ name ⧺ ".Team from " ⧺ loc- team ← eval_ (name ⧺ ".Team.team") [name ⧺ ".Team"] [] [] [loc] -- the [loc] doesn't seem to have any effect- setCurrentDirectory oldLoc+ team ← inDir loc $ do+ exitCode ← waitForProcess =<< runProcess "ghc" ["--make", "-v0", name ⧺ ".Team"] (Just ".") Nothing Nothing Nothing Nothing+ if exitCode ≢ ExitSuccess+ then return $ Left ["Teams could not be compiled"]+ else eval_ (name ⧺ ".Team.team") [name ⧺ ".Team"] [] [] [loc] -- the [loc] doesn't seem to have any effect case team of Left errors → mapM_ putStrLn ("Failed to load team. Errors:" : errors) >> exitFailure Right Nothing → do@@ -88,7 +87,12 @@ where removeTrailingSlashes str = if isSlash (last str) then removeTrailingSlashes (init str) else str isSlash = flip elem ['/','\\']-+ inDir dir ioAction = do+ oldDir ← getCurrentDirectory+ setCurrentDirectory dir+ res ← ioAction+ setCurrentDirectory oldDir+ return res {- This module defines the match and tournament data structures. -}
+ tournament/Makefile view
@@ -0,0 +1,19 @@+.SUFFIXES: .log .sft .hs+.PHONY: recordAll record clean++TEAMS=$(notdir $(wildcard teams/*))++recordAll:+ for t1 in $(TEAMS); do for t2 in $(TEAMS); do make TEAM1=$$t1 TEAM2=$$t2 record; done; done++# the rest of the file requires TEAM1 and TEAM2 to be defined++record: teams/$(TEAM1) teams/$(TEAM2) tapes/$(TEAM1)-$(TEAM2).log++tapes/$(TEAM1)-$(TEAM2).log: teams/$(TEAM1)/* teams/$(TEAM2)/*+ ulimit -t 15; sfRecord teams/$(TEAM1) teams/$(TEAM2) > $@ 2>&1+ [ -f $(TEAM1)-$(TEAM2).sft ] && mv $(TEAM1)-$(TEAM2).sft tapes++clean:+ rm -f tapes/*+ rm -f teams/*/*.o teams/*/*.hi
+ tournament/makeAll.sh view
@@ -0,0 +1,38 @@+#!/bin/sh++echo '<html><head><title>SoccerFun Tournament</title></head><body><table>' > out++echo "<tr>" >> out+for i in teams/*; do+ echo "<td>`basename $i`</td>" >> out+done+echo "<td></td>" >> out+echo "</tr>" >> out++for i in teams/*; do+ for j in teams/*; do+ make TEAM1=`basename $i` TEAM2=`basename $j` record+ done;+done++for i in teams/*; do+ echo "<tr>" >> out+ for j in teams/*; do+ game=`basename $i`-`basename $j`+ echo "<td>" >> out+ if [ `stat -c%s "tapes/$game.log"` -lt 10 ]; then+ [ -s tapes/$game.sft ] && echo "<a href=\"$game.sft\">" >> out+ cat "tapes/$game.log" >> out+ [ -s tapes/$game.sft ] && echo "</a>" >> out+ else+ echo "<a href=\"$game.log\">error</a>" >> out+ fi+ echo "</td>" >> out+ done;+ echo "<td>`basename $j`</td>" >> out+ echo "</tr>" >> out+done++echo '</table></title></head><body><table>' >> out++mv out tapes/index.html
+ tournament/makeLoop.sh view
@@ -0,0 +1,6 @@+#!/bin/sh++while ( true ); do+ ./makeAll+ sleep 60+done