diff options
author | Gökçen Eraslan <gokcen.eraslan@gmail.com> | 2016-01-06 19:50:21 +0100 |
---|---|---|
committer | Gökçen Eraslan <gokcen.eraslan@gmail.com> | 2016-01-06 19:50:21 +0100 |
commit | dcb66bd8ebe8a4f8ee6605b00af09e8a48ace0ff (patch) | |
tree | 5e5a7aafb12bf65246265b9f6e82f817842898ca /bindings/python | |
parent | df31cc20c63c9447ba057d599d48cc67c4555ca7 (diff) |
Add a SWIG interface file, a Bash script to generate Go, Python and Lua bindings and add Python test file.
Diffstat (limited to 'bindings/python')
-rw-r--r-- | bindings/python/test.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/bindings/python/test.py b/bindings/python/test.py new file mode 100644 index 0000000..a5e2373 --- /dev/null +++ b/bindings/python/test.py @@ -0,0 +1,63 @@ +# coding: utf-8 + +import quackle + +# Set up the data manager +dm = quackle.DataManager() +dm.setComputerPlayers(quackle.ComputerPlayerCollection.fullCollection()) +dm.setBackupLexicon('twl06') +dm.setAppDataDirectory('../../data') + +# Set up the alphabet +abc = quackle.AlphabetParameters.findAlphabetFile('english') +fa = quackle.FlexibleAlphabetParameters() +assert fa.load(quackle.Util.stdStringToQString(abc)) +dm.setAlphabetParameters(fa) + +# Set up the board +board = quackle.BoardParameters() +dm.setBoardParameters(board) + +# Find the lexicon +dawg = quackle.LexiconParameters.findDictionaryFile('twl06.dawg') +gaddag = quackle.LexiconParameters.findDictionaryFile('twl06.gaddag') +dm.lexiconParameters().loadDawg(dawg) +dm.lexiconParameters().loadGaddag(gaddag) + +dm.strategyParameters().initialize('twl06') + +# Create a computer player +player1, found = dm.computerPlayers().playerForName('Speedy Player') +assert found +player1 = player1.computerPlayer() +print player1.name() + +# Create the Game file (.gcg) reader +gamereader = quackle.GCGIO() +game = gamereader.read(quackle.Util.stdStringToQString('../../test/positions/short_game_with_bad_moves.gcg'), + quackle.Logania.MaintainBoardPreparation) + +# Get the current position +position = game.currentPosition() + +player1.setPosition(position) + +racks = quackle.ProbableRackList() +unseenbag = position.unseenBag() +if unseenbag.size() <= dm.parameters().rackSize() + 3: + enum = quackle.Enumerator(unseenbag) + enum.enumerate(racks) + for rack in racks: + print rack + +movesToShow = 10 + +print "Board state: \n%s" % position.board().toString() +print "Move made: %s" % position.moveMade().toString() +print "Current player: %s" % position.currentPlayer().storeInformationToString() +print "Turn number: %i" % position.turnNumber() + +movelist = player1.moves(10) + +# Show 10 moves suggested by computer player +for move in movelist: print move.toString() |