tak-ai (empty) → 0.1.0.0
raw patch · 5 files changed
+100/−0 lines, 5 filesdep +HUnitdep +basedep +matrixsetup-changed
Dependencies added: HUnit, base, matrix, parsec, random-shuffle, tak
Files
- LICENSE +17/−0
- Setup.hs +2/−0
- src/takky.hs +15/−0
- src/takkytests.hs +36/−0
- tak-ai.cabal +30/−0
+ LICENSE view
@@ -0,0 +1,17 @@+Copyright (c) 2016, Henry Bucklow+1. Redistributions of source code must retain the above copyright notice, this+ list of conditions and the following disclaimer.+2. Redistributions in binary form must reproduce the above copyright notice,+ this list of conditions and the following disclaimer in the documentation+ and/or other materials provided with the distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/takky.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE TypeFamilies #-}+module Main where++import System.Environment++import PlayTakBot+import TakkyCore++main = do+ args <- getArgs+ if length args /= 2+ then error "usage: takky <username> <password>"+ else return ()+ let username : password : [] = args+ runBot $ Takky username password
+ src/takkytests.hs view
@@ -0,0 +1,36 @@+module Main where++import Test.HUnit+import Text.Parsec++import Tak+import TakkyCore++test_eval :: Test+test_eval = TestCase $ assert $ score < 0.0 where+ score = evaluate (read "O") state+ state = GameState board player player Nothing White 3+ board = read $+ "( OOXOX O O COX CX )\n" +++ "( O OXO SO X XO )\n" +++ "( SOX X XX SO SO )\n" +++ "( SOXO X X X X )\n" +++ "( O X X X X )\n"+ player = Player 1 0++parseMoves :: [String] -> [Play]+parseMoves = map parseMove++parseMove :: String -> Play+parseMove = noParseError . parsePtn++noParseError :: Either ParseError Play -> Play+noParseError (Right play) = play+noParseError (Left err) = error $ show err++tests :: Test+tests = TestList [TestLabel "test_eval" test_eval]++main :: IO Counts+main = do+ runTestTT tests
+ tak-ai.cabal view
@@ -0,0 +1,30 @@+name: tak-ai+version: 0.1.0.0+synopsis: AI(s) for playing Tak on playtak.com+description:+ Takky is a simple bot, using a modest lookahead of 4 plies, and a heuristic+ based purely on territory owned. It hangs around on playtak.com, providing a+ moderate challenge to new and intermediate players.+homepage: http://bitbucket.org/sffubs/tak+license: BSD2+license-file: LICENSE+author: Henry Bucklow+maintainer: henry@elsie.org.uk+-- copyright: +category: Game+build-type: Simple+cabal-version: >=1.8++executable takky+ main-is: takky.hs+ hs-source-dirs: src+ ghc-options: -O2 -threaded "-with-rtsopts=-N"+ build-depends: base < 5, tak, random-shuffle++test-suite takky-tests+ hs-source-dirs: src+ ghc-options: -Wall+ type: exitcode-stdio-1.0+ main-is: takkytests.hs+ build-depends: base < 5, tak, random-shuffle, HUnit, matrix, parsec+