From: Neil Smith Date: Fri, 11 Feb 2011 21:33:59 +0000 (+0000) Subject: Initial commit X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;p=trapthecap.git Initial commit --- ae04705730a29691a56f85c2dc9830dbd335d224 diff --git a/.svn/all-wcprops b/.svn/all-wcprops new file mode 100644 index 0000000..a6a60be --- /dev/null +++ b/.svn/all-wcprops @@ -0,0 +1,57 @@ +K 26 +svn:wc:ra_dav:activity-url +V 19 +/svn/njae/!svn/act/ +K 25 +svn:wc:ra_dav:version-url +V 38 +/svn/njae/!svn/ver/68/TrapTheCap/trunk +END +Rakefile +K 25 +svn:wc:ra_dav:version-url +V 47 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/Rakefile +END +ga-trace.log +K 25 +svn:wc:ra_dav:version-url +V 51 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/ga-trace.log +END +main.rb +K 25 +svn:wc:ra_dav:version-url +V 46 +/svn/njae/!svn/ver/26/TrapTheCap/trunk/main.rb +END +run-ga.rb +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/run-ga.rb +END +systemu.rb +K 25 +svn:wc:ra_dav:version-url +V 49 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/systemu.rb +END +player.log +K 25 +svn:wc:ra_dav:version-url +V 49 +/svn/njae/!svn/ver/28/TrapTheCap/trunk/player.log +END +README +K 25 +svn:wc:ra_dav:version-url +V 45 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/README +END +play-one-game.rb +K 25 +svn:wc:ra_dav:version-url +V 55 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/play-one-game.rb +END diff --git a/.svn/dir-prop-base b/.svn/dir-prop-base new file mode 100644 index 0000000..c82adc2 --- /dev/null +++ b/.svn/dir-prop-base @@ -0,0 +1,6 @@ +K 10 +svn:ignore +V 8 +ga-logs + +END diff --git a/.svn/entries b/.svn/entries new file mode 100644 index 0000000..6d12f85 --- /dev/null +++ b/.svn/entries @@ -0,0 +1,138 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk +http://scripts.njae.me.uk/svn/njae + + + +2009-02-19T08:59:38.293071Z +68 +neil +has-props + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +test +dir + +Rakefile +file + + + + +2008-03-25T11:38:01.000000Z +fd234d29a73c0790b21fab1359ff0c85 +2008-03-25T12:46:59.166018Z +23 +neil + +ga-trace.log +file + + + + +2008-04-26T06:22:16.000000Z +f0911009c5915f48433f0b9bd91ea7e1 +2008-10-16T14:11:23.436422Z +41 + +doc +dir + +lib +dir + +nbproject +dir + +main.rb +file + + + + +2008-04-18T15:35:11.000000Z +c4856a322f630f35c8e05527e0fbce97 +2008-04-20T14:21:13.331435Z +26 +neil +has-props + +src +dir + +run-ga.rb +file + + + + +2008-04-30T20:59:41.000000Z +4d5288d51bb2f9ec0d588b5b3d39aa07 +2008-10-16T14:11:23.436422Z +41 +neil + +systemu.rb +file + + + + +2008-04-28T10:29:38.000000Z +34516ad09cfc22c8048e8eeff31541ff +2008-10-16T14:11:23.436422Z +41 + +player.log +file + + + +delete +2008-04-25T21:34:04.000000Z +e573a8367dc2985387b98ca742f05158 +2008-04-25T21:36:06.714616Z +28 +neil + +README +file + + + + +2008-03-25T11:38:01.000000Z +e92ee2fd4bcfbe8bdf15c30ef7ee5859 +2008-03-25T12:46:59.166018Z +23 +neil + +play-one-game.rb +file + + + + +2008-04-26T06:49:12.000000Z +62194a9eaa52e5108d15084e78165a0c +2008-10-16T14:11:23.436422Z +41 +neil + diff --git a/.svn/format b/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/.svn/format @@ -0,0 +1 @@ +8 diff --git a/.svn/prop-base/main.rb.svn-base b/.svn/prop-base/main.rb.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/.svn/prop-base/main.rb.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/.svn/text-base/README.svn-base b/.svn/text-base/README.svn-base new file mode 100644 index 0000000..9d4059c --- /dev/null +++ b/.svn/text-base/README.svn-base @@ -0,0 +1,3 @@ +== TrapTheCap + +You should document your project here. diff --git a/.svn/text-base/Rakefile.svn-base b/.svn/text-base/Rakefile.svn-base new file mode 100644 index 0000000..9d6872f --- /dev/null +++ b/.svn/text-base/Rakefile.svn-base @@ -0,0 +1,8 @@ +# +# To change this template, choose Tools | Templates +# and open the template in the editor. + + +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' diff --git a/.svn/text-base/ga-trace.log.svn-base b/.svn/text-base/ga-trace.log.svn-base new file mode 100644 index 0000000..f5fd061 --- /dev/null +++ b/.svn/text-base/ga-trace.log.svn-base @@ -0,0 +1,3298 @@ +Generation number 1 +00000001011100001100 +00000010011110101110 +00000101101001100110 +00001000100001100001 +00001000110111011111 +00001010011010001111 +00001011011101101101 +00001100000011111101 +00001100101101000001 +00001101001111111000 +00001110000011000001 +00001111000011101111 +00010000100111111110 +00010001000100000000 +00010001100010011010 +00010011100101011110 +00010101011000110110 +00010101110001000010 +00010110001011101101 +00010110111001110000 +00010111100001010011 +00010111110010001010 +00011001111111011010 +00011100100110000111 +00011110110011100101 +00100000101100001100 +00100000111110101100 +00100010011111000101 +00100100000100110000 +00100110101110010011 +00100111101000010010 +00101000101001111110 +00101010110101011000 +00101100101001000011 +00101100110011011000 +00101110000010100100 +00101110001010111000 +00101111001000011110 +00101111010000111100 +00101111101000001111 +00110010111100011000 +00110011100001110001 +00110011101001100100 +00110011111011100110 +00110100001010100010 +00110101110001010000 +00111000010100111011 +00111001110100010100 +00111010001011011011 +00111100101010110110 +00111100101111011001 +00111101110011000101 +00111111110100110100 +01000001000001010100 +01000001001111111101 +01000001110101011010 +01000010010111101001 +01000010111000001110 +01000101001001100101 +01000101100111111011 +01000110101001001110 +01000110110011011011 +01000111001100101111 +01000111010001001110 +01001101001011100101 +01001101001110000111 +01001110101001010111 +01001111111110000101 +01010000001011011111 +01010010100001101111 +01010100101110011110 +01010101000010110001 +01010101010110010010 +01010101101111010101 +01010110001101010000 +01010111001111100000 +01010111011101100011 +01011001110110110100 +01011100001010110001 +01011100110100000101 +01011101010010010010 +01011110111001010010 +01011111011000000001 +01100000001110100011 +01100000110001111110 +01100001101000100111 +01100010010011101111 +01100010010111000111 +01100010110110101011 +01100100110000100010 +01100101000000101100 +01100101110000000001 +01101010010001001100 +01101010101110101001 +01101011011011001100 +01101100010110000011 +01101101010001111111 +01101101011111110011 +01101111110010110001 +01110001110010101111 +01110001111110111110 +01110010111110000010 +01110100111011110000 +01110101010000010000 +01110111010001011010 +01111000110010000111 +01111001000001000100 +01111001000100010001 +01111001010011010010 +01111011101111110101 +01111111001111110110 +10000010111110000100 +10000101100010100100 +10000110111110100010 +10000111010010110011 +10001010101111001110 +10001100101011000010 +10001101001010001110 +10001111010010001011 +10010001011101011011 +10010010100000100110 +10010010110000010101 +10010100110100101111 +10010110101111110111 +10010110110001001011 +10010111111100011110 +10011000000100011111 +10011010011100010111 +10011100011111000100 +10011110101010100011 +10011110111011100001 +10011111010001000100 +10100000000100001111 +10100000001100101000 +10100010110111001010 +10100011001111111111 +10100100010100110101 +10100110100011010000 +10101001110111000100 +10101010010010100110 +10101100000001111101 +10101101111101101000 +10101110110001011000 +10110000111100111000 +10110010100110110010 +10110011011111011101 +10110011011111100000 +10110101001100010111 +10110101110001111100 +10110111011001010100 +10111000100001111100 +10111100010010111011 +10111100111000100010 +10111101000001100111 +10111101110000101010 +10111101111000111011 +10111111000110001011 +11000001001000101111 +11000010011100111101 +11000010110010110101 +11000011001111011011 +11000100111111011110 +11000101011011110010 +11001000011010000110 +11001000100110011110 +11001001011110011101 +11001010100011011100 +11001011011111110101 +11001011101010110010 +11001111110110010011 +11010000001110101110 +11010000010111110000 +11010000111010101010 +11010001000000101110 +11010001100000010110 +11010001110111100001 +11010010101000000100 +11010011010000100101 +11010011100100111111 +11010101010001100110 +11010110011000001110 +11011001011100110101 +11011010000010010010 +11011101111110110010 +11100011101001110001 +11100100000110011001 +11100101011001010000 +11100111000101011010 +11101011010000101101 +11101101111010111100 +11110000000011001100 +11110100001010011010 +11110101111000001001 +11110110001010000101 +11110110011100111011 +11110110110100101111 +11110111001001111111 +11111010001101011101 +11111011101011111011 +11111111011111000000 +Started at Fri Apr 25 22:39:39 +0100 2008 +Took 1598.862926 seconds +Generation number 2 +00000100101001100110 +00000101100010101100 +00000101101001101100 +00000101111001010100 +00001000101001110110 +00001010001010001111 +00001010011001000011 +00001010011110001111 +00001011011101101101 +00001100000011110110 +00001100010110000010 +00001100101000001111 +00001100101101111000 +00001111001111111111 +00010000110010000101 +00010001000000000000 +00010001001100010000 +00010001010100000100 +00010001100101011110 +00010001110110011010 +00010010100000100111 +00010010110111111001 +00010011100001110001 +00010100100010001010 +00010100111001001100 +00010101010110101111 +00010110111000001010 +00100000111110101100 +00100001110100010100 +00100010111110000000 +00100010111110000100 +00100100000100110000 +00100100000100110000 +00100100000100110101 +00100100110100100010 +00100110111110100010 +00101010110101111000 +00101100110001110100 +00101100110011011000 +00101100110011011001 +00101101110011010101 +00101110000101010000 +00101110001000111010 +00101110001010011001 +00101110001010110110 +00101110010001001100 +00101110101010010010 +00101111001000011110 +00101111001010111110 +00110011101111010101 +00110100001010011011 +00110100100011101100 +00110110001101011101 +00110111101110110010 +00110111110011110001 +00110111110100110100 +00111000010100111011 +00111000010110000011 +00111000100001111100 +00111000101100001100 +00111001110100000010 +00111010001011011011 +00111100001011100111 +00111100101011000011 +00111101100100011110 +00111101101010100001 +00111110110011010011 +00111110111111100001 +00111111110100110100 +01000001011000110110 +01000010101011011101 +01000010111000010101 +01000010111000011110 +01000101110110010010 +01000110001001001010 +01000111010001100001 +01000111100001000011 +01001000100001101010 +01001000110100000100 +01001100001110000111 +01001100101111011000 +01010000000001101111 +01010001000010011010 +01010010110101011100 +01010100001111011111 +01010101110001100101 +01010101111000001001 +01010111011010110001 +01010111011101100011 +01010111011111000000 +01010111100101011111 +01010111110001000100 +01010111111100000001 +01011011011000000110 +01011100100011110010 +01011100110100010101 +01011110111001010010 +01011111001111100100 +01011111011001000011 +01100000010001111110 +01100000110000100010 +01100000110110101011 +01100001000000110110 +01100001101100101111 +01100010001110100011 +01100010011011000010 +01100100000101100000 +01101000000100101011 +01101010101110101001 +01101011101111110101 +01101101010011111111 +01110000100111111010 +01110001110010101111 +01110001111111011110 +01110100111110000110 +01110111010001011010 +01111000100111111110 +01111010011011000111 +01111100101010111110 +01111111001111111101 +01111111010110001010 +10000010110111001010 +10000101100010100110 +10000110101011001100 +10001010101111000010 +10001010111010100001 +10001011101010110010 +10001100001000110001 +10001101010010001011 +10001110000011000001 +10001111010100100101 +10001111010100111100 +10010001001000010110 +10010001100010100100 +10010010110001110101 +10010010110100010001 +10010110110001001011 +10010110111110010011 +10011101110011000001 +10011110111010100011 +10011110111011001110 +10011110111011100000 +10011110111011100000 +10011110111011100001 +10011111010001110100 +10100000001100101000 +10100000001100101010 +10100100010100110111 +10100110011000000110 +10100110100011010000 +10101001110101000000 +10101001110111000101 +10101110001010111000 +10101111010000111100 +10110000111100111000 +10110001011111111000 +10110010111100011000 +10110011011111110001 +10110011111011000110 +10110110101110010011 +10111000011000001110 +10111001110110011100 +10111011010111010011 +10111111110100101010 +11000001011111110000 +11000001101000101111 +11000010010111111001 +11000100111111011111 +11000101011010110010 +11000101111011111011 +11000111010010110011 +11001001011110010111 +11001001011110011101 +11001111110110010010 +11001111110110010011 +11010001100000010110 +11010001100000010110 +11010010110001011100 +11010011100100111011 +11010111110011110101 +11011010000001000011 +11011101111110110010 +11100011001001100001 +11100100000110011001 +11100111000101011000 +11100111000101011010 +11100111101000110010 +11101010010010100110 +11101011010001101101 +11110000000011000000 +11110000000111001100 +11110001110001010000 +11110101111010101001 +11110110001000000001 +11110110001101010001 +11110110011100111011 +11110111001001111111 +11111000001110011111 +11111000010100111011 +11111000101001011110 +Started at Fri Apr 25 23:06:18 +0100 2008 +Took 1684.749211 seconds +Generation number 3 +00000001101000101111 +00000010011100001010 +00000011010001100001 +00000100101000001111 +00000100110100000000 +00000100111111011111 +00000101001001100001 +00000101111001000110 +00000101111001110001 +00001000101010100010 +00001010011001000011 +00001011111011111011 +00001100000110100111 +00001100001000110011 +00001100001010010110 +00001100100000010110 +00001100101000111011 +00001110001010011001 +00010000001011100110 +00010001010110011010 +00010010010111111001 +00010011011111110001 +00010011100001110001 +00010011100001110001 +00010011100001110001 +00010011110001010100 +00010100010100011100 +00010100011101010001 +00010100100010001010 +00010100100110010111 +00010101010110000110 +00010101010110101100 +00010101010110101111 +00010111011001000011 +00011001110001010000 +00011100101000101111 +00011101011100101011 +00011110110001000011 +00100000001101010000 +00100000111110101000 +00100010111000010101 +00100010111110110010 +00100100110100100011 +00100100110100100111 +00100100110100101000 +00100100110101110110 +00101000010001110110 +00101010001010011001 +00101010011110001100 +00101010110101110010 +00101100110011010001 +00101101110011010101 +00101101110011010101 +00101110000110010111 +00101110000111010000 +00101110001000101010 +00101110001010111100 +00101110001101011000 +00110011101111010101 +00110011110001011100 +00110011110100110101 +00110100001010011010 +00110100001011011010 +00110100111110000110 +00110110000100000100 +00110110001101011101 +00110111101110110010 +00111000010100111011 +00111000100001011100 +00111000100001111100 +00111000100100010001 +00111000111111011111 +00111001100110100000 +00111001110100000010 +00111001110100100010 +00111010010111010001 +00111100101011011111 +00111101001010101001 +00111110001010110110 +00111110010000111100 +00111110101011011101 +00111110111101100001 +00111111010100101100 +00111111110100110100 +00111111110100110100 +01000000000001101111 +01000001101010101001 +01000010110011110110 +01000010111000000101 +01000100001111010001 +01000100010100110000 +01000101100010101100 +01000110011001001010 +01001000100000101011 +01001000101001011010 +01001000101110011111 +01001000110100000100 +01001010001010011110 +01001010111000011111 +01001100111101011101 +01010000000001101111 +01010010110100010010 +01010011011101101011 +01010101111000001001 +01011000110100000100 +01011011011000000110 +01011100111001001100 +01011101010000001011 +01011110001111100100 +01011111011011100000 +01011111011101100111 +01011111110001100111 +01100000100011101010 +01100001101100101111 +01100010111110000000 +01100011000000110110 +01100100001111100110 +01100101011010111111 +01101011111000011000 +01101100000101110001 +01110000100111111010 +01110000110001010000 +01110000110111101000 +01110110010001011010 +01110110111110110101 +01111010101011011101 +01111111001111011100 +01111111001111111101 +01111111010110001010 +10000010011001011000 +10000010110111001010 +10001001011110011101 +10001100001000100001 +10001101010100111100 +10001101100000010010 +10001110111111101110 +10001111010110100100 +10001111101001101100 +10010000010110000011 +10010000111000111000 +10010000111100110100 +10010001110010101111 +10010010110001111100 +10010010110100010011 +10010101010110101111 +10011111010001101000 +10100000001100101010 +10100100010100110111 +10100110001010011001 +10100110100011010000 +10101001110101000000 +10101111010101110001 +10110000010100111011 +10110001001000010110 +10110010111100011000 +10110110001100001000 +10110110101110000011 +10110110101110110010 +10111001110110011100 +10111011110001011010 +10111011110111011111 +10111101110100101010 +10111110110011010010 +10111110111111100001 +10111111110100101111 +11000001011111110000 +11000001100101011110 +11000100010100111011 +11000100011110001111 +11000100100011100011 +11000101111011001111 +11000111010010110010 +11001001011010001010 +11001011011000000110 +11001101011111010000 +11001110111001010010 +11001111010110000010 +11010011010100100100 +11010101110011110101 +11010111110011110101 +11011001110101111000 +11011101111110000100 +11011110110011010011 +11100100010100110111 +11100101010000110110 +11100101110100011100 +11100111000000111010 +11100111000110100001 +11101111001010111110 +11110000010001101010 +11110011011111110001 +11110100101111011000 +11110110000111101111 +11110110001000001100 +11110110010110101111 +11110111001001110111 +11110111001101111111 +11111000100111111110 +11111111010001100001 +11111111110100110101 +Started at Fri Apr 25 23:34:23 +0100 2008 +Took 1771.991079 seconds +Generation number 4 +00000000110100000000 +00000001101000101100 +00000001111001000111 +00000010011100101111 +00000011010001100001 +00000100011111010010 +00000100100001001111 +00000101010110101111 +00000101100010101100 +00000101111001110001 +00000101111010000110 +00000101111101000011 +00001000001000110010 +00001010011001000000 +00001010101000111011 +00001100000110100111 +00001100000110111110 +00001100001011011010 +00001100101010111101 +00001110010111111001 +00010000001011100110 +00010000010110000011 +00010010110001000011 +00010011100001110001 +00010100011100000001 +00010100011101010010 +00010101010000010010 +00010101010110101100 +00010101011001001000 +00010101111111011111 +00010110000110101001 +00010111010110000110 +00010111011001000011 +00011000110100000100 +00011001100010100000 +00011100100001010111 +00011100101010100110 +00011101011100101011 +00011101011100101011 +00011110110001000011 +00100010010100111011 +00100010111000000101 +00100010111011110010 +00100010111110110000 +00100011101101010101 +00100100001011111010 +00100100110100101000 +00100100110101110110 +00100100110111110110 +00100100111111011111 +00100101110101010101 +00100110110100100011 +00100111001000001101 +00101000110100000100 +00101001110000010110 +00101010011011001100 +00101010011110001000 +00101100110011011110 +00101100111110000110 +00101101110011010001 +00101101110011110110 +00110001010010101111 +00110001110100000010 +00110010001010011001 +00110010011000011101 +00110011101111010101 +00110100001010010110 +00110100111101100110 +00110110000100111011 +00110110001100001000 +00110110001101011101 +00110110001101011101 +00110110011101100011 +00110111101100010000 +00110111111000001001 +00111000100100100000 +00111000110100010101 +00111001100100000010 +00111001100100110100 +00111001100110010001 +00111001100111110001 +00111001110100000010 +00111001111100101000 +00111001111111101110 +00111010010111010001 +00111010010111010101 +00111100100001010100 +00111100100100010001 +00111100101011011111 +00111100101110011000 +00111101001000000100 +00111101101010101001 +00111101110011010101 +00111110001000101010 +00111110010010111101 +00111110011111110001 +01000001111010101101 +01000011010010110010 +01000100010100111011 +01000100100010101100 +01000100101111010001 +01000101100010101100 +01000110010110101110 +01000110011100001010 +01001000010001110110 +01001000101010011111 +01001010001010010101 +01001110101000010110 +01001111001111000010 +01010010110100011000 +01010011001100000100 +01010011011101010001 +01010101010110000110 +01010101111011001111 +01011100111000101100 +01100000000001101111 +01100011000000110100 +01100100000101110001 +01100100001111100110 +01100101001111100110 +01101011111010110010 +01101100000101101011 +01110000100111111010 +01110000100111111010 +01110000110001010000 +01110000110011010100 +01110000110110001000 +01110110000111101111 +01110111010011100001 +01111000100111111011 +01111001110100000010 +01111010101011000101 +01111100001010111100 +01111101001010101001 +01111111110100101111 +10000010011100011010 +10001101100100010000 +10001111011011001111 +10010000010110000011 +10010000111100100000 +10010111010010111111 +10010111100001011100 +10011001011110010001 +10011110110101000000 +10101001000011101000 +10101101101110101111 +10101110011111011000 +10101111010100100001 +10110000010100000100 +10110000010100111011 +10110001001000010110 +10110001001000010110 +10110010111100011000 +10110100111110000110 +10110110000111100000 +10110110010111001010 +10110110101110000011 +10110110101110110010 +10110110101110110010 +10111011110011011010 +10111100101011011111 +10111101001011101011 +11000000000001101010 +11000001100101011110 +11000010101100001100 +11000011010001000001 +11000100001000111000 +11000100010100111011 +11000100011111001111 +11000100111110101000 +11000101111001101100 +11001000101010011111 +11001001110101011000 +11001100011111000000 +11001100100100110110 +11001101011010001011 +11001101011111010100 +11001110111011010001 +11001111010110000010 +11001111010110000010 +11001111100001001111 +11010000110110110000 +11010010110100010000 +11010100101110001100 +11011001110101110010 +11011001111110000100 +11011011011000000110 +11011101101110001100 +11100100001111000110 +11101101110011110101 +11101111001010111110 +11110010001111110000 +11110011010000111100 +11110100101111011000 +11110110010100101110 +11110110101110110010 +11110111000101111111 +11110111101101111111 +11111000100110111110 +11111000100111010110 +Started at Sat Apr 26 00:03:55 +0100 2008 +Took 1879.650283 seconds +Generation number 5 +00000000100111111111 +00000000110100000110 +00000000110100010010 +00000001111000110001 +00000001111110101110 +00000010011100100010 +00000100001011100110 +00000100100100100011 +00000101001010101100 +00000101010100101100 +00000101111010000110 +00001000101010010111 +00001100001011000011 +00001100011011001000 +00001100101010000100 +00001101110011110110 +00001110001010001101 +00010011100101110001 +00010100011011111010 +00010100011100000010 +00010100011101010111 +00010100011101011000 +00010101000110111110 +00010101011001000000 +00010101011001001011 +00010101100001111001 +00010101110111011111 +00010110000110101001 +00010111010110000100 +00010111010110000110 +00010111011001010011 +00011000100100100000 +00011000110100010101 +00011001110010100000 +00011101010100110110 +00011101011100100000 +00011101101010100111 +00011110110001000010 +00011110111111000000 +00100000111110110000 +00100010001010010101 +00100010110100110110 +00100010111011110111 +00100010111111011111 +00100011101111100101 +00100100001101011101 +00100100100100101110 +00100100110101011110 +00100100111110110000 +00100101011010000110 +00100110110100100011 +00100111001001011011 +00101000111010000110 +00101001110000000101 +00101010011110001001 +00101010011110100000 +00101011011101010001 +00101100011111110001 +00101100101010101101 +00101101110011010110 +00110000001100010001 +00110000011111010010 +00110001111100101000 +00110001111110101101 +00110010001010000011 +00110010001010011111 +00110010001100111001 +00110010011010010001 +00110011101111100000 +00110101100100010000 +00110110001110101011 +00110110111000000101 +00110111011010000110 +00110111100001011000 +00110111101100010000 +00110111101100010000 +00111000110000010000 +00111001011100101000 +00111001100100000101 +00111001100110110100 +00111001100111111100 +00111001110100000011 +00111010000011111111 +00111010010111000011 +00111010010111010110 +00111010011100101111 +00111011100101010010 +00111100001010111100 +00111101001000000110 +00111101001010101111 +00111101111110010000 +00111110010010101111 +00111110011111110110 +00111110100001001010 +00111111010011101001 +01000000010100111011 +01000000100001101010 +01000001101101011110 +01000001110101010000 +01000100010101111011 +01000100011101000011 +01000100101010010010 +01000100101111010001 +01000101001111100110 +01000101111101010110 +01000110010110111100 +01000110011100001010 +01000110011100001010 +01000111010110101111 +01001000010001110110 +01001000010001111000 +01001000101010011010 +01001010010001111110 +01001010111000010101 +01001110111110000101 +01001111001111001010 +01001111010000000111 +01001111110100101111 +01010011001100010100 +01010011001100100110 +01010011011101010001 +01010011011110111101 +01010100100011011111 +01010101010110101011 +01010101111011001111 +01010111010101111001 +01011010101000111011 +01011100000101101011 +01100000100111111110 +01100011110000000010 +01100100100010101100 +01100110000111101011 +01101000100111111011 +01101111110100111101 +01110000100101101000 +01110000100111111010 +01110111000111101110 +01111000110100000010 +01111100001010101100 +01111101001000101001 +01111101011010100001 +01111111110100101110 +10000001110011110101 +10000010011001000000 +10000101010100000100 +10000101111001000011 +10001010011100010010 +10001101100100011010 +10001101100101011101 +10001110000101001101 +10001111010110000110 +10010000010101111101 +10010001010010101111 +10010100111100111011 +10101100011111010010 +10101101101110100111 +10101101101110101111 +10101101111100001000 +10110001001100011111 +10110010111100011000 +10110100010100001100 +10110100111110000110 +10110110000111010101 +10110110010111010100 +10110110101110100010 +10110110101111011010 +10111001001000010110 +10111100101111011100 +11000000100101011110 +11000010101001100100 +11000011010001100001 +11000100001000110110 +11000100110010000000 +11000101010110100111 +11000101100010001100 +11001000101000011000 +11001000101010011001 +11001001110101011000 +11001100010001000001 +11001101011111010101 +11001101110101110010 +11001110101110101011 +11001111101001001111 +11010000010110110000 +11010110100100111011 +11011001101000010110 +11011001110101110010 +11011011011110000010 +11100100001111000100 +11100100001111000110 +11101101111001000111 +11101110101100110110 +11101110110010001100 +11101111001010100110 +11110000110001010001 +11110010001111100000 +11110100101111011000 +11110110010100100110 +11111000100111010001 +11111101001011101011 +Started at Sat Apr 26 00:35:15 +0100 2008 +Took 1834.799951 seconds +Generation number 6 +00000000100111111100 +00000000110100000110 +00000000110101111011 +00000001110100100111 +00000010011100100010 +00000010011100100011 +00000100001011100001 +00000100010101111011 +00000101010100001100 +00000101111010000110 +00000101111010001110 +00000110011100001000 +00001000101010100000 +00001011011001010011 +00001100001011000011 +00001100001011001010 +00001100101001100101 +00001100101010000101 +00001110001110001100 +00010000011101010111 +00010011001100010100 +00010100001101111001 +00010100011011111011 +00010101000110000110 +00010101000110111001 +00010101010100100100 +00010110000011101011 +00010110001110101001 +00010110010001010011 +00010111010110111110 +00010111110111111111 +00011000001100010111 +00011000110100010110 +00011001100111111100 +00011001110110100100 +00011010100100011001 +00011100001111000100 +00011100101010111100 +00011101101010100100 +00011110111111000000 +00100010111000000010 +00100010111010111100 +00100011101111100101 +00100100000100110110 +00100100001101001101 +00100100110101011110 +00100101011010000110 +00100101101010000100 +00100110000100110110 +00101000110001110110 +00101000111110110000 +00101001010000000110 +00101010011110000101 +00101010011110001001 +00101011011101010001 +00101100011011000011 +00101100011111110110 +00101100101011011001 +00110001010110111100 +00110001111100101000 +00110001111100101000 +00110001111110100110 +00110010011010010101 +00110011001100001100 +00110100100101100000 +00110101000110101011 +00110101100100010010 +00110101101100010011 +00110110010101101011 +00110111001100010000 +00110111011010010110 +00110111011011000001 +00110111101110110000 +00110111111110010010 +00111001011100101000 +00111001100100000010 +00111001100111111100 +00111001101010010110 +00111010010111010110 +00111100001010111100 +00111100010101111011 +00111100011101011000 +00111101001011110111 +00111101011010000100 +00111110000001001000 +00111110000010101011 +00111110001110110111 +00111110010010101110 +00111110011111110100 +00111111100011001010 +00111111101100010001 +00111111101111111000 +01000000100001101010 +01000001101101011100 +01000001110101010000 +01000001110101011000 +01000001110101111010 +01000010000011111111 +01000100011100000011 +01000100011100001010 +01000100100101011110 +01000100100111111110 +01000100111101001000 +01000101001111100110 +01000101100100010000 +01000110010000011010 +01000110111100101000 +01000111010110101111 +01000111011110001111 +01001000001010011010 +01001000010001000000 +01001000010001111000 +01001010010001000011 +01001010111000010100 +01001100001001111110 +01001101011100100000 +01001101011111010101 +01001101011111110101 +01001110000101001101 +01001110111010000101 +01001110111110000101 +01001111110100110101 +01010000101010101101 +01010011001100010101 +01010011101111101011 +01010101010010101001 +01010101110011011111 +01010101111011001011 +01010101111011011110 +01010110001010011111 +01010111010101111001 +01011010101000111011 +01011111011011001001 +01100001110000100010 +01100010111101011101 +01100011001101101111 +01100101011100100000 +01101000010001111001 +01101111001010100111 +01110000100111111000 +01110010100101101000 +01110010101110111011 +01111000110111110111 +01111100000010101110 +01111100001010101110 +01111100101111011011 +01111101011010110001 +10000100010101111011 +10000100111100000100 +10000101000100101100 +10000101010110000111 +10001010011100010010 +10001010011100101000 +10001011001111001010 +10001111100010000100 +10010000010101111101 +10010001010010101101 +10010100010101111111 +10010110111100000110 +10010111011110000001 +10100110011110010010 +10101100011111010010 +10101101101110010010 +10101111011110111101 +10110000010001111111 +10110010111100011000 +10110100101110101101 +10110100111100111011 +10110110000101010101 +10110110101111011000 +11000000101010011110 +11000001110101011110 +11000010011001000000 +11000010101001100100 +11000100001000110001 +11000101001010001101 +11001000101010011001 +11001001111101011000 +11001100110100000010 +11001101011111010001 +11001101100101011101 +11001110110010111011 +11001111101001001101 +11001111101110101011 +11010000001000110110 +11010011001100000000 +11010101100010001100 +11100100001111000100 +11100100001111010110 +11101010110010000100 +11101111000010100110 +11110000011010000110 +11110100010011101001 +11110100111111011010 +11110111000111000001 +11111000100111010000 +11111000100111010001 +11111000100111010001 +11111001101000011100 +11111010000111000011 +Started at Sat Apr 26 01:05:49 +0100 2008 +Took 1806.325558 seconds +Generation number 7 +00000000100111100000 +00000001110100100111 +00000010011101100011 +00000100000101111010 +00000100100011111110 +00000100110100111100 +00000100110101111001 +00000101010110000111 +00000110001100001000 +00000110010101101000 +00000110011101001000 +00000110110011011111 +00001000011110001000 +00001000100100110110 +00001010011110000101 +00001011011101010011 +00001100001011000011 +00001100011010011010 +00001100100010001100 +00001100100101111110 +00001100101001100101 +00001100101010001000 +00001101101001100101 +00001110001100100100 +00010000011101010110 +00010001100100001010 +00010010001101000000 +00010010101010101101 +00010100011011111011 +00010101010110001100 +00010101011100100100 +00010110010011101011 +00010111010101101000 +00011000010100010110 +00011001110110100100 +00011010100100011001 +00011010101010100111 +00011100101010110100 +00011101101010000100 +00011101101010011000 +00011110111111000000 +00100001011010000110 +00100100001101001101 +00100100101010000101 +00100100101010111011 +00100101111010011010 +00100110000100110111 +00100110001010110000 +00100110111011010110 +00101000111010110000 +00101010011110101101 +00101011011001010011 +00101100011010000010 +00101110111100011000 +00110000001000010110 +00110000010001111001 +00110001010110111010 +00110001101110101011 +00110001111110111001 +00110010011010010101 +00110011001100010101 +00110011001111110001 +00110101000111101011 +00110101010110000111 +00110101100000010010 +00110110010101101011 +00110111001001111011 +00110111011010000110 +00110111101110110000 +00111000001010111100 +00111000010100101100 +00111000010101111011 +00111001000010100110 +00111001010001111001 +00111001101010000100 +00111001101010010110 +00111001101010010110 +00111100010100001100 +00111100010101111011 +00111100011001100100 +00111100011101011000 +00111100011101111001 +00111101101111000100 +00111101101111111000 +00111110000010101011 +00111110011111111100 +00111111100011001010 +00111111101000011101 +00111111101111111001 +01000000100001101010 +01000001101101011100 +01000001110111011000 +01000100100101011101 +01000100100101011110 +01000100101010000101 +01000100110111111110 +01000100111101001000 +01000101111010000110 +01000101111010111100 +01000110011000010011 +01000110101111011011 +01000110111000010100 +01000111011110001111 +01001000001010101010 +01001000111101001010 +01001010111000010100 +01001100101010000101 +01001101010111110101 +01001101011111110111 +01001110000101001101 +01001110011110000100 +01001110111010000101 +01001110111100000001 +01001111001010100111 +01001111110100110101 +01010000010001111111 +01010000101000100101 +01010001010110101101 +01010001110101111010 +01010100000110000110 +01010100100101100000 +01010101010000101110 +01010101010010100010 +01010101010010111010 +01010101110101011000 +01010110011110001101 +01011010000100110110 +01100001110000100011 +01100010111000010000 +01100011101100010101 +01100100000111111110 +01100101001111100011 +01100111001000011111 +01101000010001110000 +01101101000110101011 +01101111000100011001 +01101111001010100111 +01101111001010100111 +01110001100111111100 +01110010101100001000 +01110010101110000001 +01110011001101111111 +01110011101111111011 +01110100110011011111 +01110110111010011101 +01111000000010111011 +01111000010001111001 +01111000010101101000 +01111000110111010010 +01111100001010001110 +01111100100111111110 +01111110001110101011 +01111110101111011011 +10000001010110111100 +10000101000101110011 +10000111100011010000 +10001010011100010001 +10001010011100100100 +10001110111110000101 +10001111010110001111 +10001111100010000100 +10010001010010101101 +10010101111011011110 +10010110010000010001 +10010110111100011101 +10010111011110000000 +10011001110100100111 +10101101101110110110 +10110001010110111100 +10110010001101010101 +10110010010100110000 +10110011001111111000 +10110100101110001001 +10110100101110101101 +10110110000000011100 +10110110111100101100 +10111000101001101101 +10111100001010001100 +11000100010101101011 +11000101001000110101 +11000101010000001100 +11000101010110000111 +11001000101110010110 +11001001111101111000 +11001011011100101000 +11001100100001011110 +11001111101010101110 +11010000001100010110 +11010111011000010110 +11011000010001111000 +11100100000000000010 +11100100001001010110 +11100101011100100000 +11101000100111010000 +11101001101110110000 +11101010110010010110 +11101100001011000010 +11101111100111111100 +11110110111111001010 +11111001101101010101 +Started at Sat Apr 26 01:35:56 +0100 2008 +Took 1893.750235 seconds +Generation number 8 +00000010001101100011 +00000100000110000110 +00000100010110011101 +00000100100011111110 +00000100100101101110 +00000100110000111111 +00000101010110011110 +00000110000010101010 +00000110001100001110 +00000110011001001010 +00000110110011011111 +00001010011010101101 +00001011011101010011 +00001100011101101001 +00001100100001100101 +00001100100101011101 +00001100101000100101 +00001101010110000011 +00001101011111110111 +00001101101001100101 +00001110001000010101 +00001110111010000101 +00001110111010011101 +00001111001010110111 +00010000011101011000 +00010000110101111000 +00010010101010101101 +00010010101011100101 +00010100011101000010 +00010100100001101010 +00010100100110100110 +00010101011100101100 +00010101011100111000 +00010101111011010010 +00010101111011011110 +00010110011100001000 +00010111001000010111 +00010111010000010110 +00011010011100011011 +00011010101100001000 +00011100011111011011 +00011110111101111001 +00011110111111000000 +00011110111111000111 +00011111101111111001 +00100010011111111100 +00100100101001100101 +00100101011101100000 +00100101111010010000 +00100110000100110111 +00100111010101101000 +00101000010001111001 +00101010011110100000 +00101011011001010011 +00101100011010000010 +00101100011010110110 +00101101000110101011 +00101101101000000100 +00110000010010111001 +00110000110001111110 +00110001001111110001 +00110001110010001110 +00110010001001010101 +00110011001100000100 +00110101000111101011 +00110101010110000000 +00110101011010100111 +00110101100000010111 +00110101100001010010 +00110101101000010010 +00110110110011011110 +00110111001001110010 +00110111001001111011 +00110111011010011001 +00111000000010111101 +00111000000110100000 +00111000010100101100 +00111000010101101011 +00111000110111010010 +00111000111000111100 +00111001000010111011 +00111100011101011011 +00111100011111000000 +00111100100101100010 +00111101101111111000 +00111110000011101011 +00111110001101000000 +00111110010010011010 +00111110011010010101 +00111110011111111100 +00111111101010000111 +01000000011011101011 +01000000011101100011 +01000000100001101010 +01000001110000100010 +01000010011101100011 +01000100010101111011 +01000100101010000101 +01000100111010100111 +01000101110110111110 +01000101111010000110 +01000110010101101000 +01001000101011111011 +01001000101101101010 +01001000111101001100 +01001001011111110010 +01001010011000010100 +01001010011110000100 +01001011011100101000 +01001100100101011110 +01001100101010001000 +01001101010100111010 +01001101111010000110 +01001110000101001101 +01001110001010000101 +01001110011010000100 +01001110011110000000 +01001111001111111010 +01001111110100110100 +01010001001110101010 +01010100100101100000 +01010101110001110000 +01010110100101011101 +01010110100101100000 +01011000001100110110 +01011100100111111110 +01011101101000011100 +01011101110110100000 +01011110001010100111 +01100000110111111110 +01100001101111101100 +01100001110001100011 +01100011001100010101 +01100100000010111110 +01100100001010000100 +01100100001101111001 +01100110000100101011 +01100111001010001011 +01101000010001011000 +01101001001010010110 +01101101000100011111 +01101101100110101011 +01101111001010000101 +01101111001010101010 +01110000010100010110 +01110001100101111100 +01110001111111101010 +01110011001001111100 +01110100000111101011 +01110100001000001100 +01110100111010000111 +01110101101110101111 +01110101110011011111 +01110110111010011101 +01111000000001111001 +01111000010001100110 +01111000010001111001 +01111000110111010010 +01111000110111111111 +01111010000101101011 +01111011101010010110 +01111100100111111110 +01111100100111111111 +01111110101101011000 +10000001111110000101 +10000010000011001110 +10001100101010011011 +10001110010110110100 +10010010001100000010 +10010101111011011111 +10010110010000010001 +10010111010111011010 +10010111011110000101 +10011001110100100100 +10110001010110111100 +10110001010110111100 +10110001110110101101 +10110011001010100111 +10110011010110111110 +10110011101111100100 +10110101000111101011 +10110110010101101011 +10111100001010001110 +10111111111100010001 +11000100010100110110 +11000100100111011101 +11000101000010100110 +11001011011100101011 +11001111100011101101 +11010001001100010110 +11010100000101111010 +11010100111011111011 +11010111011000010110 +11101100001011000111 +11101101101110000010 +11110100011000011010 +11110110111110001000 +11111000010001110000 +11111001101101010101 +11111100010101101011 +Started at Sat Apr 26 02:07:30 +0100 2008 +Took 1722.345688 seconds +Generation number 9 +00000100000110000110 +00000100010110000110 +00000100100011101101 +00000100101000100101 +00000101000010111101 +00000101010100000000 +00000101100011111100 +00000110110011011110 +00001000000100111011 +00001010011010111010 +00001011000100101011 +00001011011010011001 +00001011011100000100 +00001100001101101001 +00001100011010000010 +00001100101111011110 +00001101000100000011 +00001101011111111000 +00001101100001100101 +00001110001000010101 +00001110010011011111 +00001110011010111011 +00001110101010000101 +00001110111010000101 +00001111001010110111 +00001111001010111110 +00001111010101010111 +00001111011001111011 +00001111111101111000 +00010000100101100000 +00010001001111110001 +00010001110001100011 +00010010101011000101 +00010010101011100101 +00010010101110101111 +00010100100111001101 +00010100101010011011 +00010100111010000111 +00010101011100101100 +00010101011100111000 +00010101011110101110 +00010111010000010010 +00010111011000010000 +00011010011100011011 +00011100001111011011 +00011100010110100100 +00011110010010001001 +00011110011100000111 +00011110111011000111 +00011110111111000111 +00011110111111011011 +00100011010101101000 +00100100000100000110 +00100101000111101011 +00100101011100100000 +00100101111101100110 +00100111100101111000 +00101000010000111011 +00101000010101111001 +00101000101011111001 +00101001101000010010 +00101100111010011101 +00101101001000111001 +00101101001110101011 +00101111011101010011 +00110000001011110001 +00110000110001111010 +00110001001110110100 +00110001001111110001 +00110001110010001110 +00110011001100000100 +00110100010001110001 +00110100010110011101 +00110100010111000000 +00110100011000011010 +00110101010010111110 +00110101011101111011 +00110110001001010101 +00110110011010001101 +00110110111101010101 +00110111000000001011 +00111000010010111001 +00111000010100101100 +00111000010101101010 +00111000100001100010 +00111000100101011110 +00111000110000111101 +00111000110111010010 +00111001010111011011 +00111010000010101010 +00111011001101010011 +00111100000000010111 +00111100001101011011 +00111100010010111001 +00111100010101111011 +00111100011010010101 +00111100011101011011 +00111100011111000000 +00111100011111111100 +00111101101001100101 +00111110000011101010 +00111110010110110100 +00111110011111011101 +00111110011111111100 +00111110101010011011 +00111111100011101101 +01000000010011101000 +01000000011011101011 +01000001110000100110 +01000010000011001110 +01000010011101100011 +01000010011111111011 +01000011010111011010 +01000100010111011010 +01000100101010010110 +01000101111010000000 +01000110011011111100 +01001000011011101011 +01001010010001100110 +01001010011000010100 +01001010011110000100 +01001011011100101111 +01001100011001101001 +01001100101000001000 +01001100110101011110 +01001101000110101011 +01001110000100101101 +01001111001010000101 +01001111010011011011 +01010101000111101011 +01010110100101101100 +01010111001110000101 +01010111011100010110 +01011000110111010010 +01011110011010000101 +01100010101010101101 +01100011000001111100 +01100011010100101011 +01100100001110110111 +01100100100000010111 +01100111011010000000 +01100111101010001011 +01101001001011000001 +01101101000100011111 +01101101000110010110 +01101101010111010010 +01101101100110101001 +01101101111010000111 +01110000010100010110 +01110000010111011110 +01110011001001111100 +01110011011110000000 +01110100010100110100 +01110100111010001111 +01110101101110101101 +01110101110100111010 +01110111011010011001 +01111000000001111001 +01111000010001111001 +01111000101010101010 +01111000110111111000 +01111000111011101011 +01111000111111010010 +01111011100010010111 +01111011101001010110 +01111100000001111001 +01111100100111110100 +01111110100111111110 +01111111111111000011 +10000001010010100111 +10000101111110000100 +10001001011111110110 +10001100100001100101 +10001100110010011010 +10001101010110000011 +10001110010111110001 +10001111001010010111 +10010011101011100111 +10010100100001001000 +10010111011110000110 +10011001111111011011 +10101101000110111101 +10101110000100110111 +10110101000101101010 +10111000010001100110 +10111011101111100100 +11000100101010000101 +11001000000001111001 +11001000010001101001 +11001011011100101011 +11001110000011101011 +11001111110011101101 +11001111110100110100 +11010100000100010101 +11011100010101101010 +11011101001100101011 +11100110101100010101 +11110101010110000000 +11110101101000010010 +11111001100011001111 +Started at Sat Apr 26 02:36:12 +0100 2008 +Took 1926.564649 seconds +Generation number 10 +00000001101010101100 +00000100000011101101 +00000100000110011101 +00000100100011101100 +00000101000010111101 +00000101010100000000 +00000101101100010111 +00001000000000111011 +00001000000111111100 +00001000011011101011 +00001011001100000100 +00001011011111100011 +00001011101010110111 +00001100010011011111 +00001100010110100100 +00001100011010000000 +00001100100101100000 +00001101000110000010 +00001101011111011000 +00001110001011111001 +00001110001111101001 +00001110010011011001 +00001110010011011111 +00001111000100101011 +00001111001010011010 +00001111001010111100 +00001111010100101011 +00001111011001111110 +00001111110100110100 +00001111111101110100 +00001111111101111000 +00010001001001111011 +00010100000000111100 +00010100100011100110 +00010101010000100100 +00010101010110100011 +00010101111010000100 +00010110010010001101 +00010111011000010010 +00011000010110111110 +00011000010111011110 +00011001101111001011 +00011010011100010011 +00011100001101101001 +00011100010110100100 +00011100011010010101 +00011110010001111010 +00011110111100010110 +00011110111111011011 +00100000001100000110 +00100000010101111010 +00100100000100010101 +00100100001110110111 +00100100011100001011 +00100101011100100000 +00101000010001100110 +00101000010100110111 +00101000011000010010 +00101000011011010101 +00101000110100111011 +00101000110101010010 +00101001101000011010 +00101011101111100100 +00101100001111011011 +00101100011010111011 +00101100111010011101 +00101101001000011001 +00101101001110001011 +00101101001111111000 +00110000010111011110 +00110000110001111011 +00110000110010001110 +00110000111000011010 +00110001001110100100 +00110001111100001111 +00110010000011101010 +00110010101011100101 +00110011001101111001 +00110100000100010101 +00110100010000111011 +00110100010011111010 +00110100011000010010 +00110100011000011010 +00110100011000011010 +00110101010010111011 +00110101110010101110 +00110110001001010101 +00110110001001010101 +00110111000000001011 +00110111000011101101 +00111000010101101001 +00111000010101101010 +00111000011101100010 +00111000100101011110 +00111000110000111101 +00111000111110000111 +00111010010010111001 +00111010010110110100 +00111011001100000101 +00111011110001111010 +00111100001001011011 +00111100001011000101 +00111100010100111001 +00111100011010010101 +00111100011010011101 +00111100011100111011 +00111101010111110010 +00111101101001100101 +00111101111101101010 +00111110000100110111 +00111110011101011101 +00111110011111010101 +00111110111100000111 +00111111001010111110 +01000000011011101011 +01000000011011101011 +01000100010111111000 +01000100010111111110 +01000100101110010110 +01000101100000111011 +01000110000011001101 +01001000100111111110 +01001010000000101101 +01001010010110010100 +01001010101010000101 +01001111010011011011 +01010000100101110000 +01010101000111101011 +01010101001110111111 +01010111000111101011 +01011001010111011011 +01011010110111010010 +01011100000011110011 +01100001000111011011 +01100011010111011010 +01100100000100000110 +01100100000111101011 +01100100011110110111 +01101000111010111011 +01101001001011101011 +01101011101001011011 +01101100010111000000 +01101101010100111010 +01101101010111000110 +01101101111010000011 +01101101111111010010 +01110000010111111101 +01110010011101100011 +01110101000100011111 +01110101101110101101 +01110101110100111010 +01110101110111010010 +01110110000011000111 +01111000010100101110 +01111000101001111011 +01111000111010011010 +01111000111011000001 +01111000111110101010 +01111010101011000101 +01111011100011101101 +01111100000000010111 +01111100001101000000 +01111101000100011111 +01111110011001111011 +01111110100111111111 +01111111011010001001 +10000101010000000001 +10000101010100000000 +10001001010010010010 +10001011110010010111 +10001100010110011010 +10001100100001100101 +10001100100001100110 +10001100100011101101 +10001100110011011010 +10001111011111001101 +10010000111111010010 +10010010110101101100 +10010011110111101000 +10011001111111011001 +10011010011100011011 +10011010110111010010 +10011100100111000001 +10011101010110001110 +10110101111101100110 +10110110011010001100 +11000101010010111110 +11000101011111110110 +11001000000000000100 +11001001010001001110 +11001001010001101001 +11001001111010000000 +11010100000100010101 +11010101011100100000 +11011100001011100111 +11100110101100010101 +11100111101110101011 +11101011100011001111 +11111000100101011110 +11111000101010101010 +Started at Sat Apr 26 03:08:19 +0100 2008 +Took 2014.162627 seconds +Generation number 11 +00000010110101101000 +00000100000001101101 +00000100000011101101 +00000100011100110111 +00000100110110111010 +00000101011000010011 +00001000001101011011 +00001000010100101110 +00001000010111011100 +00001000011011101011 +00001000100001011111 +00001001011011101111 +00001001111010000010 +00001011001100000010 +00001011011111000011 +00001011101110100100 +00001100000100000110 +00001100010011011110 +00001100010011011111 +00001101010010011111 +00001101100101000000 +00001110010011011001 +00001110010011011010 +00001110010011011110 +00001111000011101101 +00001111010011011010 +00001111010100101011 +00010001000110101011 +00010100000000111100 +00010100100011100110 +00010100100100010011 +00010101010000100100 +00010101010110000110 +00010101111100010110 +00010110111110000111 +00010111111100000010 +00011000000011001010 +00011000101001100101 +00011000101010101010 +00011001010110111111 +00011010011011100110 +00011010011100010011 +00011010100111010010 +00011101110101101010 +00011110100000111011 +00011110111111011011 +00011111111111011011 +00011111111111011011 +00100000010101111000 +00100000011000011010 +00100010000001010101 +00100100011100001011 +00100101111111110010 +00100111001110111101 +00101000000011001101 +00101000010100110111 +00101000011000010010 +00101000011011000111 +00101000110100101011 +00101000110100110110 +00101000110101010110 +00101000111010111011 +00101000111110101010 +00101001101000011110 +00101010010011100011 +00101100011010111101 +00101100111010011101 +00101100111011011100 +00101101001110001011 +00101101001111000111 +00101101010110110101 +00101101010111011001 +00101101011010111011 +00101110001011111001 +00110000111000101111 +00110000111001011010 +00110001111110001111 +00110010000011101010 +00110010010010111110 +00110010111111010101 +00110100010011111010 +00110100010111111011 +00110100011000010010 +00110100011000010100 +00110100011011011010 +00110101101111001011 +00110101110010011011 +00110110010110010100 +00110111000000001011 +00110111000100101111 +00111000000010001101 +00111000110001001110 +00111000111110000111 +00111001010100111010 +00111001011100000001 +00111010011111011001 +00111011001100011001 +00111100000011001111 +00111100010101100110 +00111100010110111001 +00111100011001011011 +00111100011111101011 +00111100100111000001 +00111101101001000111 +00111110001100000101 +00111110111100010110 +00111111001110111110 +00111111010110010100 +00111111101001100101 +01000000011011010101 +01000000011011101011 +01000000011101101001 +01000100000111111100 +01000100010111111111 +01000100101110010110 +01000101100000111011 +01000110010111111110 +01000111111110101001 +01001000011011101011 +01001010010110010101 +01001010111011000000 +01001100100011101101 +01001111001010111101 +01010000011110101011 +01010101000111101011 +01010101010010110110 +01010111000111101011 +01010111000111101011 +01011001001110000100 +01011001010111011011 +01011001111010011011 +01011011010000001011 +01011110000011110011 +01011110101111111011 +01100100000010000100 +01100100000101100000 +01100100000110101011 +01100100000111101011 +01100100010111111000 +01100100100011101110 +01100111101110101011 +01101000010100110111 +01101000011000010010 +01101000111010101011 +01101011110011001111 +01101101001110001011 +01101101010010111010 +01101101010110000110 +01101101010111000110 +01101111010100101011 +01110000101011000001 +01110011010111011010 +01110011011101100001 +01110101110110111110 +01110101110111011110 +01110101111110100100 +01110110000011010101 +01111000010011101011 +01111000111110111001 +01111010011111000101 +01111010101011000101 +01111011100011101011 +01111100001101100010 +01111101000110111111 +01111101010100010101 +01111110011010011101 +01111110101000011010 +01111111011001111110 +10000101000000001111 +10001000001001000000 +10001001010000111101 +10001011110011010011 +10001100010100011010 +10001100010110011010 +10001100010110011010 +10001100110011011010 +10001111110100110100 +10010010110101101100 +10010100000110011101 +10010101011000010010 +10011001110110110100 +10011110010001111010 +10011110011010001100 +10100111101110101011 +10101011100011011111 +10110101000100010101 +10111001000111011001 +11000101011110111111 +11001001010000111001 +11001100100111111100 +11011011010111110010 +11011110111100010110 +11100100011100001011 +11100100011110110111 +11100101011110011011 +11101011101011101011 +11101011111011000101 +11101100010110000100 +11110101001111111011 +11110101111010000100 +Started at Sat Apr 26 03:41:53 +0100 2008 +Took 2051.893687 seconds +Generation number 12 +00000001011000010011 +00000010010100111010 +00000100000110101011 +00000100010111111011 +00000100011100110101 +00000100011100110111 +00000100100110111010 +00000100110110111010 +00000101001110011011 +00001000011000010010 +00001000011011000111 +00001000011011110100 +00001000111111111011 +00001001010001101011 +00001001011011101101 +00001001111010001010 +00001010000001010101 +00001010001101011111 +00001011010100101011 +00001011011111000001 +00001011101110100101 +00001100010011011011 +00001110010010001011 +00001110010010101111 +00001110010011011001 +00001110010011111010 +00001110101000011010 +00010001000110101011 +00010001000110101011 +00010001010000100100 +00010010100111000010 +00010011010111110010 +00010100010100010101 +00010100100011100110 +00010100110100010011 +00011000101001100101 +00011001010110111111 +00011001110111001011 +00011010011100010011 +00011011101110110110 +00011011110001001111 +00011100011000011010 +00011110010011011001 +00011110010110111010 +00011110111111111011 +00011111010100100110 +00011111010110010100 +00011111111111001011 +00100000000101111000 +00100000011011101011 +00100000111000101101 +00100001011000011010 +00100010000001010100 +00100010110101101100 +00100100000100111100 +00100100010011101011 +00100100011100011010 +00100101011010110100 +00100111101000011110 +00101000001011011010 +00101000011011001011 +00101000011011101011 +00101000111010111011 +00101000111110110110 +00101100000011001101 +00101100011001010110 +00101100111011011110 +00101101001111000111 +00101101010011011011 +00101101011000011111 +00101111010100101011 +00110000111010011010 +00110000111111011111 +00110001101110001111 +00110001111110001111 +00110011011000010011 +00110100000111101011 +00110100010111111011 +00110100011000010111 +00110100011011010010 +00110100111110101010 +00110101101111001001 +00110110001000011100 +00110111000100101010 +00111000000000111111 +00111000010101100111 +00111000011111000111 +00111000100001001110 +00111000110011011110 +00111000111010100001 +00111001000000001100 +00111001001000100001 +00111001011100000001 +00111001110001101000 +00111010001111011010 +00111100010101100110 +00111100010101101011 +00111100010101111011 +00111100011011001011 +00111100011111101111 +00111101000010011111 +00111101010010110110 +00111101010010110111 +00111101010111011001 +00111101110010011011 +00111110001110111110 +00111110011010011101 +00111110011111011010 +00111111101001111011 +01000000010101100110 +01000000011011010101 +01000000011011101111 +01000100000101100001 +01000100011010110100 +01000101100010001101 +01000110010101111011 +01000110010111111110 +01001000011011101011 +01001111001010101111 +01010000011000000010 +01010001111100001111 +01010100100011100110 +01010100111001011011 +01010111000111100011 +01011001010110111101 +01011100010110011010 +01011110011100011010 +01011110101110101010 +01011110101111111110 +01100100000110101011 +01100100100011101110 +01100100101110010110 +01100101000110000110 +01100101101111001011 +01100101111110011011 +01101000011000001011 +01101000011000010010 +01101000011101100001 +01101000101000011010 +01101000111010101010 +01101001010100110111 +01101001111011000101 +01101010010011011010 +01101011100011001011 +01101101010000111000 +01101101010110000110 +01101101010110000110 +01101111101110101011 +01110000010011101011 +01110000101011010000 +01110010111110111001 +01110100011000010010 +01110100110111011110 +01110101110110011111 +01110101110110111110 +01110110000011010101 +01110110000011110100 +01110110000110011010 +01110110010110000100 +01110111001110011111 +01111000010001000101 +01111000110011101011 +01111001110110000111 +01111010011110000111 +01111010101011101111 +01111101010010011111 +01111101010011111010 +01111101010100010101 +01111110011010011101 +01111110101101111011 +01111110101111001110 +01111110111010101010 +10000100000011100111 +10000101000000000001 +10001100010011011100 +10001100010111010101 +10001100100111111100 +10001111110111010101 +10010001000110011001 +10010001110110101011 +10011010001010100110 +10011110001111111011 +10101000011000010011 +10101000011100001011 +10101011011100100011 +10110011000000000101 +10111000101111111100 +10111011010100001110 +11001001010000111001 +11001010011100001011 +11001100110011011010 +11010101011110001011 +11011010111111010111 +11100100100011101110 +11100101010010110000 +11100101010011110110 +11100101010111011110 +11101011101011101011 +11101100100111111100 +11111101000110111101 +Started at Sat Apr 26 04:16:05 +0100 2008 +Took 2131.171748 seconds +Generation number 13 +00000000000110101011 +00000000010111010110 +00000000011011101001 +00000001011000010011 +00000010010110111110 +00000100010111111011 +00000100100011100110 +00000100100111101110 +00000100111000001011 +00000101011100110001 +00000101101110011011 +00000110010110111110 +00001000011000010011 +00001000111001001111 +00001001010001100011 +00001001010001101011 +00001001010110111111 +00001001011011101100 +00001001101010001011 +00001001110010001010 +00001001110110000101 +00001010000001010100 +00001010010111111110 +00001010011111000001 +00001011011110111110 +00001011101110100101 +00001011111101100101 +00001100000011011011 +00001100100011101110 +00001101010011011011 +00001110010010000011 +00001110010111111011 +00001111011010111111 +00010000000110101101 +00010001010000100101 +00010001110000100100 +00010011010000100101 +00010100110100010101 +00010100110110111010 +00010110101111001110 +00011000111111111011 +00011001011011100110 +00011011100101100110 +00011011101010110110 +00011011101110110110 +00011011101110111110 +00011011110001001101 +00011011110110001010 +00011110001110101011 +00011110010110111010 +00011110010110111011 +00011110110011101011 +00011111010110010100 +00011111011100011010 +00100000111000011010 +00100001011000010011 +00100011011000000111 +00100011101010011110 +00100100011000111011 +00100100011010010100 +00100100101111111110 +00100111101100011111 +00101000011011101011 +00101000111110110100 +00101001011001011010 +00101001011011001011 +00101010101011101111 +00101011010100001100 +00101011111100001011 +00101100000111111011 +00101101001111011010 +00101101011001010111 +00101101011111001011 +00101110001000011100 +00110000001011101101 +00110001000111101001 +00110001111111111011 +00110010111010011010 +00110011000100001010 +00110011001001011011 +00110110001000011100 +00110110001010011110 +00110110011100001011 +00110111000100100111 +00111000001011011010 +00111000010000111111 +00111000011010110110 +00111000011101000001 +00111000011111000111 +00111000110111010101 +00111000111010100011 +00111000111110001111 +00111001001001110111 +00111001010111011111 +00111001011100000001 +00111010011010100001 +00111100010101011011 +00111100010111000111 +00111100011000010111 +00111100011011001011 +00111100110010011010 +00111100111110101010 +00111101000010011110 +00111101010010100001 +00111101110010011011 +00111110011110101111 +00111110101011101011 +00111110110010110000 +00111111010011110110 +00111111101101111011 +01000010010000111000 +01000101010001101111 +01000101100010001101 +01001000111111111011 +01001001111011000101 +01001010001101011111 +01001011010100101011 +01010001000111101011 +01010110000011110100 +01011000111000100011 +01011010011110000101 +01011010101111111110 +01011100010110011011 +01011100101111000001 +01011110010011001011 +01100000011111100001 +01100100101110001110 +01100101010111110110 +01100101011110001011 +01100101111110010011 +01100110000011110110 +01101000011100110101 +01101001010111000100 +01101001011111001011 +01101001101000011010 +01101011101110100011 +01101011111011000101 +01101100000011111011 +01101101010000111110 +01101101010100110101 +01101101010110011101 +01101101010111010110 +01101111111011000101 +01110000010001101011 +01110000011011101011 +01110100010101100110 +01110100011011010001 +01110100110111011101 +01110101010011111110 +01110101110110011011 +01110110000110111010 +01110110110110000101 +01111000010011001101 +01111000011111101011 +01111000111111111011 +01111001101110111111 +01111010011110001010 +01111100010100010101 +01111100101111100010 +01111101000101001011 +01111101010010011101 +01111101010100010101 +01111110101101111011 +01111110101111001010 +01111110111010101010 +01111110111011000110 +10000001011000011010 +10000101011000010011 +10001001111011001011 +10001100000101000001 +10001100010011010101 +10001100010111010101 +10001100010111011100 +10001100011011110000 +10010001110110101010 +10011000101001000001 +10011001010001010110 +10011110111010100001 +10011111111110010101 +10101011001001100101 +10101100101110100101 +10101101011110000110 +10110011000000000111 +10111100010001100110 +10111101010010110110 +11000000010101100000 +11001000011011000010 +11001000011100001111 +11001001010000111000 +11001010011100001010 +11010100011000001011 +11010110000110111010 +11100100101010011101 +11100100110011011001 +11100101010010110000 +11100101011010110001 +11100111010011011110 +11101000011000001111 +11110101010111011110 +11111101000110111111 +Started at Sat Apr 26 04:51:36 +0100 2008 +Took 2193.372392 seconds +Generation number 14 +00000000010111010110 +00000000011010101000 +00000001011011011001 +00000010000110111010 +00000010010110110110 +00000011010000100101 +00000100100110101110 +00000100111000001011 +00000101011100110001 +00000101101100011011 +00000101111100110011 +00000110010110111100 +00000110010110111110 +00000110011010101011 +00001000010001101011 +00001000111001001110 +00001001010001010110 +00001001010001100010 +00001001010001101011 +00001001010001111110 +00001001010010011011 +00001001010010110110 +00001001010101001010 +00001001010110111110 +00001001011011101100 +00001011010110111111 +00001011011101001101 +00001011011111000010 +00001011100101100110 +00001011101110100101 +00001011101110100101 +00001011101110110000 +00001011110110000101 +00001011111100000011 +00001011111100001011 +00001100000011011011 +00001100000110101011 +00001100000111111011 +00001100010111101001 +00001101010011011011 +00001110000011011011 +00001110010111111101 +00001110101010011100 +00001110101111001110 +00001110111011000110 +00001111011010111010 +00010000101010101010 +00010001000111101011 +00010001010000001011 +00010001010000100101 +00010100000011011011 +00010100011111100110 +00010100100011000110 +00010100110111000111 +00011000011100010011 +00011000111010100011 +00011001010011100110 +00011001110100010101 +00011001110110101111 +00011011100101101010 +00011011101101100110 +00011011101110000101 +00011011101110111111 +00011100010111111011 +00011100110011101011 +00011101011100110101 +00011110001100011010 +00011110001110101010 +00011110011100011010 +00011110111010110001 +00011111111110010101 +00100100011011011111 +00100110011101001011 +00101000110000001011 +00101000111111111011 +00101001010001111010 +00101001011001011010 +00101010011010100001 +00101101011001010111 +00101110001000011100 +00110000011000011011 +00110001011011001011 +00110010111010011010 +00110100101110001110 +00110100110110111010 +00110110011000010011 +00110111000100100111 +00111000010010001010 +00111000110110100001 +00111000110111010101 +00111000110111010101 +00111001010111010110 +00111001011100010111 +00111010011110000101 +00111011100011101111 +00111011100101100110 +00111100010110110010 +00111100010111010101 +00111100011000000101 +00111100011011001001 +00111100011011001011 +00111100110000011011 +00111100111011001011 +00111100111110101010 +00111100111110101011 +00111101010010011101 +00111101010011010101 +00111101100101001011 +00111110010111101111 +00111110011000001011 +00111110011110101111 +00111110101010101111 +00111110110000110011 +00111110110010110000 +00111110111111101011 +00111111010011110110 +00111111110010100101 +01000001100010001101 +01000101010010000011 +01001000011110111110 +01001000111110110100 +01001001011111000111 +01001010001101010100 +01001010010111010110 +01001011010100101011 +01001101110110000101 +01011010011110111110 +01011011110000110100 +01011100010011100101 +01011100101111000001 +01011110010011011110 +01100000010001101011 +01100101010111111110 +01100101011111110110 +01100110110110000101 +01101001111111001111 +01101100000011111011 +01101101000100110101 +01101101010000111110 +01101101010010011101 +01101110000110101011 +01101111010011101011 +01101111111011000101 +01110000011110110100 +01110100010101100111 +01110100011011010001 +01110101010111101011 +01110101111011101011 +01111000010011001101 +01111000011011101011 +01111000011111101011 +01111000011111101011 +01111001001110111110 +01111001101110111111 +01111011010100001100 +01111100101111100011 +01111100111101100010 +01111101000110111111 +01111101010011110110 +01111110100110010001 +01111110101111001110 +01111111111010101010 +01111111111010101101 +01111111111101100101 +10000001001010010011 +10000001101110111110 +10000101101110011000 +10001001011100000001 +10001010111100001010 +10001101001101111011 +10001101010010110001 +10011001010001010100 +10011001010001100001 +10011011000001101101 +10011111110110010100 +10101000010110011011 +10101011010100001100 +10101100111101000000 +10110001000111110111 +10110011000100001000 +10110110010110111100 +10111000111111001011 +10111101010010111110 +10111101010011110110 +11000100101010011101 +11000101010001101111 +11001000011100001111 +11001010011100001010 +11001010011110111110 +11001011010101100110 +11010100011000001011 +11011000010000111110 +11011110000110111010 +11100100101010011010 +11100100110000010011 +11100100110011011001 +11101100000011111011 +11101100011100110101 +11110100110111011101 +11111101000110111110 +Started at Sat Apr 26 05:28:09 +0100 2008 +Took 2335.23266 seconds +Generation number 15 +00000000010011011011 +00000000011000101000 +00000001010000001011 +00000001011011000101 +00000001011011011001 +00000011010000100101 +00000011010000111001 +00000100101101100101 +00000101111101100111 +00000111110010100101 +00001000010011010101 +00001000010100100011 +00001000010101101011 +00001000010110110110 +00001000100110101001 +00001000111001001110 +00001001001001010110 +00001001010000001011 +00001001010000010110 +00001001010001010110 +00001001010001010111 +00001001010010110110 +00001001010010110110 +00001001011011101100 +00001001110111000110 +00001010111011101011 +00001011011110001011 +00001011100101100101 +00001011101010010101 +00001011101011110001 +00001011101110100110 +00001011110110000101 +00001011111010001011 +00001011111100001011 +00001011111110100101 +00001100000011011011 +00001100000011111011 +00001100000110101011 +00001100110010111010 +00001100111011101011 +00001101010010110001 +00001110000011011011 +00001110000011111011 +00001110001000011100 +00001110010010110000 +00001110010111100111 +00001110010111111001 +00001110110111010101 +00001111000011011011 +00001111001010111110 +00001111011110111010 +00010011101110100000 +00010100011110100110 +00010100101110111111 +00010100110111000111 +00010101000011111011 +00011000011100011111 +00011001101110110110 +00011001110100010101 +00011001110110100010 +00011001111100010011 +00011010011100011110 +00011011101001101110 +00011011101101100110 +00011011101110111111 +00011100000011011011 +00011100010111100101 +00011100101100100101 +00011100111110101011 +00011101010000010011 +00011101011011001000 +00011101110110101111 +00011110001100000101 +00011110001100011011 +00011110001100011011 +00011110001111001101 +00011110011100011010 +00011110111101100110 +00011111110110010100 +00011111110110010111 +00100000010001101011 +00100010010001101011 +00101000111001001110 +00101001010010011010 +00101001010101001000 +00101001010111000010 +00101001011010101000 +00101001110111010111 +00101100001011001011 +00101100010111100110 +00101101010000100010 +00101101010011010101 +00101111011110011010 +00110011010110111111 +00110100011001011010 +00110100011100000101 +00110100011111100110 +00110100100110100110 +00110100110110111010 +00110100110110111110 +00110100110111111010 +00110100110111111010 +00110110001100000010 +00110110010111101110 +00111000100110101110 +00111000110011010101 +00111000110110111110 +00111001010110111111 +00111001011100010001 +00111001011100100111 +00111001110011101111 +00111010011110000101 +00111010011110011010 +00111011010111010000 +00111100011000001010 +00111100110111011010 +00111100111110100010 +00111101010001100010 +00111101111000110101 +00111110010100000111 +00111110010111010110 +00111110011101101111 +00111110011110101111 +00111110110010111000 +00111110111100011010 +01000000010010011011 +01000001100010001101 +01000100101011000110 +01001000111110110100 +01001001011011101000 +01001010001101010100 +01001011010001111011 +01001011010100101011 +01001011010100110100 +01001011110110000101 +01001011111110110100 +01001100010111100001 +01001101110110000101 +01001101110110000101 +01010101111000001011 +01011010011110111010 +01011011010000110100 +01011110000110111011 +01100000010001101011 +01100000010101101011 +01100100110111011001 +01100101011111110110 +01100110110010001011 +01100110110100000110 +01101000010101000110 +01101001011111000111 +01101011111111001111 +01101100000011111011 +01101110101010011100 +01101110111101000000 +01101111111011000100 +01110000011110101001 +01110000011110110100 +01110010011001101011 +01110011010000001100 +01111000010010100010 +01111000110011010101 +01111001011011100010 +01111010101110101110 +01111100111101101101 +01111100111101110010 +01111101000110010011 +01111101010011110111 +01111101110011110010 +01111110101110001111 +01111111011101100101 +01111111110110101010 +10000100010110111100 +10000101101110011001 +10000101111110110011 +10001100000111101011 +10001101001101111010 +10011000010001101110 +10011100110011100101 +10011101001101110011 +10011110010011100010 +10011111110111111101 +10100000011000010011 +10101100110101010000 +10101111010000111110 +10110010110110111100 +10110101010001011011 +10111110101111001110 +11000100100101100110 +11001001010010011011 +11001010011001011011 +11001010011110111010 +11011000000000111101 +11011000010000010101 +11011110000110110101 +11100100101010011110 +11100100101010011110 +11100100110000010101 +11101100000011011011 +11111101000110111110 +Started at Sat Apr 26 06:07:05 +0100 2008 +Took 2289.021254 seconds +Generation number 16 +00000000010011011011 +00000001010000010111 +00000010111011110111 +00000011000000111001 +00000011110110000010 +00000100100101100110 +00000100101011000110 +00000100110000010101 +00000101000110111110 +00000101111011001101 +00000111011011001000 +00000111100010100100 +00000111100010100101 +00000111110010001011 +00001000010010110000 +00001000010100100110 +00001000110001001110 +00001000110100010101 +00001000110110100101 +00001001000110100111 +00001001010000010110 +00001001010001011011 +00001001010101100111 +00001001010110111111 +00001001011011101100 +00001001111110010011 +00001010000001001011 +00001010111101100110 +00001011010010011110 +00001011101011110010 +00001011101011110100 +00001011101110100100 +00001011111100001001 +00001011111100011011 +00001011111110110100 +00001100010010111000 +00001100011001101011 +00001101010001001010 +00001101010010110001 +00001101110110101010 +00001101111011011001 +00001110000011011011 +00001110000111101011 +00001110010000001011 +00001110010010110000 +00001110010011100111 +00001110100110100110 +00001111001010111110 +00001111001010111110 +00001111001010111110 +00001111100101100101 +00001111110110000100 +00010000011000101000 +00010011101110101111 +00010100011001011011 +00010100011110100010 +00010101000011110101 +00011000011100011111 +00011000110110111110 +00011001010001010101 +00011001110100010101 +00011001110100101110 +00011010010000011011 +00011011010100110100 +00011011101011101011 +00011011101101101110 +00011011101111011101 +00011100000011111110 +00011100001100001011 +00011100010100001111 +00011100101100100101 +00011100101101000101 +00011101000000111111 +00011101110010101011 +00011101110110101010 +00011110001100000101 +00011110111101100110 +00011111000010010000 +00011111011100011110 +00011111110110010101 +00011111111100001010 +00100000010001100010 +00100010010001101111 +00100010010011000010 +00100011010001101011 +00100011010010100101 +00100101010010100001 +00101001010010011010 +00101001010110000101 +00101001110111010111 +00101010111011000011 +00101011111100100101 +00101100001011001011 +00101100001011010100 +00101100010001011001 +00101101010111001011 +00101101110111010000 +00101110111101000000 +00110000010110101010 +00110000110000001010 +00110011010010110110 +00110011011110110111 +00110011110110100000 +00110100010110111110 +00110100011011101100 +00110100011100000101 +00110100110110111010 +00110110001100010010 +00110110110111101010 +00111000100110101110 +00111000101110101010 +00111001000011011011 +00111001010010011010 +00111001011100110110 +00111010001110000101 +00111010010111100111 +00111010011110000101 +00111011010000110100 +00111011010011010000 +00111011010111100110 +00111100011110111010 +00111100110111011000 +00111100111110000010 +00111101110111111010 +00111110010100000110 +00111110011011111010 +00111110011101101111 +00111110011110000101 +01000100101010000110 +01000100101011000110 +01001001010001110111 +01001001110111111010 +01001010011100101011 +01001011011110111010 +01001011100110010101 +01001100101011000110 +01001110101110101011 +01001110110110101111 +01010001011001101011 +01011000001010111010 +01011000011100011111 +01011000110011010101 +01011000110011110101 +01011011100011110001 +01011011110101000000 +01011100001001011110 +01011111110110000101 +01100000010100100011 +01100100110001100110 +01100100110111111001 +01100110110010011011 +01101000010000001011 +01101101010000100011 +01110001011110101001 +01110011010110011110 +01111000010010100010 +01111000100011010101 +01111000100110101100 +01111000110011110101 +01111010111110101110 +01111100111101101101 +01111101100011111111 +01111111011011001100 +01111111110110101111 +10000000001000100101 +10000100010110111100 +10001000110100101011 +10001001011011101100 +10001001110111000110 +10001011011110001011 +10001110000111101011 +10001111010110111111 +10010101110110101111 +10011000010001010101 +10011010010011100010 +10011010011110011010 +10011101101100100101 +10011101110101010111 +10011110000010100101 +10101001011000101000 +10101111010011111011 +10110101010001010110 +10111001111001001110 +11000001011011000101 +11000100101011000110 +11001001010010011011 +11001010011001011010 +11001011010010100101 +11001101001101011010 +11001101010010110001 +11010000010000010101 +11011000000000111001 +11011000010000010100 +11011000010001001111 +11011000010010010101 +11011001010011011011 +11100000010001101011 +11100100101010011011 +11111000111101101101 +11111001100010001111 +Started at Sat Apr 26 06:45:14 +0100 2008 +Took 2222.522446 seconds +Generation number 17 +00000000000000010010 +00000000001010101000 +00000000010000101011 +00000010000000111001 +00000010011011100011 +00000011000000000101 +00000011000000111001 +00000011101110110100 +00000011110110000010 +00000100100000010101 +00000100101101111010 +00000100110000010101 +00000101000110111110 +00000101110100010101 +00000101111011001101 +00000110001001011010 +00000111010001110111 +00000111011011001001 +00000111110010100100 +00001000010010110100 +00001000010100100111 +00001000110110100101 +00001000110110100101 +00001001010000010110 +00001001010001001010 +00001001010011011111 +00001001010110101001 +00001001011011101100 +00001001100010100101 +00001001110011011011 +00001001111100000001 +00001001111110010011 +00001010000001001011 +00001010111100011011 +00001010111101100011 +00001011001110100100 +00001011010110111111 +00001011101011110001 +00001011101011110011 +00001011110110101010 +00001011111100001001 +00001100010011110001 +00001100101111100110 +00001100110001101110 +00001101001101011010 +00001101010001101010 +00001101010111100110 +00001101010111101011 +00001 \ No newline at end of file diff --git a/.svn/text-base/main.rb.svn-base b/.svn/text-base/main.rb.svn-base new file mode 100644 index 0000000..ee03648 --- /dev/null +++ b/.svn/text-base/main.rb.svn-base @@ -0,0 +1,13 @@ +#!/usr/bin/ruby -w + +require 'src/play' +require 'src/selection' + +pop1 = Population.new(100, 20) + +start = Time.now +puts "Started at #{start}" +pop1.tournament_select_population(0.8, 1000, true) +finish = Time.now +puts "Took #{finish - start}" + diff --git a/.svn/text-base/play-one-game.rb.svn-base b/.svn/text-base/play-one-game.rb.svn-base new file mode 100644 index 0000000..f92e1e1 --- /dev/null +++ b/.svn/text-base/play-one-game.rb.svn-base @@ -0,0 +1,29 @@ +#!/usr/bin/ruby -w + +require 'src/play' +require 'src/selection' + +winner_success_chance = 0.8 + +player_bitstrings = readlines.collect {|l| l.chomp.split(//).collect {|x| x.to_i}} + +# File.open('player.log', 'a') do |f| +# player_bitstrings.each {|b| f.puts "Process #{Process.pid}: Received #{b}"} +# end + +players = player_bitstrings.collect {|b| Genome.new(b).to_potential_player} + +handler = GameHandler.new(players, 1000) +winner, moves = handler.play + +if winner == :draw or rand > winner_success_chance + successful_player = players[rand(players.length)] +else + successful_player = winner +end + +# File.open('player.log', 'a') do |f| +# f.puts "Process #{Process.pid}: winner is #{successful_player.to_bitstring}" +# end + +puts "#{successful_player.to_bitstring}" \ No newline at end of file diff --git a/.svn/text-base/player.log.svn-base b/.svn/text-base/player.log.svn-base new file mode 100644 index 0000000..78b2dfd --- /dev/null +++ b/.svn/text-base/player.log.svn-base @@ -0,0 +1,205 @@ +Process 3043: Received 01100011011100000100 +Process 3043: Received 01100111111110010111 +Process 3043: Received 01100111111110010111 +Process 3043: Received 01100111111110010111 +Process 3043: winner is 01100111111110010111 +Process 3044: Received 01100111111110010111 +Process 3044: Received 10111110010001000111 +Process 3044: Received 01100011011100000100 +Process 3044: winner is 01100111111110010111 +Process 3045: Received 01100011011100000100 +Process 3045: Received 10000111110000010000 +Process 3045: Received 10111110010001000111 +Process 3045: winner is 01100011011100000100 +Process 3046: Received 01100011011100000100 +Process 3046: Received 01100111111110010111 +Process 3046: Received 01100111111110010111 +Process 3046: Received 01100111111110010111 +Process 3046: winner is 01100111111110010111 +Process 3047: Received 01100111111110010111 +Process 3047: Received 11110110100101101110 +Process 3047: Received 10111110010001000111 +Process 3047: Received 10111110010001000111 +Process 3047: Received 10000111110000010000 +Process 3047: winner is 10000111110000010000 +Process 3048: Received 01101111111110011111 +Process 3048: Received 01101111111110011111 +Process 3048: Received 10000111110000010111 +Process 3048: Received 01100011011100000100 +Process 3048: Received 01100111011110010000 +Process 3048: Received 01100111111010011111 +Process 3048: winner is 01101111111110011111 +Process 3049: Received 10000111110000010111 +Process 3049: Received 01100111011110010000 +Process 3049: Received 01100111011110010000 +Process 3049: Received 01101111111110011111 +Process 3049: Received 01100011011100000100 +Process 3049: winner is 01100111011110010000 +Process 3051: Received 10000111110000010111 +Process 3051: Received 01100111111010011111 +Process 3051: winner is 01100111111010011111 +Process 3054: Received 01100111111010011111 +Process 3054: Received 01100111111010011111 +Process 3054: Received 01101111111110011111 +Process 3054: Received 01100011011100000100 +Process 3054: Received 01100011011100000100 +Process 3054: Received 01100011011100000100 +Process 3054: winner is 01100011011100000100 +Process 3057: Received 10000111110000010111 +Process 3057: Received 01100111111010011111 +Process 3057: Received 10000111110000010111 +Process 3057: Received 01100111011110010000 +Process 3057: Received 10000111110000010111 +Process 3057: Received 01101111111110011111 +Process 3057: winner is 10000111110000010111 +Process 3061: Received 01100111111010011101 +Process 3061: Received 10000111110000000111 +Process 3061: Received 00011111111110100100 +Process 3061: Received 01100111111010011101 +Process 3061: winner is 01100111111010011101 +Process 3068: Received 01100111111010011101 +Process 3068: Received 00100110011110010000 +Process 3068: Received 00011111111110100100 +Process 3068: Received 00100110011110010000 +Process 3068: Received 00100110011110010000 +Process 3068: Received 00011111111110100100 +Process 3068: winner is 00011111111110100100 +Process 3071: Received 00100110011110010000 +Process 3071: Received 10000111110000000111 +Process 3071: Received 01100011011100011111 +Process 3071: winner is 00100110011110010000 +Process 3072: Received 10000111110000000111 +Process 3072: Received 01100011011100011111 +Process 3072: Received 01100011011100011111 +Process 3072: Received 01100111111010011101 +Process 3072: winner is 01100011011100011111 +Process 3077: Received 00100110011110010000 +Process 3077: Received 01100011011100011111 +Process 3077: Received 01100111111010011101 +Process 3077: Received 10000111110000000111 +Process 3077: winner is 01100011011100011111 +Process 3090: Received 01100111111010011101 +Process 3090: Received 01100011011100011011 +Process 3090: winner is 01100111111010011101 +Process 3093: Received 00100110011110010000 +Process 3093: Received 01100011011100011011 +Process 3093: Received 11100011011100011111 +Process 3093: Received 00011111111110100100 +Process 3093: Received 11100011011100011111 +Process 3093: winner is 01100011011100011011 +Process 3094: Received 01100111111010011101 +Process 3094: Received 00100110011110010000 +Process 3094: Received 11100011011100011111 +Process 3094: Received 00100110011110010000 +Process 3094: Received 00011111111110100100 +Process 3094: winner is 11100011011100011111 +Process 3095: Received 00100110011110010000 +Process 3095: Received 01100111111010011101 +Process 3095: Received 00100110011110010000 +Process 3095: Received 01100011011100011011 +Process 3095: winner is 01100011011100011011 +Process 3096: Received 00100110011110010000 +Process 3096: Received 00100110011110010000 +Process 3096: Received 01100111111010011101 +Process 3096: winner is 00100110011110010000 +Process 3101: Received 00100110011110010000 +Process 3101: Received 01100010011100011011 +Process 3101: Received 00100110011110010000 +Process 3101: Received 00100110011110010000 +Process 3101: Received 01101110111010011101 +Process 3101: Received 01100010011100011011 +Process 3101: winner is 00100110011110010000 +Process 3104: Received 01101110111010011101 +Process 3104: Received 00100110011110010000 +Process 3104: Received 01101110111010011101 +Process 3104: Received 01101110111010011101 +Process 3104: Received 01100011011101011011 +Process 3104: winner is 00100110011110010000 +Process 3106: Received 00100110011110010000 +Process 3106: Received 01100011011101011011 +Process 3106: winner is 01100011011101011011 +Process 3107: Received 11100011010100011111 +Process 3107: Received 01101110111010011101 +Process 3107: Received 01100010011100011011 +Process 3107: winner is 01100010011100011011 +Process 3110: Received 01100010011100011011 +Process 3110: Received 00100110011110010000 +Process 3110: Received 00100110011110010000 +Process 3110: Received 00100110011110010000 +Process 3110: Received 01100011011101011011 +Process 3110: Received 01101110111010011101 +Process 3110: winner is 00100110011110010000 +Process 3125: Received 01100000011100011011 +Process 3125: Received 00100110011110010001 +Process 3125: Received 01100011011101011010 +Process 3125: Received 01100000011100011011 +Process 3125: Received 01100000011100011011 +Process 3125: winner is 01100000011100011011 +Process 3126: Received 01100011011101011010 +Process 3126: Received 00100110011110010001 +Process 3126: winner is 00100110011110010001 +Process 3127: Received 00100100011110110000 +Process 3127: Received 01100000011100011011 +Process 3127: winner is 01100000011100011011 +Process 3128: Received 10100110011110010100 +Process 3128: Received 10100110011110010100 +Process 3128: Received 00100100011110110000 +Process 3128: winner is 00100100011110110000 +Process 3131: Received 01100011011101011010 +Process 3131: Received 00100100011110110000 +Process 3131: Received 01100000011100011011 +Process 3131: Received 01100011011101011010 +Process 3131: winner is 00100100011110110000 +Process 3132: Received 00100110011111011001 +Process 3132: Received 00100100011110110000 +Process 3132: Received 00100100011110110000 +Process 3132: Received 10100000011100011011 +Process 3132: winner is 00100110011111011001 +Process 3135: Received 00100110011111011001 +Process 3135: Received 01001000011100011111 +Process 3135: Received 00100110011111011001 +Process 3135: winner is 00100110011111011001 +Process 3138: Received 10100000011100011011 +Process 3138: Received 00100101111100110000 +Process 3138: Received 00100100011110110000 +Process 3138: Received 00100110011111011001 +Process 3138: Received 10100000011100011011 +Process 3138: Received 00100101111100110000 +Process 3138: winner is 00100100011110110000 +Process 3145: Received 00100101111100110000 +Process 3145: Received 00100101111100110000 +Process 3145: Received 00100110011111011001 +Process 3145: Received 00100100011110110000 +Process 3145: winner is 00100100011110110000 +Process 3146: Received 01001000011100011111 +Process 3146: Received 00100101111100110000 +Process 3146: Received 00100101111100110000 +Process 3146: Received 00100110011111011001 +Process 3146: Received 00100110011111011001 +Process 3146: winner is 00100101111100110000 +Process 3147: Received 00100100011110111010 +Process 3147: Received 00100110011110011000 +Process 3147: Received 00100110011110011000 +Process 3147: Received 00000101111100110000 +Process 3147: winner is 00100100011110111010 +Process 3148: Received 00000101111100110000 +Process 3148: Received 00100100011110111010 +Process 3148: Received 00100110011110011000 +Process 3148: Received 00100010011101010000 +Process 3148: Received 00100100011110111001 +Process 3148: winner is 00100100011110111010 +Process 3149: Received 00100100011110111010 +Process 3149: Received 00000101111100110000 +Process 3149: Received 00100100011110111001 +Process 3149: winner is 00100100011110111010 +Process 3152: Received 00100100011110111001 +Process 3152: Received 00100100011110111001 +Process 3152: Received 00100010011101010000 +Process 3152: winner is 00100010011101010000 +Process 3153: Received 00000101111100110000 +Process 3153: Received 00100010011101010000 +Process 3153: winner is 00100010011101010000 +Process 3154: Received 00100100011110111010 +Process 3154: Received 00101010011101010000 +Process 3154: Received 00100010011111010000 +Process 3154: Received 00100100011110111010 diff --git a/.svn/text-base/run-ga.rb.svn-base b/.svn/text-base/run-ga.rb.svn-base new file mode 100644 index 0000000..abd27c6 --- /dev/null +++ b/.svn/text-base/run-ga.rb.svn-base @@ -0,0 +1,59 @@ +#!/usr/bin/ruby -w + +require 'src/play' +require 'src/selection' +# require 'systemu' + +pop = Population.new(5, 20) +generation_count = 1 +max_generations = 3 + +if File.file? 'player.log' + File.delete 'player.log' +end + +puts "Generation number #{generation_count}" +pop.individuals.sort {|x, y| x.genome <=> y.genome}.each {|i| puts "#{i.genome}"} + +while generation_count <= max_generations + start = Time.now + puts "Started at #{start}" + + new_population = [] + threads = [] + 1.upto(pop.individuals.length) do |i| + threads << Thread.new do + puts "Starting thread #{i}" + sleep 2 + player_count = rand(5) + 2 + pool_size = pop.individuals.length + players = [] + 1.upto(player_count) { players << pop.individuals[rand(pool_size)] } + IO.popen('ruby play-one-game.rb', 'r+') do |pipe| + players.each {|p| pipe << "#{p.genome}\n" ; puts "Game #{i}: putting player #{p.genome}"} +# players.each {|p| pipe << "#{p.genome}\n"} + pipe.close_write + new_population << Genome.new(pipe.readline.chomp.split(//).collect {|x| x.to_i}) + puts "Got result #{new_population[-1].genome}" + end +# game_input = (players.collect {|p| p.genome.to_s}).join("\n") +# game_result = '' +# puts "Calling game #{i} with input #{game_input}" +# status, game_result, stderr = systemu 'ruby play-one-game.rb', 'stdin' => game_input +# puts "Game #{i} returned #{game_result}" +# new_population << Genome.new(game_result.chomp.split(//).collect {|x| x.to_i}) + end + threads.each {|t| t.join} + end + + pop.individuals = new_population + + finish = Time.now + puts "Took #{finish - start} seconds" + pop1 = pop.crossover(0.7) + pop = pop1.mutation(0.05) + generation_count += 1 + puts "Generation number #{generation_count}" + pop.individuals.sort {|x, y| x.genome <=> y.genome}.each {|i| puts "#{i.genome}"} + $stdout.flush +end \ No newline at end of file diff --git a/.svn/text-base/systemu.rb.svn-base b/.svn/text-base/systemu.rb.svn-base new file mode 100644 index 0000000..27c0323 --- /dev/null +++ b/.svn/text-base/systemu.rb.svn-base @@ -0,0 +1,299 @@ +# vim: ts=2:sw=2:sts=2:et:fdm=marker +require 'tmpdir' +require 'socket' +require 'fileutils' +require 'rbconfig' +require 'thread' +require 'yaml' + +class Object + def systemu(*a, &b) SystemUniversal.new(*a, &b).systemu end +end + +class SystemUniversal +# +# constants +# + SystemUniversal::VERSION = '1.2.0' unless defined? SystemUniversal::VERSION + def version() SystemUniversal::VERSION end +# +# class methods +# + + @host = Socket.gethostname + @ppid = Process.ppid + @pid = Process.pid + @turd = ENV['SYSTEMU_TURD'] + + c = ::Config::CONFIG + ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT'] + @ruby = if system('%s -e 42' % ruby) + ruby + else + system('%s -e 42' % 'ruby') ? 'ruby' : warn('no ruby in PATH/CONFIG') + end + + class << self + %w( host ppid pid ruby turd ).each{|a| attr_accessor a} + end + +# +# instance methods +# + + def initialize argv, opts = {}, &block + getopt = getopts opts + + @argv = argv + @block = block + + @stdin = getopt[ ['stdin', 'in', '0', 0] ] + @stdout = getopt[ ['stdout', 'out', '1', 1] ] + @stderr = getopt[ ['stderr', 'err', '2', 2] ] + @env = getopt[ 'env' ] + @cwd = getopt[ 'cwd' ] + + @host = getopt[ 'host', self.class.host ] + @ppid = getopt[ 'ppid', self.class.ppid ] + @pid = getopt[ 'pid', self.class.pid ] + @ruby = getopt[ 'ruby', self.class.ruby ] + end + + def systemu + tmpdir do |tmp| + c = child_setup tmp + status = nil + + begin + thread = nil + + quietly{ + IO.popen "#{ @ruby } #{ c['program'] }", 'r+' do |pipe| + line = pipe.gets + case line + when %r/^pid: \d+$/ + cid = Integer line[%r/\d+/] + else + begin + buf = pipe.read + buf = "#{ line }#{ buf }" + e = Marshal.load buf + raise unless Exception === e + raise e + rescue + raise "wtf?\n#{ buf }\n" + end + end + thread = new_thread cid, @block if @block + pipe.read rescue nil + end + } + status = $? + ensure + if thread + begin + class << status + attr 'thread' + end + status.instance_eval{ @thread = thread } + rescue + 42 + end + end + end + + if @stdout or @stderr + open(c['stdout']){|f| relay f => @stdout} if @stdout + open(c['stderr']){|f| relay f => @stderr} if @stderr + status + else + [status, IO.read(c['stdout']), IO.read(c['stderr'])] + end + end + end + + def new_thread cid, block + q = Queue.new + Thread.new(cid) do |cid| + current = Thread.current + current.abort_on_exception = true + q.push current + block.call cid + end + q.pop + end + + def child_setup tmp + stdin = File.expand_path(File.join(tmp, 'stdin')) + stdout = File.expand_path(File.join(tmp, 'stdout')) + stderr = File.expand_path(File.join(tmp, 'stderr')) + program = File.expand_path(File.join(tmp, 'program')) + config = File.expand_path(File.join(tmp, 'config')) + + if @stdin + open(stdin, 'w'){|f| relay @stdin => f} + else + FileUtils.touch stdin + end + FileUtils.touch stdout + FileUtils.touch stderr + + c = {} + c['argv'] = @argv + c['env'] = @env + c['cwd'] = @cwd + c['stdin'] = stdin + c['stdout'] = stdout + c['stderr'] = stderr + c['program'] = program + open(config, 'w'){|f| YAML.dump c, f} + + open(program, 'w'){|f| f.write child_program(config)} + + c + end + + def quietly + v = $VERBOSE + $VERBOSE = nil + yield + ensure + $VERBOSE = v + end + + def child_program config + <<-program + PIPE = STDOUT.dup + begin + require 'yaml' + + config = YAML.load(IO.read('#{ config }')) + + argv = config['argv'] + env = config['env'] + cwd = config['cwd'] + stdin = config['stdin'] + stdout = config['stdout'] + stderr = config['stderr'] + + Dir.chdir cwd if cwd + env.each{|k,v| ENV[k.to_s] = v.to_s} if env + + STDIN.reopen stdin + STDOUT.reopen stdout + STDERR.reopen stderr + + PIPE.puts "pid: \#{ Process.pid }" + PIPE.flush ### the process is ready yo! + PIPE.close + + exec *argv + rescue Exception => e + PIPE.write Marshal.dump(e) rescue nil + exit 42 + end + program + end + + def relay srcdst + src, dst, ignored = srcdst.to_a.first + if src.respond_to? 'read' + while((buf = src.read(8192))); dst << buf; end + else + src.each{|buf| dst << buf} + end + end + + def tmpdir d = Dir.tmpdir, max = 42, &b + i = -1 and loop{ + i += 1 + + tmp = File.join d, "systemu_#{ @host }_#{ @ppid }_#{ @pid }_#{ rand }_#{ i += 1 }" + + begin + Dir.mkdir tmp + rescue Errno::EEXIST + raise if i >= max + next + end + + break( + if b + begin + b.call tmp + ensure + FileUtils.rm_rf tmp unless SystemU.turd + end + else + tmp + end + ) + } + end + + def getopts opts = {} + lambda do |*args| + keys, default, ignored = args + catch('opt') do + [keys].flatten.each do |key| + [key, key.to_s, key.to_s.intern].each do |key| + throw 'opt', opts[key] if opts.has_key?(key) + end + end + default + end + end + end +end + +SystemU = SystemUniversal unless defined? SystemU + + + + + + + + + + + + + +if $0 == __FILE__ +# +# date +# + date = %q( ruby -e" t = Time.now; STDOUT.puts t; STDERR.puts t " ) + + status, stdout, stderr = systemu date + p [status, stdout, stderr] + + status = systemu date, 1=>(stdout = '') + p [status, stdout] + + status = systemu date, 2=>(stderr = '') + p [status, stderr] +# +# sleep +# + sleep = %q( ruby -e" p(sleep(1)) " ) + status, stdout, stderr = systemu sleep + p [status, stdout, stderr] + + sleep = %q( ruby -e" p(sleep(42)) " ) + status, stdout, stderr = systemu(sleep){|cid| Process.kill 9, cid} + p [status, stdout, stderr] +# +# env +# + env = %q( ruby -e" p ENV['A'] " ) + status, stdout, stderr = systemu env, :env => {'A' => 42} + p [status, stdout, stderr] +# +# cwd +# + env = %q( ruby -e" p Dir.pwd " ) + status, stdout, stderr = systemu env, :cwd => Dir.tmpdir + p [status, stdout, stderr] +end diff --git a/README b/README new file mode 100644 index 0000000..9d4059c --- /dev/null +++ b/README @@ -0,0 +1,3 @@ +== TrapTheCap + +You should document your project here. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..9d6872f --- /dev/null +++ b/Rakefile @@ -0,0 +1,8 @@ +# +# To change this template, choose Tools | Templates +# and open the template in the editor. + + +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' diff --git a/doc/.svn/all-wcprops b/doc/.svn/all-wcprops new file mode 100644 index 0000000..51ff91d --- /dev/null +++ b/doc/.svn/all-wcprops @@ -0,0 +1,41 @@ +K 25 +svn:wc:ra_dav:version-url +V 42 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc +END +fr_file_index.html +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/27/TrapTheCap/trunk/doc/fr_file_index.html +END +fr_method_index.html +K 25 +svn:wc:ra_dav:version-url +V 63 +/svn/njae/!svn/ver/27/TrapTheCap/trunk/doc/fr_method_index.html +END +created.rid +K 25 +svn:wc:ra_dav:version-url +V 54 +/svn/njae/!svn/ver/27/TrapTheCap/trunk/doc/created.rid +END +fr_class_index.html +K 25 +svn:wc:ra_dav:version-url +V 62 +/svn/njae/!svn/ver/27/TrapTheCap/trunk/doc/fr_class_index.html +END +index.html +K 25 +svn:wc:ra_dav:version-url +V 53 +/svn/njae/!svn/ver/27/TrapTheCap/trunk/doc/index.html +END +rdoc-style.css +K 25 +svn:wc:ra_dav:version-url +V 57 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/rdoc-style.css +END diff --git a/doc/.svn/entries b/doc/.svn/entries new file mode 100644 index 0000000..e22df70 --- /dev/null +++ b/doc/.svn/entries @@ -0,0 +1,106 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +fr_file_index.html +file + + + + +2008-04-23T19:33:08.000000Z +d9df6971ec6f53c0482a1c8fe43d8436 +2008-04-23T19:36:22.892674Z +27 +neil + +fr_method_index.html +file + + + + +2008-04-23T19:33:08.000000Z +1a085831442a15f6af6f0c2d9c84c3fa +2008-04-23T19:36:22.892674Z +27 +neil + +files +dir + +created.rid +file + + + + +2008-04-23T19:33:08.000000Z +b0cccc2d369ec6e66e8f701185d7fa58 +2008-04-23T19:36:22.892674Z +27 +neil + +fr_class_index.html +file + + + + +2008-04-23T19:33:08.000000Z +83a238a1e55110f86717564e822b3b35 +2008-04-23T19:36:22.892674Z +27 +neil + +index.html +file + + + + +2008-04-23T19:33:08.000000Z +d3e476b2ab35951a8169d146ba68fb3d +2008-04-23T19:36:22.892674Z +27 +neil + +rdoc-style.css +file + + + + +2008-03-25T12:43:37.000000Z +07cc32aa3b88f9911fe43613a29650a3 +2008-03-25T12:46:59.166018Z +23 +neil + +classes +dir + diff --git a/doc/.svn/format b/doc/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/.svn/text-base/created.rid.svn-base b/doc/.svn/text-base/created.rid.svn-base new file mode 100644 index 0000000..89e065f --- /dev/null +++ b/doc/.svn/text-base/created.rid.svn-base @@ -0,0 +1 @@ +Wed, 23 Apr 2008 20:33:07 +0100 diff --git a/doc/.svn/text-base/fr_class_index.html.svn-base b/doc/.svn/text-base/fr_class_index.html.svn-base new file mode 100644 index 0000000..386985b --- /dev/null +++ b/doc/.svn/text-base/fr_class_index.html.svn-base @@ -0,0 +1,32 @@ + + + + + + + + Classes + + + + + +
+

Classes

+ +
+ + \ No newline at end of file diff --git a/doc/.svn/text-base/fr_file_index.html.svn-base b/doc/.svn/text-base/fr_file_index.html.svn-base new file mode 100644 index 0000000..1521d1c --- /dev/null +++ b/doc/.svn/text-base/fr_file_index.html.svn-base @@ -0,0 +1,30 @@ + + + + + + + + Files + + + + + +
+

Files

+ +
+ + \ No newline at end of file diff --git a/doc/.svn/text-base/fr_method_index.html.svn-base b/doc/.svn/text-base/fr_method_index.html.svn-base new file mode 100644 index 0000000..d9c748a --- /dev/null +++ b/doc/.svn/text-base/fr_method_index.html.svn-base @@ -0,0 +1,48 @@ + + + + + + + + Methods + + + + + +
+

Methods

+ +
+ + \ No newline at end of file diff --git a/doc/.svn/text-base/index.html.svn-base b/doc/.svn/text-base/index.html.svn-base new file mode 100644 index 0000000..e3c61b6 --- /dev/null +++ b/doc/.svn/text-base/index.html.svn-base @@ -0,0 +1,24 @@ + + + + + + + RDoc Documentation + + + + + + + + + + + \ No newline at end of file diff --git a/doc/.svn/text-base/rdoc-style.css.svn-base b/doc/.svn/text-base/rdoc-style.css.svn-base new file mode 100644 index 0000000..44c7b3d --- /dev/null +++ b/doc/.svn/text-base/rdoc-style.css.svn-base @@ -0,0 +1,208 @@ + +body { + font-family: Verdana,Arial,Helvetica,sans-serif; + font-size: 90%; + margin: 0; + margin-left: 40px; + padding: 0; + background: white; +} + +h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; } +h1 { font-size: 150%; } +h2,h3,h4 { margin-top: 1em; } + +a { background: #eef; color: #039; text-decoration: none; } +a:hover { background: #039; color: #eef; } + +/* Override the base stylesheet's Anchor inside a table cell */ +td > a { + background: transparent; + color: #039; + text-decoration: none; +} + +/* and inside a section title */ +.section-title > a { + background: transparent; + color: #eee; + text-decoration: none; +} + +/* === Structural elements =================================== */ + +div#index { + margin: 0; + margin-left: -40px; + padding: 0; + font-size: 90%; +} + + +div#index a { + margin-left: 0.7em; +} + +div#index .section-bar { + margin-left: 0px; + padding-left: 0.7em; + background: #ccc; + font-size: small; +} + + +div#classHeader, div#fileHeader { + width: auto; + color: white; + padding: 0.5em 1.5em 0.5em 1.5em; + margin: 0; + margin-left: -40px; + border-bottom: 3px solid #006; +} + +div#classHeader a, div#fileHeader a { + background: inherit; + color: white; +} + +div#classHeader td, div#fileHeader td { + background: inherit; + color: white; +} + + +div#fileHeader { + background: #057; +} + +div#classHeader { + background: #048; +} + + +.class-name-in-header { + font-size: 180%; + font-weight: bold; +} + + +div#bodyContent { + padding: 0 1.5em 0 1.5em; +} + +div#description { + padding: 0.5em 1.5em; + background: #efefef; + border: 1px dotted #999; +} + +div#description h1,h2,h3,h4,h5,h6 { + color: #125;; + background: transparent; +} + +div#validator-badges { + text-align: center; +} +div#validator-badges img { border: 0; } + +div#copyright { + color: #333; + background: #efefef; + font: 0.75em sans-serif; + margin-top: 5em; + margin-bottom: 0; + padding: 0.5em 2em; +} + + +/* === Classes =================================== */ + +table.header-table { + color: white; + font-size: small; +} + +.type-note { + font-size: small; + color: #DEDEDE; +} + +.xxsection-bar { + background: #eee; + color: #333; + padding: 3px; +} + +.section-bar { + color: #333; + border-bottom: 1px solid #999; + margin-left: -20px; +} + + +.section-title { + background: #79a; + color: #eee; + padding: 3px; + margin-top: 2em; + margin-left: -30px; + border: 1px solid #999; +} + +.top-aligned-row { vertical-align: top } +.bottom-aligned-row { vertical-align: bottom } + +/* --- Context section classes ----------------------- */ + +.context-row { } +.context-item-name { font-family: monospace; font-weight: bold; color: black; } +.context-item-value { font-size: small; color: #448; } +.context-item-desc { color: #333; padding-left: 2em; } + +/* --- Method classes -------------------------- */ +.method-detail { + background: #efefef; + padding: 0; + margin-top: 0.5em; + margin-bottom: 1em; + border: 1px dotted #ccc; +} +.method-heading { + color: black; + background: #ccc; + border-bottom: 1px solid #666; + padding: 0.2em 0.5em 0 0.5em; +} +.method-signature { color: black; background: inherit; } +.method-name { font-weight: bold; } +.method-args { font-style: italic; } +.method-description { padding: 0 0.5em 0 0.5em; } + +/* --- Source code sections -------------------- */ + +a.source-toggle { font-size: 90%; } +div.method-source-code { + background: #262626; + color: #ffdead; + margin: 1em; + padding: 0.5em; + border: 1px dashed #999; + overflow: hidden; +} + +div.method-source-code pre { color: #ffdead; overflow: hidden; } + +/* --- Ruby keyword styles --------------------- */ + +.standalone-code { background: #221111; color: #ffdead; overflow: hidden; } + +.ruby-constant { color: #7fffd4; background: transparent; } +.ruby-keyword { color: #00ffff; background: transparent; } +.ruby-ivar { color: #eedd82; background: transparent; } +.ruby-operator { color: #00ffee; background: transparent; } +.ruby-identifier { color: #ffdead; background: transparent; } +.ruby-node { color: #ffa07a; background: transparent; } +.ruby-comment { color: #b22222; font-weight: bold; background: transparent; } +.ruby-regexp { color: #ffa07a; background: transparent; } +.ruby-value { color: #7fffd4; background: transparent; } \ No newline at end of file diff --git a/doc/classes/.svn/all-wcprops b/doc/classes/.svn/all-wcprops new file mode 100644 index 0000000..1f4f79d --- /dev/null +++ b/doc/classes/.svn/all-wcprops @@ -0,0 +1,137 @@ +K 25 +svn:wc:ra_dav:version-url +V 50 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes +END +Array.html +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Array.html +END +GameWonInHistoryError.html +K 25 +svn:wc:ra_dav:version-url +V 77 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameWonInHistoryError.html +END +InvalidCaptureError.html +K 25 +svn:wc:ra_dav:version-url +V 75 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/InvalidCaptureError.html +END +Piece.html +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Piece.html +END +Board.html +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Board.html +END +InvalidMoveError.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/InvalidMoveError.html +END +Population.html +K 25 +svn:wc:ra_dav:version-url +V 66 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.html +END +GameWonNotice.html +K 25 +svn:wc:ra_dav:version-url +V 69 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameWonNotice.html +END +InvalidMoveInHistoryError.html +K 25 +svn:wc:ra_dav:version-url +V 81 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/InvalidMoveInHistoryError.html +END +Position.html +K 25 +svn:wc:ra_dav:version-url +V 64 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Position.html +END +Fixnum.html +K 25 +svn:wc:ra_dav:version-url +V 62 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Fixnum.html +END +String.html +K 25 +svn:wc:ra_dav:version-url +V 62 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/String.html +END +InvalidRobotError.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/InvalidRobotError.html +END +Move.html +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Move.html +END +NoInputFileError.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/NoInputFileError.html +END +IO.html +K 25 +svn:wc:ra_dav:version-url +V 58 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/IO.html +END +GameHandler.html +K 25 +svn:wc:ra_dav:version-url +V 67 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameHandler.html +END +GameTest.html +K 25 +svn:wc:ra_dav:version-url +V 64 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.html +END +Game.html +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.html +END +GameState.html +K 25 +svn:wc:ra_dav:version-url +V 65 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameState.html +END +Genome.html +K 25 +svn:wc:ra_dav:version-url +V 62 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Genome.html +END +Potential_player.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.html +END diff --git a/doc/classes/.svn/entries b/doc/classes/.svn/entries new file mode 100644 index 0000000..5dd6c7b --- /dev/null +++ b/doc/classes/.svn/entries @@ -0,0 +1,331 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +Population.src +dir + +Array.html +file + + + + +2008-04-23T19:33:08.000000Z +26b3b2bd12f11b95f54fcce6db73b47a +2008-10-16T14:11:23.436422Z +41 + +GameWonInHistoryError.html +file + + + + +2008-03-25T11:48:00.000000Z +f43593c452c84e51cf4e62d5738d2e08 +2008-03-25T12:46:59.166018Z +23 +neil + +InvalidCaptureError.html +file + + + + +2008-03-25T12:43:37.000000Z +bbd86f1b1971cfd97ed5b058377a3869 +2008-03-25T12:46:59.166018Z +23 +neil + +Board.html +file + + + + +2008-03-28T15:44:42.000000Z +72da0a082ed92be30d7e992745a0480d +2008-10-16T14:11:23.436422Z +41 +neil + +Position.src +dir + +Fixnum.src +dir + +String.src +dir + +Genome.src +dir + +GameWonNotice.html +file + + + + +2008-03-25T12:43:37.000000Z +332eba20be7511005e22f5f01ca6faf5 +2008-03-25T12:46:59.166018Z +23 +neil + +Array.src +dir + +InvalidRobotError.html +file + + + + +2008-03-25T11:48:00.000000Z +46d5abef635a1aa02f9c4859ad94b4c3 +2008-03-25T12:46:59.166018Z +23 +neil + +Move.html +file + + + + +2008-03-28T15:44:42.000000Z +463b73125f1c32b9e6a592818d38890b +2008-10-16T14:11:23.436422Z +41 +neil + +Piece.src +dir + +GameState.html +file + + + + +2008-03-28T15:44:42.000000Z +f14a4e9cabcc1fb062a8cd471b5a6be6 +2008-10-16T14:11:23.436422Z +41 +neil + +Piece.html +file + + + + +2008-03-28T15:44:42.000000Z +6b11191e3b5e3ef0eaf4fe36cad43812 +2008-10-16T14:11:23.436422Z +41 +neil + +InvalidMoveError.html +file + + + + +2008-03-25T12:43:37.000000Z +3c00b961119ca2812c61cafcadc36f67 +2008-03-25T12:46:59.166018Z +23 +neil + +Move.src +dir + +IO.src +dir + +GameHandler.src +dir + +Population.html +file + + + + +2008-04-23T19:33:08.000000Z +ff38b0da69ec518f6f4022971dd47ac9 +2008-10-16T14:11:23.436422Z +41 + +Game.src +dir + +GameTest.src +dir + +GameState.src +dir + +Potential_player.src +dir + +InvalidMoveInHistoryError.html +file + + + + +2008-03-25T11:48:00.000000Z +01e22991cb33522bab7219decf57a4cf +2008-03-25T12:46:59.166018Z +23 +neil + +Position.html +file + + + + +2008-03-28T15:44:42.000000Z +9b00d1c61cce99489bc88976682e7c0b +2008-10-16T14:11:23.436422Z +41 +neil + +Fixnum.html +file + + + + +2008-04-23T19:33:08.000000Z +0a520ee31fa6d1653d81cbb1435bfc91 +2008-10-16T14:11:23.436422Z +41 + +String.html +file + + + + +2008-03-28T15:44:42.000000Z +4096019548a8f5bd51ff6a68321876f9 +2008-10-16T14:11:23.436422Z +41 +neil + +NoInputFileError.html +file + + + + +2008-03-25T11:48:00.000000Z +66fd610fc6c5b6a79e3f5dd0f6d20fac +2008-03-25T12:46:59.166018Z +23 +neil + +GameHandler.html +file + + + + +2008-04-23T19:33:08.000000Z +504212682c4aee8c7d4d557c90dbcd3e +2008-10-16T14:11:23.436422Z +41 + +IO.html +file + + + + +2008-03-28T15:44:42.000000Z +ba16c7a024d72969f3df04c9749a788c +2008-10-16T14:11:23.436422Z +41 +neil + +Game.html +file + + + + +2008-03-28T15:44:42.000000Z +c9bd061a736b2a16dafe021554d704ce +2008-10-16T14:11:23.436422Z +41 +neil + +GameTest.html +file + + + + +2008-03-28T15:44:42.000000Z +c7123d7f248384c7db0330ce33e8c2ed +2008-10-16T14:11:23.436422Z +41 +neil + +Board.src +dir + +Genome.html +file + + + + +2008-04-23T19:33:08.000000Z +9055b137b7b63d0304a000d45a5fb49a +2008-10-16T14:11:23.436422Z +41 + +Potential_player.html +file + + + + +2008-04-23T19:33:08.000000Z +709b3f794da92de66d4e59fbeb9d4449 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/.svn/format b/doc/classes/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/.svn/text-base/Array.html.svn-base b/doc/classes/.svn/text-base/Array.html.svn-base new file mode 100644 index 0000000..1a56172 --- /dev/null +++ b/doc/classes/.svn/text-base/Array.html.svn-base @@ -0,0 +1,167 @@ + + + + + + Class: Array + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassArray
In: + + lib/libgenetics.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ + + +
+ +
+

Methods

+ +
+ gray_decode   + gray_encode   + to_decimal   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Board.html.svn-base b/doc/classes/.svn/text-base/Board.html.svn-base new file mode 100644 index 0000000..c03f754 --- /dev/null +++ b/doc/classes/.svn/text-base/Board.html.svn-base @@ -0,0 +1,243 @@ + + + + + + Class: Board + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassBoard
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+The game board +

+ +
+ + +
+ +
+

Methods

+ +
+ cache_valid_moves   + layout   + new   + to_s   + to_str   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + + + + + + +
centre [R] 
distance_between [R] 
positions [R] 
valid_moves [R] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

+A laborious procedure to create all the positions and tie them all together +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Precompute the valid moves for this board, and the distances between each +pair of positions +

+
+
+ +
+ + + + +
+

+For each position, show its name and what it touches +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Fixnum.html.svn-base b/doc/classes/.svn/text-base/Fixnum.html.svn-base new file mode 100644 index 0000000..ba0b706 --- /dev/null +++ b/doc/classes/.svn/text-base/Fixnum.html.svn-base @@ -0,0 +1,137 @@ + + + + + + Class: Fixnum + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassFixnum
In: + + lib/libgenetics.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ + + +
+ +
+

Methods

+ +
+ to_bitstring   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ + + + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Game.html.svn-base b/doc/classes/.svn/text-base/Game.html.svn-base new file mode 100644 index 0000000..7c6f30b --- /dev/null +++ b/doc/classes/.svn/text-base/Game.html.svn-base @@ -0,0 +1,355 @@ + + + + + + Class: Game + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGame
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A game of Trap the Cap. It keeps a history of all previous states. +

+ +
+ + +
+ +
+

Methods

+ +
+ apply_move!   + apply_moves!   + build_state_string   + new   + next_player!   + possible_moves   + read_game   + show_state   + to_s   + to_str   + undo_move!   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
board [R] 
current_player [R] 
history [R] 
pieces [R] 
players [R] 
+
+
+ + + + +
+

Public Class methods

+ + + +
+ + + + +
+

+Given a set of lines from an input file, turn them into a Game object and a set of Move +objects. Note the multiple return values. Class method +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Apply a single move to a game. +

+
+
+ +
+ + + + +
+

+Apply a list of moves in order +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+

+Set the current player to be the next player +

+
+
+ +
+ + + + +
+

+Return an array of all possible moves from this state, given the die roll +and the active player +

+
+
+ +
+ + + + +
+

+Show the state of the board +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+

+Undo a move +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/GameHandler.html.svn-base b/doc/classes/.svn/text-base/GameHandler.html.svn-base new file mode 100644 index 0000000..874113e --- /dev/null +++ b/doc/classes/.svn/text-base/GameHandler.html.svn-base @@ -0,0 +1,181 @@ + + + + + + Class: GameHandler + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameHandler
In: + + src/play.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Play a game to completion, given a set of player agents. +

+ +
+ + +
+ +
+

Methods

+ +
+ new   + play   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + +
game [R] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

+Create a game handler that uses a set of players +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Play a game of Trap the Cap. If players make illegal moves, disqualify them +and restart the game. Terminate the game if there‘s a winner, +there‘s only one player left, or the game has gone on too long. +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/GameState.html.svn-base b/doc/classes/.svn/text-base/GameState.html.svn-base new file mode 100644 index 0000000..dbfa0c2 --- /dev/null +++ b/doc/classes/.svn/text-base/GameState.html.svn-base @@ -0,0 +1,185 @@ + + + + + + Class: GameState + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameState
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A class to record each of the states previously found in a game. Note that +this is a deep copy of the pieces and what they‘ve captured, so +you‘ll need to convert back +

+ +
+ + +
+ +
+

Methods

+ +
+ ==   + new   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + +
move [RW] 
pieces_after_move [RW] 
player [RW] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/GameTest.html.svn-base b/doc/classes/.svn/text-base/GameTest.html.svn-base new file mode 100644 index 0000000..e6067b2 --- /dev/null +++ b/doc/classes/.svn/text-base/GameTest.html.svn-base @@ -0,0 +1,287 @@ + + + + + + Class: GameTest + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameTest
In: + + test/libttc_test.rb + +
+
Parent: + Test::Unit::TestCase +
+
+ + +
+ + + +
+ + + +
+ + + +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + + + + +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/GameWonInHistoryError.html.svn-base b/doc/classes/.svn/text-base/GameWonInHistoryError.html.svn-base new file mode 100644 index 0000000..1814a1a --- /dev/null +++ b/doc/classes/.svn/text-base/GameWonInHistoryError.html.svn-base @@ -0,0 +1,111 @@ + + + + + + Class: GameWonInHistoryError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameWonInHistoryError
In: + + src/ttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/GameWonNotice.html.svn-base b/doc/classes/.svn/text-base/GameWonNotice.html.svn-base new file mode 100644 index 0000000..3e1e3fc --- /dev/null +++ b/doc/classes/.svn/text-base/GameWonNotice.html.svn-base @@ -0,0 +1,118 @@ + + + + + + Class: GameWonNotice + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameWonNotice
In: + + lib/libttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ +
+

+Game is won when only one player has uncaptured +pieces +

+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Genome.html.svn-base b/doc/classes/.svn/text-base/Genome.html.svn-base new file mode 100644 index 0000000..496f785 --- /dev/null +++ b/doc/classes/.svn/text-base/Genome.html.svn-base @@ -0,0 +1,237 @@ + + + + + + Class: Genome + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGenome
In: + + lib/libgenetics.rb + +
+ + lib/libpplayer.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A single genome in a population +

+ +
+ + +
+ +
+

Methods

+ +
+ crossover   + mutate   + mutate!   + new   + to_potential_player   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + +
genome [RW] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

+Create a random genome of the given length +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Crossover two genomes at the given point +

+
+
+ +
+ + + + +
+

+Mutate a genome with the given rate per bit +

+
+
+ +
+ + + + +
+

+Mutate a genome in-place with the given rate per bit +

+
+
+ +
+ + + + +
+

+Create a potential player from a genome +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/IO.html.svn-base b/doc/classes/.svn/text-base/IO.html.svn-base new file mode 100644 index 0000000..304be5a --- /dev/null +++ b/doc/classes/.svn/text-base/IO.html.svn-base @@ -0,0 +1,146 @@ + + + + + + Class: IO + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassIO
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Read a game description file and convert it into a Game object and set of Move +objects. Note that Game.read_game method +returns multiple values, so this one does too. +

+ +
+ + +
+ +
+

Methods

+ +
+ read_game   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Class methods

+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/InvalidCaptureError.html.svn-base b/doc/classes/.svn/text-base/InvalidCaptureError.html.svn-base new file mode 100644 index 0000000..9e8d0a8 --- /dev/null +++ b/doc/classes/.svn/text-base/InvalidCaptureError.html.svn-base @@ -0,0 +1,117 @@ + + + + + + Class: InvalidCaptureError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassInvalidCaptureError
In: + + lib/libttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ +
+

+Pieces can only capture pieces that they‘re on. +

+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/InvalidMoveError.html.svn-base b/doc/classes/.svn/text-base/InvalidMoveError.html.svn-base new file mode 100644 index 0000000..e897961 --- /dev/null +++ b/doc/classes/.svn/text-base/InvalidMoveError.html.svn-base @@ -0,0 +1,117 @@ + + + + + + Class: InvalidMoveError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassInvalidMoveError
In: + + lib/libttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ +
+

+Moves can only be [1..6] spaces +

+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/InvalidMoveInHistoryError.html.svn-base b/doc/classes/.svn/text-base/InvalidMoveInHistoryError.html.svn-base new file mode 100644 index 0000000..6c1456b --- /dev/null +++ b/doc/classes/.svn/text-base/InvalidMoveInHistoryError.html.svn-base @@ -0,0 +1,111 @@ + + + + + + Class: InvalidMoveInHistoryError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassInvalidMoveInHistoryError
In: + + src/ttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/InvalidRobotError.html.svn-base b/doc/classes/.svn/text-base/InvalidRobotError.html.svn-base new file mode 100644 index 0000000..f68f98e --- /dev/null +++ b/doc/classes/.svn/text-base/InvalidRobotError.html.svn-base @@ -0,0 +1,111 @@ + + + + + + Class: InvalidRobotError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassInvalidRobotError
In: + + src/ttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Move.html.svn-base b/doc/classes/.svn/text-base/Move.html.svn-base new file mode 100644 index 0000000..ac70219 --- /dev/null +++ b/doc/classes/.svn/text-base/Move.html.svn-base @@ -0,0 +1,212 @@ + + + + + + Class: Move + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassMove
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A move in a game +

+ +
+ + +
+ +
+

Methods

+ +
+ new   + to_s   + to_str   + via_base?   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + +
destination [R] 
piece [R] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+

+Write a move to a string Note the inverse, String#to_move, is defined below +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/NoInputFileError.html.svn-base b/doc/classes/.svn/text-base/NoInputFileError.html.svn-base new file mode 100644 index 0000000..590dcb7 --- /dev/null +++ b/doc/classes/.svn/text-base/NoInputFileError.html.svn-base @@ -0,0 +1,111 @@ + + + + + + Class: NoInputFileError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassNoInputFileError
In: + + src/ttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Piece.html.svn-base b/doc/classes/.svn/text-base/Piece.html.svn-base new file mode 100644 index 0000000..5a4a698 --- /dev/null +++ b/doc/classes/.svn/text-base/Piece.html.svn-base @@ -0,0 +1,251 @@ + + + + + + Class: Piece + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassPiece
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Each piece on the board is an object +

+ +
+ + +
+ +
+

Methods

+ +
+ capture   + move_to   + name   + new   + to_s   + to_str   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + + + + + + +
captured [RW] 
colour [R] 
contains [RW] 
position [RW] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+

+Caputre another piece +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Population.html.svn-base b/doc/classes/.svn/text-base/Population.html.svn-base new file mode 100644 index 0000000..2d66c0d --- /dev/null +++ b/doc/classes/.svn/text-base/Population.html.svn-base @@ -0,0 +1,255 @@ + + + + + + Class: Population + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassPopulation
In: + + src/selection.rb + +
+ + lib/libgenetics.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A population of genomes +

+ +
+ + +
+ +
+

Methods

+ + +
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + +
individuals [RW] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

+Create a population of a given size +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Perform the crossover step in a +population, giving a new population +

+
+
+ + + +
+ + + + +
+

+Perform the mutation step in a +population, giving a new population +

+
+
+ +
+ + + + +
+

+Use tournament selection to pick an individual for the next generation +

+
+
+ +
+ + + + +
+

+Select a new population the same size +as the current population +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Position.html.svn-base b/doc/classes/.svn/text-base/Position.html.svn-base new file mode 100644 index 0000000..02b8993 --- /dev/null +++ b/doc/classes/.svn/text-base/Position.html.svn-base @@ -0,0 +1,235 @@ + + + + + + Class: Position + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassPosition
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Each possible position for a piece is an object Each neighbour is another +position object +

+ +
+ + +
+ +
+

Methods

+ +
+ base?   + new   + safe?   + to_s   + to_str   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + +
contains [RW] 
neighbours [RW] 
place [R] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+

+Is this position a base? +

+
+
+ +
+ + + + +
+

+is this position a safety one (i.e. no captures allowed)? +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/Potential_player.html.svn-base b/doc/classes/.svn/text-base/Potential_player.html.svn-base new file mode 100644 index 0000000..2940688 --- /dev/null +++ b/doc/classes/.svn/text-base/Potential_player.html.svn-base @@ -0,0 +1,251 @@ + + + + + + Class: Potential_player + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassPotential_player
In: + + lib/libpplayer.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Play Trap the Cap by using potential fields. For each possible move, +calculate the field strength and pick the move with the lowest potential +

+ +
+ + +
+ +
+

Methods

+ +
+ best_move   + new   + score_position   + to_bitstring   + to_genome   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
base_pull [R] 
capture_bonus [R] 
enemy_pull [R] 
friend_pull [R] 
safe_bonus [R] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+

+Find the best move of the possible ones +

+
+
+ +
+ + + + +
+

+Calculate the potential score of a position for a given player +

+
+
+ +
+ + + + +
+

+Convert a player to a bitstring +

+
+
+ +
+ + + + +
+

+Convert a player to a genome +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/.svn/text-base/String.html.svn-base b/doc/classes/.svn/text-base/String.html.svn-base new file mode 100644 index 0000000..ea7c8cc --- /dev/null +++ b/doc/classes/.svn/text-base/String.html.svn-base @@ -0,0 +1,145 @@ + + + + + + Class: String + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassString
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Extension to String class to convert a +move-description string into a Move object. This is +the inverse of the Move#to_s method +

+ +
+ + +
+ +
+

Methods

+ +
+ to_move   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Array.html b/doc/classes/Array.html new file mode 100644 index 0000000..1a56172 --- /dev/null +++ b/doc/classes/Array.html @@ -0,0 +1,167 @@ + + + + + + Class: Array + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassArray
In: + + lib/libgenetics.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ + + +
+ +
+

Methods

+ +
+ gray_decode   + gray_encode   + to_decimal   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Array.src/.svn/all-wcprops b/doc/classes/Array.src/.svn/all-wcprops new file mode 100644 index 0000000..a1c66b2 --- /dev/null +++ b/doc/classes/Array.src/.svn/all-wcprops @@ -0,0 +1,41 @@ +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Array.src +END +M000013.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Array.src/M000013.html +END +M000005.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Array.src/M000005.html +END +M000014.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Array.src/M000014.html +END +M000006.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Array.src/M000006.html +END +M000015.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Array.src/M000015.html +END +M000007.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Array.src/M000007.html +END diff --git a/doc/classes/Array.src/.svn/entries b/doc/classes/Array.src/.svn/entries new file mode 100644 index 0000000..f105857 --- /dev/null +++ b/doc/classes/Array.src/.svn/entries @@ -0,0 +1,82 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Array.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +M000013.html +file + + + + +2008-04-23T19:33:07.000000Z +baa109e01879922b8579d90e8477b359 +2008-10-16T14:11:23.436422Z +41 + +M000005.html +file + + + + +2008-04-23T19:30:16.000000Z +54ffa8dd6a5930189670ec82b377a16f +2008-10-16T14:11:23.436422Z +41 + +M000014.html +file + + + + +2008-04-23T19:33:07.000000Z +d5c3211d58ed9c08da6a030da6fffb8c +2008-10-16T14:11:23.436422Z +41 + +M000015.html +file + + + + +2008-04-23T19:33:07.000000Z +86c0658d8f6cc47e238122886f1ea7c6 +2008-10-16T14:11:23.436422Z +41 + +M000006.html +file + + + + +2008-04-23T19:30:16.000000Z +377d87bd4a639828465f40da231c77b4 +2008-10-16T14:11:23.436422Z +41 + +M000007.html +file + + + + +2008-04-23T19:30:16.000000Z +a9c7f3219152d1a8cf0ea56f8bea6d12 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/Array.src/.svn/format b/doc/classes/Array.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Array.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Array.src/.svn/text-base/M000005.html.svn-base b/doc/classes/Array.src/.svn/text-base/M000005.html.svn-base new file mode 100644 index 0000000..a08b680 --- /dev/null +++ b/doc/classes/Array.src/.svn/text-base/M000005.html.svn-base @@ -0,0 +1,24 @@ + + + + + + to_decimal (Array) + + + + +
# File lib/libgenetics.rb, line 71
+  def to_decimal
+    val = 0
+    bits = self.dup
+    while not bits.empty?
+      val = val * 2 + bits[0]
+      bits = bits[1..bits.length]
+    end
+    val
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/.svn/text-base/M000006.html.svn-base b/doc/classes/Array.src/.svn/text-base/M000006.html.svn-base new file mode 100644 index 0000000..b836fcb --- /dev/null +++ b/doc/classes/Array.src/.svn/text-base/M000006.html.svn-base @@ -0,0 +1,26 @@ + + + + + + gray_encode (Array) + + + + +
# File lib/libgenetics.rb, line 81
+  def gray_encode
+    gray = self[0..0]
+    (1...self.length).each do |i|
+      if (self[i - 1] == 1) ^ (self[i] == 1)
+        gray << 1
+      else
+        gray << 0
+      end
+    end
+    gray
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/.svn/text-base/M000007.html.svn-base b/doc/classes/Array.src/.svn/text-base/M000007.html.svn-base new file mode 100644 index 0000000..38d43d2 --- /dev/null +++ b/doc/classes/Array.src/.svn/text-base/M000007.html.svn-base @@ -0,0 +1,26 @@ + + + + + + gray_decode (Array) + + + + +
# File lib/libgenetics.rb, line 93
+  def gray_decode
+    binary = self[0..0]
+    (1...self.length).each do |i|
+      if (binary[i - 1] == 1) ^ (self[i] == 1)
+        binary << 1
+      else
+        binary << 0
+      end
+    end
+    binary
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/.svn/text-base/M000013.html.svn-base b/doc/classes/Array.src/.svn/text-base/M000013.html.svn-base new file mode 100644 index 0000000..55b3c97 --- /dev/null +++ b/doc/classes/Array.src/.svn/text-base/M000013.html.svn-base @@ -0,0 +1,24 @@ + + + + + + to_decimal (Array) + + + + +
# File lib/libgenetics.rb, line 74
+  def to_decimal
+    val = 0
+    bits = self.dup
+    while not bits.empty?
+      val = val * 2 + bits[0]
+      bits = bits[1..bits.length]
+    end
+    val
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/.svn/text-base/M000014.html.svn-base b/doc/classes/Array.src/.svn/text-base/M000014.html.svn-base new file mode 100644 index 0000000..77d8cc3 --- /dev/null +++ b/doc/classes/Array.src/.svn/text-base/M000014.html.svn-base @@ -0,0 +1,26 @@ + + + + + + gray_encode (Array) + + + + +
# File lib/libgenetics.rb, line 84
+  def gray_encode
+    gray = self[0..0]
+    (1...self.length).each do |i|
+      if (self[i - 1] == 1) ^ (self[i] == 1)
+        gray << 1
+      else
+        gray << 0
+      end
+    end
+    gray
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/.svn/text-base/M000015.html.svn-base b/doc/classes/Array.src/.svn/text-base/M000015.html.svn-base new file mode 100644 index 0000000..94bcd90 --- /dev/null +++ b/doc/classes/Array.src/.svn/text-base/M000015.html.svn-base @@ -0,0 +1,26 @@ + + + + + + gray_decode (Array) + + + + +
# File lib/libgenetics.rb, line 96
+  def gray_decode
+    binary = self[0..0]
+    (1...self.length).each do |i|
+      if (binary[i - 1] == 1) ^ (self[i] == 1)
+        binary << 1
+      else
+        binary << 0
+      end
+    end
+    binary
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/M000005.html b/doc/classes/Array.src/M000005.html new file mode 100644 index 0000000..a08b680 --- /dev/null +++ b/doc/classes/Array.src/M000005.html @@ -0,0 +1,24 @@ + + + + + + to_decimal (Array) + + + + +
# File lib/libgenetics.rb, line 71
+  def to_decimal
+    val = 0
+    bits = self.dup
+    while not bits.empty?
+      val = val * 2 + bits[0]
+      bits = bits[1..bits.length]
+    end
+    val
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/M000006.html b/doc/classes/Array.src/M000006.html new file mode 100644 index 0000000..b836fcb --- /dev/null +++ b/doc/classes/Array.src/M000006.html @@ -0,0 +1,26 @@ + + + + + + gray_encode (Array) + + + + +
# File lib/libgenetics.rb, line 81
+  def gray_encode
+    gray = self[0..0]
+    (1...self.length).each do |i|
+      if (self[i - 1] == 1) ^ (self[i] == 1)
+        gray << 1
+      else
+        gray << 0
+      end
+    end
+    gray
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/M000007.html b/doc/classes/Array.src/M000007.html new file mode 100644 index 0000000..38d43d2 --- /dev/null +++ b/doc/classes/Array.src/M000007.html @@ -0,0 +1,26 @@ + + + + + + gray_decode (Array) + + + + +
# File lib/libgenetics.rb, line 93
+  def gray_decode
+    binary = self[0..0]
+    (1...self.length).each do |i|
+      if (binary[i - 1] == 1) ^ (self[i] == 1)
+        binary << 1
+      else
+        binary << 0
+      end
+    end
+    binary
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/M000013.html b/doc/classes/Array.src/M000013.html new file mode 100644 index 0000000..55b3c97 --- /dev/null +++ b/doc/classes/Array.src/M000013.html @@ -0,0 +1,24 @@ + + + + + + to_decimal (Array) + + + + +
# File lib/libgenetics.rb, line 74
+  def to_decimal
+    val = 0
+    bits = self.dup
+    while not bits.empty?
+      val = val * 2 + bits[0]
+      bits = bits[1..bits.length]
+    end
+    val
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/M000014.html b/doc/classes/Array.src/M000014.html new file mode 100644 index 0000000..77d8cc3 --- /dev/null +++ b/doc/classes/Array.src/M000014.html @@ -0,0 +1,26 @@ + + + + + + gray_encode (Array) + + + + +
# File lib/libgenetics.rb, line 84
+  def gray_encode
+    gray = self[0..0]
+    (1...self.length).each do |i|
+      if (self[i - 1] == 1) ^ (self[i] == 1)
+        gray << 1
+      else
+        gray << 0
+      end
+    end
+    gray
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Array.src/M000015.html b/doc/classes/Array.src/M000015.html new file mode 100644 index 0000000..94bcd90 --- /dev/null +++ b/doc/classes/Array.src/M000015.html @@ -0,0 +1,26 @@ + + + + + + gray_decode (Array) + + + + +
# File lib/libgenetics.rb, line 96
+  def gray_decode
+    binary = self[0..0]
+    (1...self.length).each do |i|
+      if (binary[i - 1] == 1) ^ (self[i] == 1)
+        binary << 1
+      else
+        binary << 0
+      end
+    end
+    binary
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.html b/doc/classes/Board.html new file mode 100644 index 0000000..c03f754 --- /dev/null +++ b/doc/classes/Board.html @@ -0,0 +1,243 @@ + + + + + + Class: Board + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassBoard
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+The game board +

+ +
+ + +
+ +
+

Methods

+ +
+ cache_valid_moves   + layout   + new   + to_s   + to_str   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + + + + + + +
centre [R] 
distance_between [R] 
positions [R] 
valid_moves [R] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

+A laborious procedure to create all the positions and tie them all together +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Precompute the valid moves for this board, and the distances between each +pair of positions +

+
+
+ +
+ + + + +
+

+For each position, show its name and what it touches +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/all-wcprops b/doc/classes/Board.src/.svn/all-wcprops new file mode 100644 index 0000000..b013bec --- /dev/null +++ b/doc/classes/Board.src/.svn/all-wcprops @@ -0,0 +1,83 @@ +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Board.src +END +M000024.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Board.src/M000024.html +END +M000034.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Board.src/M000034.html +END +M000025.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Board.src/M000025.html +END +M000035.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Board.src/M000035.html +END +M000026.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Board.src/M000026.html +END +M000036.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Board.src/M000036.html +END +M000027.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Board.src/M000027.html +END +M000054.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Board.src/M000054.html +END +M000037.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Board.src/M000037.html +END +M000055.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Board.src/M000055.html +END +M000056.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Board.src/M000056.html +END +M000057.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Board.src/M000057.html +END +M000058.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Board.src/M000058.html +END diff --git a/doc/classes/Board.src/.svn/entries b/doc/classes/Board.src/.svn/entries new file mode 100644 index 0000000..9df2703 --- /dev/null +++ b/doc/classes/Board.src/.svn/entries @@ -0,0 +1,179 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Board.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000024.html +file + + + + +2008-03-25T12:43:37.000000Z +c73359a71a510ffc4d3cd42c30c91679 +2008-03-28T15:47:09.723420Z +24 +neil + +M000034.html +file + + + + +2008-03-25T11:48:00.000000Z +4cce8fb72c33b1e626b2cd690b035c11 +2008-03-25T12:46:59.166018Z +23 +neil + +M000025.html +file + + + + +2008-03-25T12:43:37.000000Z +72b3c1baab11f2df5d94ef1c3b6e5a20 +2008-03-28T15:47:09.723420Z +24 +neil + +M000035.html +file + + + + +2008-03-25T11:48:00.000000Z +f9a730ba1d43f01125364803c2fc13f8 +2008-03-25T12:46:59.166018Z +23 +neil + +M000026.html +file + + + + +2008-03-25T12:43:37.000000Z +6afd410d4c4643f3805a0a6302d5d6c5 +2008-03-28T15:47:09.723420Z +24 +neil + +M000036.html +file + + + + +2008-03-25T11:48:00.000000Z +f48b5b76b4eaf398da6cea4a79ab09e5 +2008-03-25T12:46:59.166018Z +23 +neil + +M000027.html +file + + + + +2008-03-25T12:43:37.000000Z +8245dd5f67b41834d7dd58cdb91fce10 +2008-03-28T15:47:09.723420Z +24 +neil + +M000054.html +file + + + + +2008-03-28T15:44:42.000000Z +3c4533b3f9fdf56f2f69dfafd8c5f667 +2008-10-16T14:11:23.436422Z +41 + +M000037.html +file + + + + +2008-03-25T11:48:00.000000Z +234475e43958a801ba63bb1c424c8715 +2008-03-25T12:46:59.166018Z +23 +neil + +M000055.html +file + + + + +2008-03-28T15:44:42.000000Z +f920b99c27c792bdac0c054274ba6f44 +2008-10-16T14:11:23.436422Z +41 + +M000056.html +file + + + + +2008-03-28T15:44:42.000000Z +92592649e07c5a06ad738a2fe2f0de81 +2008-10-16T14:11:23.436422Z +41 + +M000057.html +file + + + + +2008-03-28T15:44:42.000000Z +23114a254a99e70cea32162f401a6426 +2008-10-16T14:11:23.436422Z +41 + +M000058.html +file + + + + +2008-03-28T15:44:42.000000Z +9a4fa5bc45f3b738b1245d1eb4c4b68b +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/Board.src/.svn/format b/doc/classes/Board.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Board.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Board.src/.svn/text-base/M000024.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000024.html.svn-base new file mode 100644 index 0000000..a37f686 --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000024.html.svn-base @@ -0,0 +1,95 @@ + + + + + + new (Board) + + + + +
# File lib/libttc.rb, line 90
+  def initialize(spokes, spoke_length, arc_length)
+    # A hash of all positions, indexed by position names
+    @positions = Hash.new   
+    @centre = Position.new('ac' + spoke_length.to_s, false, false)
+    @positions['ac' + spoke_length.to_s] = centre
+    a1_corner = nil
+    end_of_previous_arc = nil
+
+    # Do each arc-spoke-base set
+    (?a...(?a + spokes)).each do |arc_code|
+      arc = arc_code.chr
+      base = Position.new(arc, false, true)
+      this_arc = Array.new
+      
+      # build the arc
+      (1..arc_length).each do |arc_position|
+        position_name = arc + arc_position.to_s
+        arc_place = Position.new(position_name, arc_position == 4, false)
+        arc_place.neighbours = []
+        @positions[position_name] = arc_place
+        this_arc << arc_place
+        a1_corner = a1_corner || arc_place
+      end
+      (0...arc_length).each do |arc_position|
+        if arc_position > 0
+          this_arc[arc_position].neighbours << this_arc[arc_position - 1]
+        end
+        if arc_position < (arc_length - 1)
+          this_arc[arc_position].neighbours << this_arc[arc_position + 1]
+        end
+      end
+        
+      # build the spoke
+      this_spoke = Array.new
+      (1..(spoke_length - 1)).each do |spoke_position|
+        position_name = arc + "c" + spoke_position.to_s
+        spoke_place = Position.new(position_name, spoke_position == 3, false)
+        spoke_place.neighbours = []
+        @positions[position_name] = spoke_place
+        this_spoke << spoke_place
+      end
+      (0...(spoke_length - 1)).each do |spoke_position|
+        if spoke_position > 0
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1]
+        end
+        if spoke_position < spoke_length - 2
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1]
+        end
+      end
+      
+      # tie the spoke and arc together, 
+      this_arc[0].neighbours << this_spoke[0]
+      this_spoke[0].neighbours << this_arc[0]
+
+      # tie the spoke to the centre, and
+      this_spoke[-1].neighbours << @centre
+      @centre.neighbours << this_spoke[-1]
+      
+      # tie the base to the arc
+      base = Position.new(arc, false, true)
+      @positions[arc] = base
+      base.neighbours << this_arc[0]
+      this_arc[0].neighbours << base
+
+      # record the ends of the arc for tying to adjacent arcs
+      if end_of_previous_arc
+        end_of_previous_arc.neighbours << this_arc[0]
+        this_arc[0].neighbours << end_of_previous_arc
+      end
+      end_of_previous_arc = this_arc[-1]
+
+    end # arc
+
+    # tie both ends of the rim together 
+    a1_corner.neighbours << end_of_previous_arc
+    end_of_previous_arc.neighbours << a1_corner
+
+    cache_valid_moves
+
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000025.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000025.html.svn-base new file mode 100644 index 0000000..4db9d1c --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000025.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Board) + + + + +
# File lib/libttc.rb, line 171
+  def to_s
+    layout
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000026.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000026.html.svn-base new file mode 100644 index 0000000..14896fe --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000026.html.svn-base @@ -0,0 +1,26 @@ + + + + + + layout (Board) + + + + +
# File lib/libttc.rb, line 176
+  def layout
+    out_string = ""
+    @positions.keys.sort.each do |position|
+      out_string << sprintf("%s touches ", @positions[position])
+      @positions[position].neighbours.each do |neighbour|
+        out_string << sprintf("%s, ", neighbour)
+      end
+      out_string << sprintf("\n")
+    end
+    out_string
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000027.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000027.html.svn-base new file mode 100644 index 0000000..b6a5ed9 --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000027.html.svn-base @@ -0,0 +1,46 @@ + + + + + + cache_valid_moves (Board) + + + + +
# File lib/libttc.rb, line 191
+  def cache_valid_moves
+    # A hash of arrays.  The has key is the name of a positions.  The array 
+    #  element [i] stores the positions that are i spaces from here
+    @valid_moves = Hash.new
+    # A hash of hashes.  Given two names, return the shortest distance between
+    #  the two locations
+    @distance_between = Hash.new
+    @positions.each do |place, position|
+      @valid_moves[place] = Array.new
+      @distance_between[place] = Hash.new
+      @valid_moves[place][0] = [place]
+      @distance_between[place][place] = 0
+      # Find the shortest routes by Dijkstra's algorithm
+      agenda = [position]
+      closed_list = [position]
+      i = 1
+      while not agenda.empty?
+        @valid_moves[place][i] = []
+        new_agenda = []
+        agenda.each do |pos|
+          valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) }
+          @valid_moves[place][i] += valid_extensions
+          valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i }
+          closed_list += valid_extensions
+          new_agenda += valid_extensions
+        end
+        agenda = new_agenda
+        i += 1
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000034.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000034.html.svn-base new file mode 100644 index 0000000..5294404 --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000034.html.svn-base @@ -0,0 +1,95 @@ + + + + + + new (Board) + + + + +
# File lib/libttc.rb, line 82
+  def initialize(spokes, spoke_length, arc_length)
+    # A hash of all positions, indexed by position names
+    @positions = Hash.new   
+    @centre = Position.new('ac' + spoke_length.to_s, false, false)
+    @positions['ac' + spoke_length.to_s] = centre
+    a1_corner = nil
+    end_of_previous_arc = nil
+
+    # Do each arc-spoke-base set
+    (?a...(?a + spokes)).each do |arc_code|
+      arc = arc_code.chr
+      base = Position.new(arc, false, true)
+      this_arc = Array.new
+      
+      # build the arc
+      (1..arc_length).each do |arc_position|
+        position_name = arc + arc_position.to_s
+        arc_place = Position.new(position_name, arc_position == 4, false)
+        arc_place.neighbours = []
+        @positions[position_name] = arc_place
+        this_arc << arc_place
+        a1_corner = a1_corner || arc_place
+      end
+      (0...arc_length).each do |arc_position|
+        if arc_position > 0
+          this_arc[arc_position].neighbours << this_arc[arc_position - 1]
+        end
+        if arc_position < (arc_length - 1)
+          this_arc[arc_position].neighbours << this_arc[arc_position + 1]
+        end
+      end
+        
+      # build the spoke
+      this_spoke = Array.new
+      (1..(spoke_length - 1)).each do |spoke_position|
+        position_name = arc + "c" + spoke_position.to_s
+        spoke_place = Position.new(position_name, spoke_position == 3, false)
+        spoke_place.neighbours = []
+        @positions[position_name] = spoke_place
+        this_spoke << spoke_place
+      end
+      (0...(spoke_length - 1)).each do |spoke_position|
+        if spoke_position > 0
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1]
+        end
+        if spoke_position < spoke_length - 2
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1]
+        end
+      end
+      
+      # tie the spoke and arc together, 
+      this_arc[0].neighbours << this_spoke[0]
+      this_spoke[0].neighbours << this_arc[0]
+
+      # tie the spoke to the centre, and
+      this_spoke[-1].neighbours << @centre
+      @centre.neighbours << this_spoke[-1]
+      
+      # tie the base to the arc
+      base = Position.new(arc, false, true)
+      @positions[arc] = base
+      base.neighbours << this_arc[0]
+      this_arc[0].neighbours << base
+
+      # record the ends of the arc for tying to adjacent arcs
+      if end_of_previous_arc
+        end_of_previous_arc.neighbours << this_arc[0]
+        this_arc[0].neighbours << end_of_previous_arc
+      end
+      end_of_previous_arc = this_arc[-1]
+
+    end # arc
+
+    # tie both ends of the rim together 
+    a1_corner.neighbours << end_of_previous_arc
+    end_of_previous_arc.neighbours << a1_corner
+
+    cache_valid_moves
+
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000035.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000035.html.svn-base new file mode 100644 index 0000000..ed822f1 --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000035.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Board) + + + + +
# File lib/libttc.rb, line 163
+  def to_s
+    layout
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000036.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000036.html.svn-base new file mode 100644 index 0000000..3aa04d2 --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000036.html.svn-base @@ -0,0 +1,26 @@ + + + + + + layout (Board) + + + + +
# File lib/libttc.rb, line 168
+  def layout
+    out_string = ""
+    @positions.keys.sort.each do |position|
+      out_string << sprintf("%s touches ", @positions[position])
+      @positions[position].neighbours.each do |neighbour|
+        out_string << sprintf("%s, ", neighbour)
+      end
+      out_string << sprintf("\n")
+    end
+    out_string
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000037.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000037.html.svn-base new file mode 100644 index 0000000..4847c58 --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000037.html.svn-base @@ -0,0 +1,45 @@ + + + + + + cache_valid_moves (Board) + + + + +
# File lib/libttc.rb, line 182
+  def cache_valid_moves
+    # A hash of arrays.  The has key is the name of a positions.  The array element [i] stores the
+    #  positions that are i spaces from here
+    @valid_moves = Hash.new
+    # A hash of hashes.  Given two names, return the shortest distance between the two locations
+    @distance_between = Hash.new
+    @positions.each do |place, position|
+      @valid_moves[place] = Array.new
+      @distance_between[place] = Hash.new
+      @valid_moves[place][0] = [place]
+      @distance_between[place][place] = 0
+      # Find the shortest routes by Dijkstra's algorithm
+      agenda = [position]
+      closed_list = [position]
+      i = 1
+      while not agenda.empty?
+        @valid_moves[place][i] = []
+        new_agenda = []
+        agenda.each do |pos|
+          valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) }
+          @valid_moves[place][i] += valid_extensions
+          valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i }
+          closed_list += valid_extensions
+          new_agenda += valid_extensions
+        end
+        agenda = new_agenda
+        i += 1
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000054.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000054.html.svn-base new file mode 100644 index 0000000..36d997b --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000054.html.svn-base @@ -0,0 +1,95 @@ + + + + + + new (Board) + + + + +
# File lib/libttc.rb, line 94
+  def initialize(spokes, spoke_length, arc_length)
+    # A hash of all positions, indexed by position names
+    @positions = Hash.new   
+    @centre = Position.new('ac' + spoke_length.to_s, false, false)
+    @positions['ac' + spoke_length.to_s] = centre
+    a1_corner = nil
+    end_of_previous_arc = nil
+
+    # Do each arc-spoke-base set
+    (?a...(?a + spokes)).each do |arc_code|
+      arc = arc_code.chr
+      base = Position.new(arc, false, true)
+      this_arc = Array.new
+      
+      # build the arc
+      (1..arc_length).each do |arc_position|
+        position_name = arc + arc_position.to_s
+        arc_place = Position.new(position_name, arc_position == 4, false)
+        arc_place.neighbours = []
+        @positions[position_name] = arc_place
+        this_arc << arc_place
+        a1_corner = a1_corner || arc_place
+      end
+      (0...arc_length).each do |arc_position|
+        if arc_position > 0
+          this_arc[arc_position].neighbours << this_arc[arc_position - 1]
+        end
+        if arc_position < (arc_length - 1)
+          this_arc[arc_position].neighbours << this_arc[arc_position + 1]
+        end
+      end
+        
+      # build the spoke
+      this_spoke = Array.new
+      (1..(spoke_length - 1)).each do |spoke_position|
+        position_name = arc + "c" + spoke_position.to_s
+        spoke_place = Position.new(position_name, spoke_position == 3, false)
+        spoke_place.neighbours = []
+        @positions[position_name] = spoke_place
+        this_spoke << spoke_place
+      end
+      (0...(spoke_length - 1)).each do |spoke_position|
+        if spoke_position > 0
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1]
+        end
+        if spoke_position < spoke_length - 2
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1]
+        end
+      end
+      
+      # tie the spoke and arc together, 
+      this_arc[0].neighbours << this_spoke[0]
+      this_spoke[0].neighbours << this_arc[0]
+
+      # tie the spoke to the centre, and
+      this_spoke[-1].neighbours << @centre
+      @centre.neighbours << this_spoke[-1]
+      
+      # tie the base to the arc
+      base = Position.new(arc, false, true)
+      @positions[arc] = base
+      base.neighbours << this_arc[0]
+      this_arc[0].neighbours << base
+
+      # record the ends of the arc for tying to adjacent arcs
+      if end_of_previous_arc
+        end_of_previous_arc.neighbours << this_arc[0]
+        this_arc[0].neighbours << end_of_previous_arc
+      end
+      end_of_previous_arc = this_arc[-1]
+
+    end # arc
+
+    # tie both ends of the rim together 
+    a1_corner.neighbours << end_of_previous_arc
+    end_of_previous_arc.neighbours << a1_corner
+
+    cache_valid_moves
+
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000055.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000055.html.svn-base new file mode 100644 index 0000000..eb0e755 --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000055.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Board) + + + + +
# File lib/libttc.rb, line 175
+  def to_s
+    layout
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000056.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000056.html.svn-base new file mode 100644 index 0000000..a776b7c --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000056.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_str (Board) + + + + +
# File lib/libttc.rb, line 179
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000057.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000057.html.svn-base new file mode 100644 index 0000000..fc1693e --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000057.html.svn-base @@ -0,0 +1,26 @@ + + + + + + layout (Board) + + + + +
# File lib/libttc.rb, line 185
+  def layout
+    out_string = ""
+    @positions.keys.sort.each do |position|
+      out_string << sprintf("%s touches ", @positions[position])
+      @positions[position].neighbours.each do |neighbour|
+        out_string << sprintf("%s, ", neighbour)
+      end
+      out_string << sprintf("\n")
+    end
+    out_string
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/.svn/text-base/M000058.html.svn-base b/doc/classes/Board.src/.svn/text-base/M000058.html.svn-base new file mode 100644 index 0000000..66ad23c --- /dev/null +++ b/doc/classes/Board.src/.svn/text-base/M000058.html.svn-base @@ -0,0 +1,46 @@ + + + + + + cache_valid_moves (Board) + + + + +
# File lib/libttc.rb, line 200
+  def cache_valid_moves
+    # A hash of arrays.  The has key is the name of a positions.  The array 
+    #  element [i] stores the positions that are i spaces from here
+    @valid_moves = Hash.new
+    # A hash of hashes.  Given two names, return the shortest distance between
+    #  the two locations
+    @distance_between = Hash.new
+    @positions.each do |place, position|
+      @valid_moves[place] = Array.new
+      @distance_between[place] = Hash.new
+      @valid_moves[place][0] = [@positions[place]]
+      @distance_between[place][place] = 0
+      # Find the shortest routes by Dijkstra's algorithm
+      agenda = [position]
+      closed_list = [position]
+      i = 1
+      while not agenda.empty?
+        @valid_moves[place][i] = []
+        new_agenda = []
+        agenda.each do |pos|
+          valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) }
+          @valid_moves[place][i] += valid_extensions
+          valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i }
+          closed_list += valid_extensions
+          new_agenda += valid_extensions
+        end
+        agenda = new_agenda
+        i += 1
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000024.html b/doc/classes/Board.src/M000024.html new file mode 100644 index 0000000..a37f686 --- /dev/null +++ b/doc/classes/Board.src/M000024.html @@ -0,0 +1,95 @@ + + + + + + new (Board) + + + + +
# File lib/libttc.rb, line 90
+  def initialize(spokes, spoke_length, arc_length)
+    # A hash of all positions, indexed by position names
+    @positions = Hash.new   
+    @centre = Position.new('ac' + spoke_length.to_s, false, false)
+    @positions['ac' + spoke_length.to_s] = centre
+    a1_corner = nil
+    end_of_previous_arc = nil
+
+    # Do each arc-spoke-base set
+    (?a...(?a + spokes)).each do |arc_code|
+      arc = arc_code.chr
+      base = Position.new(arc, false, true)
+      this_arc = Array.new
+      
+      # build the arc
+      (1..arc_length).each do |arc_position|
+        position_name = arc + arc_position.to_s
+        arc_place = Position.new(position_name, arc_position == 4, false)
+        arc_place.neighbours = []
+        @positions[position_name] = arc_place
+        this_arc << arc_place
+        a1_corner = a1_corner || arc_place
+      end
+      (0...arc_length).each do |arc_position|
+        if arc_position > 0
+          this_arc[arc_position].neighbours << this_arc[arc_position - 1]
+        end
+        if arc_position < (arc_length - 1)
+          this_arc[arc_position].neighbours << this_arc[arc_position + 1]
+        end
+      end
+        
+      # build the spoke
+      this_spoke = Array.new
+      (1..(spoke_length - 1)).each do |spoke_position|
+        position_name = arc + "c" + spoke_position.to_s
+        spoke_place = Position.new(position_name, spoke_position == 3, false)
+        spoke_place.neighbours = []
+        @positions[position_name] = spoke_place
+        this_spoke << spoke_place
+      end
+      (0...(spoke_length - 1)).each do |spoke_position|
+        if spoke_position > 0
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1]
+        end
+        if spoke_position < spoke_length - 2
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1]
+        end
+      end
+      
+      # tie the spoke and arc together, 
+      this_arc[0].neighbours << this_spoke[0]
+      this_spoke[0].neighbours << this_arc[0]
+
+      # tie the spoke to the centre, and
+      this_spoke[-1].neighbours << @centre
+      @centre.neighbours << this_spoke[-1]
+      
+      # tie the base to the arc
+      base = Position.new(arc, false, true)
+      @positions[arc] = base
+      base.neighbours << this_arc[0]
+      this_arc[0].neighbours << base
+
+      # record the ends of the arc for tying to adjacent arcs
+      if end_of_previous_arc
+        end_of_previous_arc.neighbours << this_arc[0]
+        this_arc[0].neighbours << end_of_previous_arc
+      end
+      end_of_previous_arc = this_arc[-1]
+
+    end # arc
+
+    # tie both ends of the rim together 
+    a1_corner.neighbours << end_of_previous_arc
+    end_of_previous_arc.neighbours << a1_corner
+
+    cache_valid_moves
+
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000025.html b/doc/classes/Board.src/M000025.html new file mode 100644 index 0000000..4db9d1c --- /dev/null +++ b/doc/classes/Board.src/M000025.html @@ -0,0 +1,18 @@ + + + + + + to_s (Board) + + + + +
# File lib/libttc.rb, line 171
+  def to_s
+    layout
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000026.html b/doc/classes/Board.src/M000026.html new file mode 100644 index 0000000..14896fe --- /dev/null +++ b/doc/classes/Board.src/M000026.html @@ -0,0 +1,26 @@ + + + + + + layout (Board) + + + + +
# File lib/libttc.rb, line 176
+  def layout
+    out_string = ""
+    @positions.keys.sort.each do |position|
+      out_string << sprintf("%s touches ", @positions[position])
+      @positions[position].neighbours.each do |neighbour|
+        out_string << sprintf("%s, ", neighbour)
+      end
+      out_string << sprintf("\n")
+    end
+    out_string
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000027.html b/doc/classes/Board.src/M000027.html new file mode 100644 index 0000000..b6a5ed9 --- /dev/null +++ b/doc/classes/Board.src/M000027.html @@ -0,0 +1,46 @@ + + + + + + cache_valid_moves (Board) + + + + +
# File lib/libttc.rb, line 191
+  def cache_valid_moves
+    # A hash of arrays.  The has key is the name of a positions.  The array 
+    #  element [i] stores the positions that are i spaces from here
+    @valid_moves = Hash.new
+    # A hash of hashes.  Given two names, return the shortest distance between
+    #  the two locations
+    @distance_between = Hash.new
+    @positions.each do |place, position|
+      @valid_moves[place] = Array.new
+      @distance_between[place] = Hash.new
+      @valid_moves[place][0] = [place]
+      @distance_between[place][place] = 0
+      # Find the shortest routes by Dijkstra's algorithm
+      agenda = [position]
+      closed_list = [position]
+      i = 1
+      while not agenda.empty?
+        @valid_moves[place][i] = []
+        new_agenda = []
+        agenda.each do |pos|
+          valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) }
+          @valid_moves[place][i] += valid_extensions
+          valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i }
+          closed_list += valid_extensions
+          new_agenda += valid_extensions
+        end
+        agenda = new_agenda
+        i += 1
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000034.html b/doc/classes/Board.src/M000034.html new file mode 100644 index 0000000..5294404 --- /dev/null +++ b/doc/classes/Board.src/M000034.html @@ -0,0 +1,95 @@ + + + + + + new (Board) + + + + +
# File lib/libttc.rb, line 82
+  def initialize(spokes, spoke_length, arc_length)
+    # A hash of all positions, indexed by position names
+    @positions = Hash.new   
+    @centre = Position.new('ac' + spoke_length.to_s, false, false)
+    @positions['ac' + spoke_length.to_s] = centre
+    a1_corner = nil
+    end_of_previous_arc = nil
+
+    # Do each arc-spoke-base set
+    (?a...(?a + spokes)).each do |arc_code|
+      arc = arc_code.chr
+      base = Position.new(arc, false, true)
+      this_arc = Array.new
+      
+      # build the arc
+      (1..arc_length).each do |arc_position|
+        position_name = arc + arc_position.to_s
+        arc_place = Position.new(position_name, arc_position == 4, false)
+        arc_place.neighbours = []
+        @positions[position_name] = arc_place
+        this_arc << arc_place
+        a1_corner = a1_corner || arc_place
+      end
+      (0...arc_length).each do |arc_position|
+        if arc_position > 0
+          this_arc[arc_position].neighbours << this_arc[arc_position - 1]
+        end
+        if arc_position < (arc_length - 1)
+          this_arc[arc_position].neighbours << this_arc[arc_position + 1]
+        end
+      end
+        
+      # build the spoke
+      this_spoke = Array.new
+      (1..(spoke_length - 1)).each do |spoke_position|
+        position_name = arc + "c" + spoke_position.to_s
+        spoke_place = Position.new(position_name, spoke_position == 3, false)
+        spoke_place.neighbours = []
+        @positions[position_name] = spoke_place
+        this_spoke << spoke_place
+      end
+      (0...(spoke_length - 1)).each do |spoke_position|
+        if spoke_position > 0
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1]
+        end
+        if spoke_position < spoke_length - 2
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1]
+        end
+      end
+      
+      # tie the spoke and arc together, 
+      this_arc[0].neighbours << this_spoke[0]
+      this_spoke[0].neighbours << this_arc[0]
+
+      # tie the spoke to the centre, and
+      this_spoke[-1].neighbours << @centre
+      @centre.neighbours << this_spoke[-1]
+      
+      # tie the base to the arc
+      base = Position.new(arc, false, true)
+      @positions[arc] = base
+      base.neighbours << this_arc[0]
+      this_arc[0].neighbours << base
+
+      # record the ends of the arc for tying to adjacent arcs
+      if end_of_previous_arc
+        end_of_previous_arc.neighbours << this_arc[0]
+        this_arc[0].neighbours << end_of_previous_arc
+      end
+      end_of_previous_arc = this_arc[-1]
+
+    end # arc
+
+    # tie both ends of the rim together 
+    a1_corner.neighbours << end_of_previous_arc
+    end_of_previous_arc.neighbours << a1_corner
+
+    cache_valid_moves
+
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000035.html b/doc/classes/Board.src/M000035.html new file mode 100644 index 0000000..ed822f1 --- /dev/null +++ b/doc/classes/Board.src/M000035.html @@ -0,0 +1,18 @@ + + + + + + to_s (Board) + + + + +
# File lib/libttc.rb, line 163
+  def to_s
+    layout
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000036.html b/doc/classes/Board.src/M000036.html new file mode 100644 index 0000000..3aa04d2 --- /dev/null +++ b/doc/classes/Board.src/M000036.html @@ -0,0 +1,26 @@ + + + + + + layout (Board) + + + + +
# File lib/libttc.rb, line 168
+  def layout
+    out_string = ""
+    @positions.keys.sort.each do |position|
+      out_string << sprintf("%s touches ", @positions[position])
+      @positions[position].neighbours.each do |neighbour|
+        out_string << sprintf("%s, ", neighbour)
+      end
+      out_string << sprintf("\n")
+    end
+    out_string
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000037.html b/doc/classes/Board.src/M000037.html new file mode 100644 index 0000000..4847c58 --- /dev/null +++ b/doc/classes/Board.src/M000037.html @@ -0,0 +1,45 @@ + + + + + + cache_valid_moves (Board) + + + + +
# File lib/libttc.rb, line 182
+  def cache_valid_moves
+    # A hash of arrays.  The has key is the name of a positions.  The array element [i] stores the
+    #  positions that are i spaces from here
+    @valid_moves = Hash.new
+    # A hash of hashes.  Given two names, return the shortest distance between the two locations
+    @distance_between = Hash.new
+    @positions.each do |place, position|
+      @valid_moves[place] = Array.new
+      @distance_between[place] = Hash.new
+      @valid_moves[place][0] = [place]
+      @distance_between[place][place] = 0
+      # Find the shortest routes by Dijkstra's algorithm
+      agenda = [position]
+      closed_list = [position]
+      i = 1
+      while not agenda.empty?
+        @valid_moves[place][i] = []
+        new_agenda = []
+        agenda.each do |pos|
+          valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) }
+          @valid_moves[place][i] += valid_extensions
+          valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i }
+          closed_list += valid_extensions
+          new_agenda += valid_extensions
+        end
+        agenda = new_agenda
+        i += 1
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000054.html b/doc/classes/Board.src/M000054.html new file mode 100644 index 0000000..36d997b --- /dev/null +++ b/doc/classes/Board.src/M000054.html @@ -0,0 +1,95 @@ + + + + + + new (Board) + + + + +
# File lib/libttc.rb, line 94
+  def initialize(spokes, spoke_length, arc_length)
+    # A hash of all positions, indexed by position names
+    @positions = Hash.new   
+    @centre = Position.new('ac' + spoke_length.to_s, false, false)
+    @positions['ac' + spoke_length.to_s] = centre
+    a1_corner = nil
+    end_of_previous_arc = nil
+
+    # Do each arc-spoke-base set
+    (?a...(?a + spokes)).each do |arc_code|
+      arc = arc_code.chr
+      base = Position.new(arc, false, true)
+      this_arc = Array.new
+      
+      # build the arc
+      (1..arc_length).each do |arc_position|
+        position_name = arc + arc_position.to_s
+        arc_place = Position.new(position_name, arc_position == 4, false)
+        arc_place.neighbours = []
+        @positions[position_name] = arc_place
+        this_arc << arc_place
+        a1_corner = a1_corner || arc_place
+      end
+      (0...arc_length).each do |arc_position|
+        if arc_position > 0
+          this_arc[arc_position].neighbours << this_arc[arc_position - 1]
+        end
+        if arc_position < (arc_length - 1)
+          this_arc[arc_position].neighbours << this_arc[arc_position + 1]
+        end
+      end
+        
+      # build the spoke
+      this_spoke = Array.new
+      (1..(spoke_length - 1)).each do |spoke_position|
+        position_name = arc + "c" + spoke_position.to_s
+        spoke_place = Position.new(position_name, spoke_position == 3, false)
+        spoke_place.neighbours = []
+        @positions[position_name] = spoke_place
+        this_spoke << spoke_place
+      end
+      (0...(spoke_length - 1)).each do |spoke_position|
+        if spoke_position > 0
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1]
+        end
+        if spoke_position < spoke_length - 2
+          this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1]
+        end
+      end
+      
+      # tie the spoke and arc together, 
+      this_arc[0].neighbours << this_spoke[0]
+      this_spoke[0].neighbours << this_arc[0]
+
+      # tie the spoke to the centre, and
+      this_spoke[-1].neighbours << @centre
+      @centre.neighbours << this_spoke[-1]
+      
+      # tie the base to the arc
+      base = Position.new(arc, false, true)
+      @positions[arc] = base
+      base.neighbours << this_arc[0]
+      this_arc[0].neighbours << base
+
+      # record the ends of the arc for tying to adjacent arcs
+      if end_of_previous_arc
+        end_of_previous_arc.neighbours << this_arc[0]
+        this_arc[0].neighbours << end_of_previous_arc
+      end
+      end_of_previous_arc = this_arc[-1]
+
+    end # arc
+
+    # tie both ends of the rim together 
+    a1_corner.neighbours << end_of_previous_arc
+    end_of_previous_arc.neighbours << a1_corner
+
+    cache_valid_moves
+
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000055.html b/doc/classes/Board.src/M000055.html new file mode 100644 index 0000000..eb0e755 --- /dev/null +++ b/doc/classes/Board.src/M000055.html @@ -0,0 +1,18 @@ + + + + + + to_s (Board) + + + + +
# File lib/libttc.rb, line 175
+  def to_s
+    layout
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000056.html b/doc/classes/Board.src/M000056.html new file mode 100644 index 0000000..a776b7c --- /dev/null +++ b/doc/classes/Board.src/M000056.html @@ -0,0 +1,18 @@ + + + + + + to_str (Board) + + + + +
# File lib/libttc.rb, line 179
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000057.html b/doc/classes/Board.src/M000057.html new file mode 100644 index 0000000..fc1693e --- /dev/null +++ b/doc/classes/Board.src/M000057.html @@ -0,0 +1,26 @@ + + + + + + layout (Board) + + + + +
# File lib/libttc.rb, line 185
+  def layout
+    out_string = ""
+    @positions.keys.sort.each do |position|
+      out_string << sprintf("%s touches ", @positions[position])
+      @positions[position].neighbours.each do |neighbour|
+        out_string << sprintf("%s, ", neighbour)
+      end
+      out_string << sprintf("\n")
+    end
+    out_string
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Board.src/M000058.html b/doc/classes/Board.src/M000058.html new file mode 100644 index 0000000..66ad23c --- /dev/null +++ b/doc/classes/Board.src/M000058.html @@ -0,0 +1,46 @@ + + + + + + cache_valid_moves (Board) + + + + +
# File lib/libttc.rb, line 200
+  def cache_valid_moves
+    # A hash of arrays.  The has key is the name of a positions.  The array 
+    #  element [i] stores the positions that are i spaces from here
+    @valid_moves = Hash.new
+    # A hash of hashes.  Given two names, return the shortest distance between
+    #  the two locations
+    @distance_between = Hash.new
+    @positions.each do |place, position|
+      @valid_moves[place] = Array.new
+      @distance_between[place] = Hash.new
+      @valid_moves[place][0] = [@positions[place]]
+      @distance_between[place][place] = 0
+      # Find the shortest routes by Dijkstra's algorithm
+      agenda = [position]
+      closed_list = [position]
+      i = 1
+      while not agenda.empty?
+        @valid_moves[place][i] = []
+        new_agenda = []
+        agenda.each do |pos|
+          valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) }
+          @valid_moves[place][i] += valid_extensions
+          valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i }
+          closed_list += valid_extensions
+          new_agenda += valid_extensions
+        end
+        agenda = new_agenda
+        i += 1
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Fixnum.html b/doc/classes/Fixnum.html new file mode 100644 index 0000000..ba0b706 --- /dev/null +++ b/doc/classes/Fixnum.html @@ -0,0 +1,137 @@ + + + + + + Class: Fixnum + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassFixnum
In: + + lib/libgenetics.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ + + +
+ +
+

Methods

+ +
+ to_bitstring   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ + + + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Fixnum.src/.svn/all-wcprops b/doc/classes/Fixnum.src/.svn/all-wcprops new file mode 100644 index 0000000..7a85986 --- /dev/null +++ b/doc/classes/Fixnum.src/.svn/all-wcprops @@ -0,0 +1,17 @@ +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Fixnum.src +END +M000012.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Fixnum.src/M000012.html +END +M000022.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Fixnum.src/M000022.html +END diff --git a/doc/classes/Fixnum.src/.svn/entries b/doc/classes/Fixnum.src/.svn/entries new file mode 100644 index 0000000..f677b39 --- /dev/null +++ b/doc/classes/Fixnum.src/.svn/entries @@ -0,0 +1,38 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Fixnum.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +M000012.html +file + + + + +2008-04-23T19:30:16.000000Z +ae2e1de25443c09224230ea37c75c000 +2008-10-16T14:11:23.436422Z +41 + +M000022.html +file + + + + +2008-04-23T19:33:07.000000Z +a315af98617a2484b934bce36e982eb6 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/Fixnum.src/.svn/format b/doc/classes/Fixnum.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Fixnum.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Fixnum.src/.svn/text-base/M000012.html.svn-base b/doc/classes/Fixnum.src/.svn/text-base/M000012.html.svn-base new file mode 100644 index 0000000..e3f9d18 --- /dev/null +++ b/doc/classes/Fixnum.src/.svn/text-base/M000012.html.svn-base @@ -0,0 +1,31 @@ + + + + + + to_bitstring (Fixnum) + + + + +
# File lib/libgenetics.rb, line 108
+  def to_bitstring(min_length = 0)
+    bits = []
+    k = self
+    while k > 0 do
+      if k % 2 == 1
+        bits << 1
+      else
+        bits << 0
+      end
+      k = k >> 1
+    end
+    while bits.length < min_length do
+      bits << 0
+    end
+    bits.reverse
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Fixnum.src/.svn/text-base/M000022.html.svn-base b/doc/classes/Fixnum.src/.svn/text-base/M000022.html.svn-base new file mode 100644 index 0000000..cc88eaa --- /dev/null +++ b/doc/classes/Fixnum.src/.svn/text-base/M000022.html.svn-base @@ -0,0 +1,31 @@ + + + + + + to_bitstring (Fixnum) + + + + +
# File lib/libgenetics.rb, line 111
+  def to_bitstring(min_length = 0)
+    bits = []
+    k = self
+    while k > 0 do
+      if k % 2 == 1
+        bits << 1
+      else
+        bits << 0
+      end
+      k = k >> 1
+    end
+    while bits.length < min_length do
+      bits << 0
+    end
+    bits.reverse
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Fixnum.src/M000012.html b/doc/classes/Fixnum.src/M000012.html new file mode 100644 index 0000000..e3f9d18 --- /dev/null +++ b/doc/classes/Fixnum.src/M000012.html @@ -0,0 +1,31 @@ + + + + + + to_bitstring (Fixnum) + + + + +
# File lib/libgenetics.rb, line 108
+  def to_bitstring(min_length = 0)
+    bits = []
+    k = self
+    while k > 0 do
+      if k % 2 == 1
+        bits << 1
+      else
+        bits << 0
+      end
+      k = k >> 1
+    end
+    while bits.length < min_length do
+      bits << 0
+    end
+    bits.reverse
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Fixnum.src/M000022.html b/doc/classes/Fixnum.src/M000022.html new file mode 100644 index 0000000..cc88eaa --- /dev/null +++ b/doc/classes/Fixnum.src/M000022.html @@ -0,0 +1,31 @@ + + + + + + to_bitstring (Fixnum) + + + + +
# File lib/libgenetics.rb, line 111
+  def to_bitstring(min_length = 0)
+    bits = []
+    k = self
+    while k > 0 do
+      if k % 2 == 1
+        bits << 1
+      else
+        bits << 0
+      end
+      k = k >> 1
+    end
+    while bits.length < min_length do
+      bits << 0
+    end
+    bits.reverse
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.html b/doc/classes/Game.html new file mode 100644 index 0000000..7c6f30b --- /dev/null +++ b/doc/classes/Game.html @@ -0,0 +1,355 @@ + + + + + + Class: Game + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGame
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A game of Trap the Cap. It keeps a history of all previous states. +

+ +
+ + +
+ +
+

Methods

+ +
+ apply_move!   + apply_moves!   + build_state_string   + new   + next_player!   + possible_moves   + read_game   + show_state   + to_s   + to_str   + undo_move!   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
board [R] 
current_player [R] 
history [R] 
pieces [R] 
players [R] 
+
+
+ + + + +
+

Public Class methods

+ + + +
+ + + + +
+

+Given a set of lines from an input file, turn them into a Game object and a set of Move +objects. Note the multiple return values. Class method +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Apply a single move to a game. +

+
+
+ +
+ + + + +
+

+Apply a list of moves in order +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+

+Set the current player to be the next player +

+
+
+ +
+ + + + +
+

+Return an array of all possible moves from this state, given the die roll +and the active player +

+
+
+ +
+ + + + +
+

+Show the state of the board +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+

+Undo a move +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/all-wcprops b/doc/classes/Game.src/.svn/all-wcprops new file mode 100644 index 0000000..31227a2 --- /dev/null +++ b/doc/classes/Game.src/.svn/all-wcprops @@ -0,0 +1,155 @@ +K 25 +svn:wc:ra_dav:version-url +V 59 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src +END +M000011.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Game.src/M000011.html +END +M000021.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Game.src/M000021.html +END +M000012.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Game.src/M000012.html +END +M000040.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000040.html +END +M000022.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Game.src/M000022.html +END +M000013.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Game.src/M000013.html +END +M000041.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000041.html +END +M000023.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Game.src/M000023.html +END +M000014.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Game.src/M000014.html +END +M000042.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000042.html +END +M000024.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Game.src/M000024.html +END +M000015.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Game.src/M000015.html +END +M000043.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000043.html +END +M000025.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Game.src/M000025.html +END +M000016.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Game.src/M000016.html +END +M000017.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Game.src/M000017.html +END +M000026.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Game.src/M000026.html +END +M000044.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000044.html +END +M000036.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000036.html +END +M000027.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Game.src/M000027.html +END +M000045.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000045.html +END +M000037.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000037.html +END +M000046.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000046.html +END +M000038.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000038.html +END +M000039.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Game.src/M000039.html +END diff --git a/doc/classes/Game.src/.svn/entries b/doc/classes/Game.src/.svn/entries new file mode 100644 index 0000000..a7c798a --- /dev/null +++ b/doc/classes/Game.src/.svn/entries @@ -0,0 +1,317 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Game.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000011.html +file + + + + +2008-03-25T12:43:37.000000Z +72f0bf2b98751cd586569cc725d9958f +2008-03-28T15:47:09.723420Z +24 +neil + +M000012.html +file + + + + +2008-03-25T12:43:37.000000Z +847544ecc2aa237c46799d389b4c5022 +2008-03-28T15:47:09.723420Z +24 +neil + +M000021.html +file + + + + +2008-03-25T11:48:00.000000Z +6d26a39471790f335c2079b934dd4f87 +2008-03-25T12:46:59.166018Z +23 +neil + +M000040.html +file + + + + +2008-03-28T15:44:42.000000Z +8150ce9dcc9a66d1cf726441ca6424e8 +2008-10-16T14:11:23.436422Z +41 + +M000013.html +file + + + + +2008-03-25T12:43:37.000000Z +56ad1e2992ed4c5ab5c4cf8b7617db55 +2008-03-28T15:47:09.723420Z +24 +neil + +M000022.html +file + + + + +2008-03-25T11:48:00.000000Z +722d3c796a54769f4a9154e02746a2c9 +2008-03-25T12:46:59.166018Z +23 +neil + +M000014.html +file + + + + +2008-03-25T12:43:37.000000Z +c8c45fd34107894059c4528364c6e869 +2008-03-28T15:47:09.723420Z +24 +neil + +M000023.html +file + + + + +2008-03-25T11:48:00.000000Z +1130afe34708f44ac61f7ed0b5c4118c +2008-03-25T12:46:59.166018Z +23 +neil + +M000041.html +file + + + + +2008-03-28T15:44:42.000000Z +feb55ca6336a84dc5309a068223a5142 +2008-10-16T14:11:23.436422Z +41 + +M000042.html +file + + + + +2008-03-28T15:44:42.000000Z +dbc7864e9f5753a51b01ab51edd77fc5 +2008-10-16T14:11:23.436422Z +41 + +M000015.html +file + + + + +2008-03-25T12:43:37.000000Z +60db3283ae32e48d3adaf3ce0e5e7333 +2008-03-28T15:47:09.723420Z +24 +neil + +M000024.html +file + + + + +2008-03-25T11:48:00.000000Z +b2bd90498157b556657b1baa008da6c8 +2008-03-25T12:46:59.166018Z +23 +neil + +M000043.html +file + + + + +2008-03-28T15:44:42.000000Z +bc2baa00a766dd71b53839be9b8f327f +2008-10-16T14:11:23.436422Z +41 + +M000016.html +file + + + + +2008-03-25T12:43:37.000000Z +31e5c38d706790da4db7681b39f8c984 +2008-03-28T15:47:09.723420Z +24 +neil + +M000025.html +file + + + + +2008-03-25T11:48:00.000000Z +3107728daed89cafeee115daefc695cd +2008-03-25T12:46:59.166018Z +23 +neil + +M000026.html +file + + + + +2008-03-25T11:48:00.000000Z +fd5f18c9eb5e2edaa940cc7d900807fb +2008-03-25T12:46:59.166018Z +23 +neil + +M000044.html +file + + + + +2008-03-28T15:44:42.000000Z +0da711412a0bc336780c4c806ca78f78 +2008-10-16T14:11:23.436422Z +41 + +M000017.html +file + + + + +2008-03-25T12:43:37.000000Z +d73fc9ea1b9254b28368249f77d15b5a +2008-03-28T15:47:09.723420Z +24 +neil + +M000027.html +file + + + + +2008-03-25T11:48:00.000000Z +5790a8e4264498aa0ecf34c3e857060a +2008-03-25T12:46:59.166018Z +23 +neil + +M000045.html +file + + + + +2008-03-28T15:44:42.000000Z +68c624e923d750802ebe8c327ee6ac03 +2008-10-16T14:11:23.436422Z +41 + +M000036.html +file + + + + +2008-03-28T15:44:42.000000Z +784f5a3f2bf4f4be5649be867d2cb695 +2008-10-16T14:11:23.436422Z +41 + +M000037.html +file + + + + +2008-03-28T15:44:42.000000Z +b0f6c28477ed6d3c4970d7a98195d224 +2008-10-16T14:11:23.436422Z +41 + +M000046.html +file + + + + +2008-03-28T15:44:42.000000Z +4acd05b0a726cdbf3c1813c5c67f0635 +2008-10-16T14:11:23.436422Z +41 + +M000038.html +file + + + + +2008-03-28T15:44:42.000000Z +db418a74dea51b3974b9506c7c69ac36 +2008-10-16T14:11:23.436422Z +41 + +M000039.html +file + + + + +2008-03-28T15:44:42.000000Z +7f02999403f38304f4cc063263a3f30a +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/Game.src/.svn/format b/doc/classes/Game.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Game.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Game.src/.svn/text-base/M000011.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000011.html.svn-base new file mode 100644 index 0000000..bb023a8 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000011.html.svn-base @@ -0,0 +1,36 @@ + + + + + + new (Game) + + + + +
# File lib/libttc.rb, line 329
+  def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, 
+      pieces_each = 6)
+    @board = Board.new(spokes, spoke_length, arc_length)
+    @history = []
+    @pieces = Hash.new
+    @players = case
+                 when players == 2 ; ['a', 'd']
+                 when players == 3 ; ['a', 'c', 'e']
+                 when players == 4 ; ['a', 'b', 'd', 'e']
+                 when players == 5 ; ['a', 'b', 'c', 'd', 'e']
+                 when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f']
+               end
+    @current_player = 'a'
+    @players.each do |player|
+      players_base = board.positions[player]
+      (1..pieces_each).each do |count|
+        piece = Piece.new(count, players_base, player)
+        @pieces[player + count.to_s] = piece
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000012.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000012.html.svn-base new file mode 100644 index 0000000..a799d4f --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000012.html.svn-base @@ -0,0 +1,78 @@ + + + + + + apply_move (Game) + + + + +
# File lib/libttc.rb, line 353
+  def apply_move(move, player = @current_player)
+    # Check the move is a valid one
+    raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name)
+    raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player
+    raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured
+    raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty?
+    if move.destination.safe?
+      if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3
+        raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there")
+      end
+    end
+    if move.via_base?
+      moved_distance = board.distance_between[move.piece.position.place][player] +
+        board.distance_between[player][move.destination.place]
+    else
+      moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+    end
+    raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places") if moved_distance < 1 or moved_distance > 6
+
+    # Apply this move
+    move.piece.move_to(move.destination)
+
+    # Capture anything already there (unless it's a safe place or a base, 
+    #  or our own colour)
+    unless move.destination.safe? or move.destination.base?
+      @pieces.each do |name, target_piece|
+        if target_piece.position == move.destination and 
+            target_piece != move.piece and
+            not move.piece.contains.member?(target_piece) and
+            target_piece.colour != player
+          move.piece.capture(target_piece)
+        end
+      end
+    end
+    
+    # If the move was via our base, drop all captured pieces
+    if move.via_base?
+      capturers_base = board.positions[move.piece.colour]
+      move.piece.contains.each do |captured_piece|
+        captured_piece.move_to capturers_base
+        captured_piece.captured = false if captured_piece.colour == move.piece.colour
+      end
+      move.piece.contains = []
+    end
+    
+    # Record the new stae
+    this_game_state = GameState.new(move, player, @pieces)
+    @history << this_game_state
+
+    # Retain only players that have uncaptured pieces.  
+    # If there's only one player with uncaptured pieces, declare a win.
+    potential_players = []
+    @players.each do |p|
+      if (@pieces.values.select {|piece| piece.colour == p}).any? {|piece| not piece.captured}
+        potential_players << p
+      end
+#      potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured}
+    end
+    if potential_players.length <= 1
+      raise(GameWonNotice, "Game won by #{potential_players[0]}")
+    end
+    @players = potential_players.sort
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000013.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000013.html.svn-base new file mode 100644 index 0000000..76e5be0 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000013.html.svn-base @@ -0,0 +1,27 @@ + + + + + + apply_moves (Game) + + + + +
# File lib/libttc.rb, line 419
+  def apply_moves(moves)
+    moves.each do |move| 
+      if move.via_base?
+        moved_distance = board.distance_between[move.piece.position.place][@current_player] +
+          board.distance_between[@current_player][move.destination.place]
+      else
+        moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+      end
+      self.apply_move(move, @current_player)
+      next_player unless moved_distance == 6
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000014.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000014.html.svn-base new file mode 100644 index 0000000..16ec0bd --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000014.html.svn-base @@ -0,0 +1,26 @@ + + + + + + next_player (Game) + + + + +
# File lib/libttc.rb, line 434
+  def next_player
+    original_player = @current_player
+    begin
+      if @current_player == @players[-1]
+        @current_player = @players[0]
+      else
+        @current_player = @players[@players.index(@current_player) + 1]
+      end
+    end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player
+    @current_player
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000015.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000015.html.svn-base new file mode 100644 index 0000000..8b36978 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000015.html.svn-base @@ -0,0 +1,48 @@ + + + + + + possible_moves (Game) + + + + +
# File lib/libttc.rb, line 448
+  def possible_moves(die_result, player = @current_player)
+    moves = []
+    @pieces.each do |key, piece|
+      # only move current player's pieces, and only if they're not captured
+      if piece.colour == player and (not piece.captured)
+        (@board.valid_moves[piece.position.place][die_result]).each do |destination|
+          if destination.safe?
+            if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+              moves << Move.new(piece, destination, false)
+            end
+          else
+            moves << Move.new(piece, destination, false) unless destination.base?
+          end
+        end
+        # if we can move to our base (but not already on it), add moves via that...
+        if @board.distance_between[piece.position.place][player] <= die_result and 
+            not piece.position.place == player and
+            not piece.contains.empty?
+          distance_after_base = die_result - board.distance_between[piece.position.place][player]
+          (@board.valid_moves[player][distance_after_base]).each do |destination|
+            if destination.safe?
+              if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+                moves << Move.new(piece, destination, true)
+              end
+            else
+              moves << Move.new(piece, destination, true)
+            end
+          end
+        end
+      end
+    end
+    moves
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000016.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000016.html.svn-base new file mode 100644 index 0000000..1231a36 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000016.html.svn-base @@ -0,0 +1,24 @@ + + + + + + show_state (Game) + + + + +
# File lib/libttc.rb, line 484
+  def show_state
+    @pieces.keys.sort.each do |piece_name|
+      if @pieces[piece_name].captured
+        puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}"
+      else
+        puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}"
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000017.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000017.html.svn-base new file mode 100644 index 0000000..b1e7320 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000017.html.svn-base @@ -0,0 +1,22 @@ + + + + + + read_game (Game) + + + + +
# File lib/libttc.rb, line 498
+  def Game.read_game(gamelines)
+    gamelines.each {|l| l.chomp!}
+    game = Game.new(gamelines[0].to_i, 6, 6, 6, 6)
+    moves = []
+    gamelines[1..-2].each {|m| moves << m.to_move(game)}
+    return game, moves, gamelines[-1].to_i
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000021.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000021.html.svn-base new file mode 100644 index 0000000..3f8a43e --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000021.html.svn-base @@ -0,0 +1,35 @@ + + + + + + new (Game) + + + + +
# File lib/libttc.rb, line 318
+  def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, pieces_each = 6)
+    @board = Board.new(spokes, spoke_length, arc_length)
+    @history = []
+    @pieces = Hash.new
+    @players = case
+                 when players == 2 ; ['a', 'd']
+                 when players == 3 ; ['a', 'c', 'e']
+                 when players == 4 ; ['a', 'b', 'd', 'e']
+                 when players == 5 ; ['a', 'b', 'c', 'd', 'e']
+                 when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f']
+               end
+    @current_player = 'a'
+    @players.each do |player|
+      players_base = board.positions[player]
+      (1..pieces_each).each do |count|
+        piece = Piece.new(count, players_base, player)
+        @pieces[player + count.to_s] = piece
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000022.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000022.html.svn-base new file mode 100644 index 0000000..d336636 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000022.html.svn-base @@ -0,0 +1,72 @@ + + + + + + apply_move (Game) + + + + +
# File lib/libttc.rb, line 341
+  def apply_move(move, player = @current_player)
+    # Check the move is a valid one
+    raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name)
+    raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player
+    raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured
+    raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty?
+    if move.destination.safe?
+      if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3
+        raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there")
+      end
+    end
+    if move.via_base?
+      moved_distance = board.distance_between[move.piece.position.place][player] +
+        board.distance_between[player][move.destination.place]
+    else
+      moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+    end
+    raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places") if moved_distance < 1 or moved_distance > 6
+
+    # Apply this move
+    move.piece.move_to(move.destination)
+
+    # Capture anything already there (unless it's a safe place or a base, or our own colour)
+    unless move.destination.safe? or move.destination.base?
+      @pieces.each do |name, target_piece|
+        if target_piece.position == move.destination and 
+            target_piece != move.piece and
+            not move.piece.contains.member?(target_piece) and
+            target_piece.colour != player
+          move.piece.capture(target_piece)
+        end
+      end
+    end
+    
+    # If the move was via our base, drop all captured pieces
+    if move.via_base?
+      capturers_base = board.positions[move.piece.colour]
+      move.piece.contains.each do |captured_piece|
+        captured_piece.move_to capturers_base
+        captured_piece.captured = false if captured_piece.colour == move.piece.colour
+      end
+      move.piece.contains = []
+    end
+    
+    # Record the new stae
+    this_game_state = GameState.new(move, player, @pieces)
+    @history << this_game_state
+
+    # If there's only one player with uncaptured pieces, declare a win
+    potential_players = []
+    @players.each do |p|
+      potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured}
+    end
+    if potential_players.length <= 1
+      raise(GameWonNotice, "Game won by #{potential_players[0]}")
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000023.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000023.html.svn-base new file mode 100644 index 0000000..4ab28cf --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000023.html.svn-base @@ -0,0 +1,27 @@ + + + + + + apply_moves (Game) + + + + +
# File lib/libttc.rb, line 401
+  def apply_moves(moves)
+    moves.each do |move| 
+      if move.via_base?
+        moved_distance = board.distance_between[move.piece.position.place][@current_player] +
+          board.distance_between[@current_player][move.destination.place]
+      else
+        moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+      end
+      self.apply_move(move, @current_player)
+      next_player unless moved_distance == 6
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000024.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000024.html.svn-base new file mode 100644 index 0000000..c3acbeb --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000024.html.svn-base @@ -0,0 +1,26 @@ + + + + + + next_player (Game) + + + + +
# File lib/libttc.rb, line 416
+  def next_player
+    original_player = @current_player
+    begin
+      if @current_player == @players[-1]
+        @current_player = @players[0]
+      else
+        @current_player = @players[@players.index(@current_player) + 1]
+      end
+    end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player
+    @current_player
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000025.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000025.html.svn-base new file mode 100644 index 0000000..9d031de --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000025.html.svn-base @@ -0,0 +1,48 @@ + + + + + + possible_moves (Game) + + + + +
# File lib/libttc.rb, line 430
+  def possible_moves(die_result, player = @current_player)
+    moves = []
+    @pieces.each do |key, piece|
+      # only move current player's pieces, and only if they're not captured
+      if piece.colour == player and (not piece.captured)
+        (@board.valid_moves[piece.position.place][die_result]).each do |destination|
+          if destination.safe?
+            if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+              moves << Move.new(piece, destination, false)
+            end
+          else
+            moves << Move.new(piece, destination, false) unless destination.base?
+          end
+        end
+        # if we can move to our base (but not already on it), add moves via that...
+        if @board.distance_between[piece.position.place][player] <= die_result and 
+            not piece.position.place == player and
+            not piece.contains.empty?
+          distance_after_base = die_result - board.distance_between[piece.position.place][player]
+          (@board.valid_moves[player][distance_after_base]).each do |destination|
+            if destination.safe?
+              if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+                moves << Move.new(piece, destination, true)
+              end
+            else
+              moves << Move.new(piece, destination, true)
+            end
+          end
+        end
+      end
+    end
+    moves
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000026.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000026.html.svn-base new file mode 100644 index 0000000..e2d04c4 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000026.html.svn-base @@ -0,0 +1,24 @@ + + + + + + show_state (Game) + + + + +
# File lib/libttc.rb, line 466
+  def show_state
+    @pieces.keys.sort.each do |piece_name|
+      if @pieces[piece_name].captured
+        puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}"
+      else
+        puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}"
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000027.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000027.html.svn-base new file mode 100644 index 0000000..fc46f3a --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000027.html.svn-base @@ -0,0 +1,22 @@ + + + + + + read_game (Game) + + + + +
# File lib/libttc.rb, line 480
+  def Game.read_game(gamelines)
+    gamelines.each {|l| l.chomp!}
+    game = Game.new(gamelines[0].to_i, 6, 6, 6, 6)
+    moves = []
+    gamelines[1..-2].each {|m| moves << m.to_move(game)}
+    return game, moves, gamelines[-1].to_i
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000036.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000036.html.svn-base new file mode 100644 index 0000000..4e5c4ce --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000036.html.svn-base @@ -0,0 +1,36 @@ + + + + + + new (Game) + + + + +
# File lib/libttc.rb, line 355
+  def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, 
+      pieces_each = 6)
+    @board = Board.new(spokes, spoke_length, arc_length)
+    @history = []
+    @pieces = Hash.new
+    @players = case
+    when players == 2 ; ['a', 'd']
+    when players == 3 ; ['a', 'c', 'e']
+    when players == 4 ; ['a', 'b', 'd', 'e']
+    when players == 5 ; ['a', 'b', 'c', 'd', 'e']
+    when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f']
+    end
+    @current_player = 'a'
+    @players.each do |player|
+      players_base = @board.positions[player]
+      (1..pieces_each).each do |count|
+        piece = Piece.new(count, players_base, player)
+        @pieces[player + count.to_s] = piece
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000037.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000037.html.svn-base new file mode 100644 index 0000000..7f2ca42 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000037.html.svn-base @@ -0,0 +1,79 @@ + + + + + + apply_move! (Game) + + + + +
# File lib/libttc.rb, line 379
+  def apply_move!(move, player = @current_player)
+    # Check the move is a valid one
+    raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name)
+    raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player
+    raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured
+    raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty?
+    if move.destination.safe?
+      if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3
+        raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there")
+      end
+    end
+    if move.via_base?
+      moved_distance = board.distance_between[move.piece.position.place][player] +
+        board.distance_between[player][move.destination.place]
+    else
+      moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+    end
+    raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places (from #{move.piece.position} to #{move.destination})") if moved_distance < 1 or moved_distance > 6
+
+    # Apply this move
+    move.piece.move_to(move.destination)
+
+    # Capture anything already there (unless it's a safe place or a base, 
+    # or our own colour, or already captured)
+    unless move.destination.safe? or move.destination.base?
+      @pieces.each do |name, target_piece|
+        if target_piece.position == move.destination and 
+            target_piece != move.piece and
+            not move.piece.contains.member?(target_piece) and
+            target_piece.colour != player and
+            not target_piece.captured
+          move.piece.capture(target_piece)
+        end
+      end
+    end
+    
+    # If the move was via our base, drop all captured pieces
+    if move.via_base?
+      capturers_base = board.positions[move.piece.colour]
+      move.piece.contains.each do |captured_piece|
+        captured_piece.move_to capturers_base
+        captured_piece.captured = false if captured_piece.colour == move.piece.colour
+      end
+      move.piece.contains = []
+    end
+    
+    # Record the new stae
+    this_game_state = GameState.new(move, player, @pieces)
+    @history << this_game_state
+
+    # Retain only players that have uncaptured pieces.  
+    # If there's only one player with uncaptured pieces, declare a win.
+    potential_players = []
+    @players.each do |p|
+      if (@pieces.values.select {|piece| piece.colour == p}).any? {|piece| not piece.captured}
+        potential_players << p
+      end
+      #      potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured}
+    end
+    if potential_players.length <= 1
+      raise(GameWonNotice, "Game won by #{potential_players[0]}")
+    end
+    @players = potential_players.sort
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000038.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000038.html.svn-base new file mode 100644 index 0000000..76e138e --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000038.html.svn-base @@ -0,0 +1,42 @@ + + + + + + undo_move! (Game) + + + + +
# File lib/libttc.rb, line 445
+  def undo_move!
+    if @history.length > 1
+      # general case
+      state_to_restore = @history[-2]
+      @current_player = @history[-1].player
+      @pieces.each do |name, piece| 
+        copy_piece = state_to_restore.pieces_after_move[name]
+        piece.position = copy_piece.position
+        piece.captured = copy_piece.captured
+        piece.contains = []
+        copy_piece.contains.each do |p|
+#          piece.capture(@pieces[p.name])
+          piece.contains << @pieces[p.name]
+        end
+      end
+      @history.pop    
+    elsif @history.length == 1
+      # reset to start
+      @current_player = 'a'
+      @pieces.each do |name, piece| 
+        piece.position = @board.positions[piece.colour]
+        piece.captured = false
+        piece.contains = []
+      end
+      @history.pop    
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000039.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000039.html.svn-base new file mode 100644 index 0000000..e6beeb0 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000039.html.svn-base @@ -0,0 +1,27 @@ + + + + + + apply_moves! (Game) + + + + +
# File lib/libttc.rb, line 474
+  def apply_moves!(moves)
+    moves.each do |move| 
+      if move.via_base?
+        moved_distance = board.distance_between[move.piece.position.place][@current_player] +
+          board.distance_between[@current_player][move.destination.place]
+      else
+        moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+      end
+      self.apply_move!(move, @current_player)
+      next_player! unless moved_distance == 6
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000040.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000040.html.svn-base new file mode 100644 index 0000000..bb9306b --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000040.html.svn-base @@ -0,0 +1,26 @@ + + + + + + next_player! (Game) + + + + +
# File lib/libttc.rb, line 489
+  def next_player!
+    original_player = @current_player
+    begin
+      if @current_player == @players[-1]
+        @current_player = @players[0]
+      else
+        @current_player = @players[@players.index(@current_player) + 1]
+      end
+    end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player
+    @current_player
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000041.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000041.html.svn-base new file mode 100644 index 0000000..d8fff61 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000041.html.svn-base @@ -0,0 +1,48 @@ + + + + + + possible_moves (Game) + + + + +
# File lib/libttc.rb, line 504
+  def possible_moves(die_result, player = @current_player)
+    moves = []
+    @pieces.each do |key, piece|
+      # only move current player's pieces, and only if they're not captured
+      if piece.colour == player and (not piece.captured)
+        (@board.valid_moves[piece.position.place][die_result]).each do |destination|
+          if destination.safe?
+            if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+              moves << Move.new(piece, destination, false)
+            end
+          else
+            moves << Move.new(piece, destination, false) unless destination.base?
+          end
+        end
+        # if we can move to our base (but not already on it), add moves via that...
+        if @board.distance_between[piece.position.place][player] <= die_result and 
+            not piece.position.place == player and
+            not piece.contains.empty?
+          distance_after_base = die_result - @board.distance_between[piece.position.place][player]
+          (@board.valid_moves[player][distance_after_base]).each do |destination|
+            if destination.safe?
+              if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+                moves << Move.new(piece, destination, true)
+              end
+            else
+              moves << Move.new(piece, destination, true)
+            end
+          end
+        end
+      end
+    end
+    moves
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000042.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000042.html.svn-base new file mode 100644 index 0000000..4ba853e --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000042.html.svn-base @@ -0,0 +1,26 @@ + + + + + + build_state_string (Game) + + + + +
# File lib/libttc.rb, line 539
+  def build_state_string
+    outstr = "Current player = #{@current_player}\n"
+    @pieces.keys.sort.each do |piece_name|
+      if @pieces[piece_name].captured
+        outstr << "Piece #{piece_name} captured, at #{@pieces[piece_name].position}\n"
+      else
+        outstr << "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}\n"
+      end
+    end
+    outstr
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000043.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000043.html.svn-base new file mode 100644 index 0000000..2b3bc35 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000043.html.svn-base @@ -0,0 +1,25 @@ + + + + + + show_state (Game) + + + + +
# File lib/libttc.rb, line 552
+  def show_state
+    puts build_state_string
+#    @pieces.keys.sort.each do |piece_name|
+#      if @pieces[piece_name].captured
+#        puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}"
+#      else
+#        puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}"
+#      end
+#    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000044.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000044.html.svn-base new file mode 100644 index 0000000..55553f4 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000044.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Game) + + + + +
# File lib/libttc.rb, line 563
+  def to_s
+    show_state
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000045.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000045.html.svn-base new file mode 100644 index 0000000..4ca247d --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000045.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_str (Game) + + + + +
# File lib/libttc.rb, line 567
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/.svn/text-base/M000046.html.svn-base b/doc/classes/Game.src/.svn/text-base/M000046.html.svn-base new file mode 100644 index 0000000..c3e7452 --- /dev/null +++ b/doc/classes/Game.src/.svn/text-base/M000046.html.svn-base @@ -0,0 +1,22 @@ + + + + + + read_game (Game) + + + + +
# File lib/libttc.rb, line 576
+  def Game.read_game(gamelines)
+    gamelines.each {|l| l.chomp!}
+    game = Game.new(gamelines[0].to_i, 6, 6, 6, 6)
+    moves = []
+    gamelines[1..-2].each {|m| moves << m.to_move(game)}
+    return game, moves, gamelines[-1].to_i
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000011.html b/doc/classes/Game.src/M000011.html new file mode 100644 index 0000000..bb023a8 --- /dev/null +++ b/doc/classes/Game.src/M000011.html @@ -0,0 +1,36 @@ + + + + + + new (Game) + + + + +
# File lib/libttc.rb, line 329
+  def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, 
+      pieces_each = 6)
+    @board = Board.new(spokes, spoke_length, arc_length)
+    @history = []
+    @pieces = Hash.new
+    @players = case
+                 when players == 2 ; ['a', 'd']
+                 when players == 3 ; ['a', 'c', 'e']
+                 when players == 4 ; ['a', 'b', 'd', 'e']
+                 when players == 5 ; ['a', 'b', 'c', 'd', 'e']
+                 when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f']
+               end
+    @current_player = 'a'
+    @players.each do |player|
+      players_base = board.positions[player]
+      (1..pieces_each).each do |count|
+        piece = Piece.new(count, players_base, player)
+        @pieces[player + count.to_s] = piece
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000012.html b/doc/classes/Game.src/M000012.html new file mode 100644 index 0000000..a799d4f --- /dev/null +++ b/doc/classes/Game.src/M000012.html @@ -0,0 +1,78 @@ + + + + + + apply_move (Game) + + + + +
# File lib/libttc.rb, line 353
+  def apply_move(move, player = @current_player)
+    # Check the move is a valid one
+    raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name)
+    raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player
+    raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured
+    raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty?
+    if move.destination.safe?
+      if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3
+        raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there")
+      end
+    end
+    if move.via_base?
+      moved_distance = board.distance_between[move.piece.position.place][player] +
+        board.distance_between[player][move.destination.place]
+    else
+      moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+    end
+    raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places") if moved_distance < 1 or moved_distance > 6
+
+    # Apply this move
+    move.piece.move_to(move.destination)
+
+    # Capture anything already there (unless it's a safe place or a base, 
+    #  or our own colour)
+    unless move.destination.safe? or move.destination.base?
+      @pieces.each do |name, target_piece|
+        if target_piece.position == move.destination and 
+            target_piece != move.piece and
+            not move.piece.contains.member?(target_piece) and
+            target_piece.colour != player
+          move.piece.capture(target_piece)
+        end
+      end
+    end
+    
+    # If the move was via our base, drop all captured pieces
+    if move.via_base?
+      capturers_base = board.positions[move.piece.colour]
+      move.piece.contains.each do |captured_piece|
+        captured_piece.move_to capturers_base
+        captured_piece.captured = false if captured_piece.colour == move.piece.colour
+      end
+      move.piece.contains = []
+    end
+    
+    # Record the new stae
+    this_game_state = GameState.new(move, player, @pieces)
+    @history << this_game_state
+
+    # Retain only players that have uncaptured pieces.  
+    # If there's only one player with uncaptured pieces, declare a win.
+    potential_players = []
+    @players.each do |p|
+      if (@pieces.values.select {|piece| piece.colour == p}).any? {|piece| not piece.captured}
+        potential_players << p
+      end
+#      potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured}
+    end
+    if potential_players.length <= 1
+      raise(GameWonNotice, "Game won by #{potential_players[0]}")
+    end
+    @players = potential_players.sort
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000013.html b/doc/classes/Game.src/M000013.html new file mode 100644 index 0000000..76e5be0 --- /dev/null +++ b/doc/classes/Game.src/M000013.html @@ -0,0 +1,27 @@ + + + + + + apply_moves (Game) + + + + +
# File lib/libttc.rb, line 419
+  def apply_moves(moves)
+    moves.each do |move| 
+      if move.via_base?
+        moved_distance = board.distance_between[move.piece.position.place][@current_player] +
+          board.distance_between[@current_player][move.destination.place]
+      else
+        moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+      end
+      self.apply_move(move, @current_player)
+      next_player unless moved_distance == 6
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000014.html b/doc/classes/Game.src/M000014.html new file mode 100644 index 0000000..16ec0bd --- /dev/null +++ b/doc/classes/Game.src/M000014.html @@ -0,0 +1,26 @@ + + + + + + next_player (Game) + + + + +
# File lib/libttc.rb, line 434
+  def next_player
+    original_player = @current_player
+    begin
+      if @current_player == @players[-1]
+        @current_player = @players[0]
+      else
+        @current_player = @players[@players.index(@current_player) + 1]
+      end
+    end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player
+    @current_player
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000015.html b/doc/classes/Game.src/M000015.html new file mode 100644 index 0000000..8b36978 --- /dev/null +++ b/doc/classes/Game.src/M000015.html @@ -0,0 +1,48 @@ + + + + + + possible_moves (Game) + + + + +
# File lib/libttc.rb, line 448
+  def possible_moves(die_result, player = @current_player)
+    moves = []
+    @pieces.each do |key, piece|
+      # only move current player's pieces, and only if they're not captured
+      if piece.colour == player and (not piece.captured)
+        (@board.valid_moves[piece.position.place][die_result]).each do |destination|
+          if destination.safe?
+            if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+              moves << Move.new(piece, destination, false)
+            end
+          else
+            moves << Move.new(piece, destination, false) unless destination.base?
+          end
+        end
+        # if we can move to our base (but not already on it), add moves via that...
+        if @board.distance_between[piece.position.place][player] <= die_result and 
+            not piece.position.place == player and
+            not piece.contains.empty?
+          distance_after_base = die_result - board.distance_between[piece.position.place][player]
+          (@board.valid_moves[player][distance_after_base]).each do |destination|
+            if destination.safe?
+              if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+                moves << Move.new(piece, destination, true)
+              end
+            else
+              moves << Move.new(piece, destination, true)
+            end
+          end
+        end
+      end
+    end
+    moves
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000016.html b/doc/classes/Game.src/M000016.html new file mode 100644 index 0000000..1231a36 --- /dev/null +++ b/doc/classes/Game.src/M000016.html @@ -0,0 +1,24 @@ + + + + + + show_state (Game) + + + + +
# File lib/libttc.rb, line 484
+  def show_state
+    @pieces.keys.sort.each do |piece_name|
+      if @pieces[piece_name].captured
+        puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}"
+      else
+        puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}"
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000017.html b/doc/classes/Game.src/M000017.html new file mode 100644 index 0000000..b1e7320 --- /dev/null +++ b/doc/classes/Game.src/M000017.html @@ -0,0 +1,22 @@ + + + + + + read_game (Game) + + + + +
# File lib/libttc.rb, line 498
+  def Game.read_game(gamelines)
+    gamelines.each {|l| l.chomp!}
+    game = Game.new(gamelines[0].to_i, 6, 6, 6, 6)
+    moves = []
+    gamelines[1..-2].each {|m| moves << m.to_move(game)}
+    return game, moves, gamelines[-1].to_i
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000021.html b/doc/classes/Game.src/M000021.html new file mode 100644 index 0000000..3f8a43e --- /dev/null +++ b/doc/classes/Game.src/M000021.html @@ -0,0 +1,35 @@ + + + + + + new (Game) + + + + +
# File lib/libttc.rb, line 318
+  def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, pieces_each = 6)
+    @board = Board.new(spokes, spoke_length, arc_length)
+    @history = []
+    @pieces = Hash.new
+    @players = case
+                 when players == 2 ; ['a', 'd']
+                 when players == 3 ; ['a', 'c', 'e']
+                 when players == 4 ; ['a', 'b', 'd', 'e']
+                 when players == 5 ; ['a', 'b', 'c', 'd', 'e']
+                 when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f']
+               end
+    @current_player = 'a'
+    @players.each do |player|
+      players_base = board.positions[player]
+      (1..pieces_each).each do |count|
+        piece = Piece.new(count, players_base, player)
+        @pieces[player + count.to_s] = piece
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000022.html b/doc/classes/Game.src/M000022.html new file mode 100644 index 0000000..d336636 --- /dev/null +++ b/doc/classes/Game.src/M000022.html @@ -0,0 +1,72 @@ + + + + + + apply_move (Game) + + + + +
# File lib/libttc.rb, line 341
+  def apply_move(move, player = @current_player)
+    # Check the move is a valid one
+    raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name)
+    raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player
+    raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured
+    raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty?
+    if move.destination.safe?
+      if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3
+        raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there")
+      end
+    end
+    if move.via_base?
+      moved_distance = board.distance_between[move.piece.position.place][player] +
+        board.distance_between[player][move.destination.place]
+    else
+      moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+    end
+    raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places") if moved_distance < 1 or moved_distance > 6
+
+    # Apply this move
+    move.piece.move_to(move.destination)
+
+    # Capture anything already there (unless it's a safe place or a base, or our own colour)
+    unless move.destination.safe? or move.destination.base?
+      @pieces.each do |name, target_piece|
+        if target_piece.position == move.destination and 
+            target_piece != move.piece and
+            not move.piece.contains.member?(target_piece) and
+            target_piece.colour != player
+          move.piece.capture(target_piece)
+        end
+      end
+    end
+    
+    # If the move was via our base, drop all captured pieces
+    if move.via_base?
+      capturers_base = board.positions[move.piece.colour]
+      move.piece.contains.each do |captured_piece|
+        captured_piece.move_to capturers_base
+        captured_piece.captured = false if captured_piece.colour == move.piece.colour
+      end
+      move.piece.contains = []
+    end
+    
+    # Record the new stae
+    this_game_state = GameState.new(move, player, @pieces)
+    @history << this_game_state
+
+    # If there's only one player with uncaptured pieces, declare a win
+    potential_players = []
+    @players.each do |p|
+      potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured}
+    end
+    if potential_players.length <= 1
+      raise(GameWonNotice, "Game won by #{potential_players[0]}")
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000023.html b/doc/classes/Game.src/M000023.html new file mode 100644 index 0000000..4ab28cf --- /dev/null +++ b/doc/classes/Game.src/M000023.html @@ -0,0 +1,27 @@ + + + + + + apply_moves (Game) + + + + +
# File lib/libttc.rb, line 401
+  def apply_moves(moves)
+    moves.each do |move| 
+      if move.via_base?
+        moved_distance = board.distance_between[move.piece.position.place][@current_player] +
+          board.distance_between[@current_player][move.destination.place]
+      else
+        moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+      end
+      self.apply_move(move, @current_player)
+      next_player unless moved_distance == 6
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000024.html b/doc/classes/Game.src/M000024.html new file mode 100644 index 0000000..c3acbeb --- /dev/null +++ b/doc/classes/Game.src/M000024.html @@ -0,0 +1,26 @@ + + + + + + next_player (Game) + + + + +
# File lib/libttc.rb, line 416
+  def next_player
+    original_player = @current_player
+    begin
+      if @current_player == @players[-1]
+        @current_player = @players[0]
+      else
+        @current_player = @players[@players.index(@current_player) + 1]
+      end
+    end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player
+    @current_player
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000025.html b/doc/classes/Game.src/M000025.html new file mode 100644 index 0000000..9d031de --- /dev/null +++ b/doc/classes/Game.src/M000025.html @@ -0,0 +1,48 @@ + + + + + + possible_moves (Game) + + + + +
# File lib/libttc.rb, line 430
+  def possible_moves(die_result, player = @current_player)
+    moves = []
+    @pieces.each do |key, piece|
+      # only move current player's pieces, and only if they're not captured
+      if piece.colour == player and (not piece.captured)
+        (@board.valid_moves[piece.position.place][die_result]).each do |destination|
+          if destination.safe?
+            if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+              moves << Move.new(piece, destination, false)
+            end
+          else
+            moves << Move.new(piece, destination, false) unless destination.base?
+          end
+        end
+        # if we can move to our base (but not already on it), add moves via that...
+        if @board.distance_between[piece.position.place][player] <= die_result and 
+            not piece.position.place == player and
+            not piece.contains.empty?
+          distance_after_base = die_result - board.distance_between[piece.position.place][player]
+          (@board.valid_moves[player][distance_after_base]).each do |destination|
+            if destination.safe?
+              if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+                moves << Move.new(piece, destination, true)
+              end
+            else
+              moves << Move.new(piece, destination, true)
+            end
+          end
+        end
+      end
+    end
+    moves
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000026.html b/doc/classes/Game.src/M000026.html new file mode 100644 index 0000000..e2d04c4 --- /dev/null +++ b/doc/classes/Game.src/M000026.html @@ -0,0 +1,24 @@ + + + + + + show_state (Game) + + + + +
# File lib/libttc.rb, line 466
+  def show_state
+    @pieces.keys.sort.each do |piece_name|
+      if @pieces[piece_name].captured
+        puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}"
+      else
+        puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}"
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000027.html b/doc/classes/Game.src/M000027.html new file mode 100644 index 0000000..fc46f3a --- /dev/null +++ b/doc/classes/Game.src/M000027.html @@ -0,0 +1,22 @@ + + + + + + read_game (Game) + + + + +
# File lib/libttc.rb, line 480
+  def Game.read_game(gamelines)
+    gamelines.each {|l| l.chomp!}
+    game = Game.new(gamelines[0].to_i, 6, 6, 6, 6)
+    moves = []
+    gamelines[1..-2].each {|m| moves << m.to_move(game)}
+    return game, moves, gamelines[-1].to_i
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000036.html b/doc/classes/Game.src/M000036.html new file mode 100644 index 0000000..4e5c4ce --- /dev/null +++ b/doc/classes/Game.src/M000036.html @@ -0,0 +1,36 @@ + + + + + + new (Game) + + + + +
# File lib/libttc.rb, line 355
+  def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, 
+      pieces_each = 6)
+    @board = Board.new(spokes, spoke_length, arc_length)
+    @history = []
+    @pieces = Hash.new
+    @players = case
+    when players == 2 ; ['a', 'd']
+    when players == 3 ; ['a', 'c', 'e']
+    when players == 4 ; ['a', 'b', 'd', 'e']
+    when players == 5 ; ['a', 'b', 'c', 'd', 'e']
+    when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f']
+    end
+    @current_player = 'a'
+    @players.each do |player|
+      players_base = @board.positions[player]
+      (1..pieces_each).each do |count|
+        piece = Piece.new(count, players_base, player)
+        @pieces[player + count.to_s] = piece
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000037.html b/doc/classes/Game.src/M000037.html new file mode 100644 index 0000000..7f2ca42 --- /dev/null +++ b/doc/classes/Game.src/M000037.html @@ -0,0 +1,79 @@ + + + + + + apply_move! (Game) + + + + +
# File lib/libttc.rb, line 379
+  def apply_move!(move, player = @current_player)
+    # Check the move is a valid one
+    raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name)
+    raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player
+    raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured
+    raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty?
+    if move.destination.safe?
+      if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3
+        raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there")
+      end
+    end
+    if move.via_base?
+      moved_distance = board.distance_between[move.piece.position.place][player] +
+        board.distance_between[player][move.destination.place]
+    else
+      moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+    end
+    raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places (from #{move.piece.position} to #{move.destination})") if moved_distance < 1 or moved_distance > 6
+
+    # Apply this move
+    move.piece.move_to(move.destination)
+
+    # Capture anything already there (unless it's a safe place or a base, 
+    # or our own colour, or already captured)
+    unless move.destination.safe? or move.destination.base?
+      @pieces.each do |name, target_piece|
+        if target_piece.position == move.destination and 
+            target_piece != move.piece and
+            not move.piece.contains.member?(target_piece) and
+            target_piece.colour != player and
+            not target_piece.captured
+          move.piece.capture(target_piece)
+        end
+      end
+    end
+    
+    # If the move was via our base, drop all captured pieces
+    if move.via_base?
+      capturers_base = board.positions[move.piece.colour]
+      move.piece.contains.each do |captured_piece|
+        captured_piece.move_to capturers_base
+        captured_piece.captured = false if captured_piece.colour == move.piece.colour
+      end
+      move.piece.contains = []
+    end
+    
+    # Record the new stae
+    this_game_state = GameState.new(move, player, @pieces)
+    @history << this_game_state
+
+    # Retain only players that have uncaptured pieces.  
+    # If there's only one player with uncaptured pieces, declare a win.
+    potential_players = []
+    @players.each do |p|
+      if (@pieces.values.select {|piece| piece.colour == p}).any? {|piece| not piece.captured}
+        potential_players << p
+      end
+      #      potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured}
+    end
+    if potential_players.length <= 1
+      raise(GameWonNotice, "Game won by #{potential_players[0]}")
+    end
+    @players = potential_players.sort
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000038.html b/doc/classes/Game.src/M000038.html new file mode 100644 index 0000000..76e138e --- /dev/null +++ b/doc/classes/Game.src/M000038.html @@ -0,0 +1,42 @@ + + + + + + undo_move! (Game) + + + + +
# File lib/libttc.rb, line 445
+  def undo_move!
+    if @history.length > 1
+      # general case
+      state_to_restore = @history[-2]
+      @current_player = @history[-1].player
+      @pieces.each do |name, piece| 
+        copy_piece = state_to_restore.pieces_after_move[name]
+        piece.position = copy_piece.position
+        piece.captured = copy_piece.captured
+        piece.contains = []
+        copy_piece.contains.each do |p|
+#          piece.capture(@pieces[p.name])
+          piece.contains << @pieces[p.name]
+        end
+      end
+      @history.pop    
+    elsif @history.length == 1
+      # reset to start
+      @current_player = 'a'
+      @pieces.each do |name, piece| 
+        piece.position = @board.positions[piece.colour]
+        piece.captured = false
+        piece.contains = []
+      end
+      @history.pop    
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000039.html b/doc/classes/Game.src/M000039.html new file mode 100644 index 0000000..e6beeb0 --- /dev/null +++ b/doc/classes/Game.src/M000039.html @@ -0,0 +1,27 @@ + + + + + + apply_moves! (Game) + + + + +
# File lib/libttc.rb, line 474
+  def apply_moves!(moves)
+    moves.each do |move| 
+      if move.via_base?
+        moved_distance = board.distance_between[move.piece.position.place][@current_player] +
+          board.distance_between[@current_player][move.destination.place]
+      else
+        moved_distance = board.distance_between[move.piece.position.place][move.destination.place]
+      end
+      self.apply_move!(move, @current_player)
+      next_player! unless moved_distance == 6
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000040.html b/doc/classes/Game.src/M000040.html new file mode 100644 index 0000000..bb9306b --- /dev/null +++ b/doc/classes/Game.src/M000040.html @@ -0,0 +1,26 @@ + + + + + + next_player! (Game) + + + + +
# File lib/libttc.rb, line 489
+  def next_player!
+    original_player = @current_player
+    begin
+      if @current_player == @players[-1]
+        @current_player = @players[0]
+      else
+        @current_player = @players[@players.index(@current_player) + 1]
+      end
+    end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player
+    @current_player
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000041.html b/doc/classes/Game.src/M000041.html new file mode 100644 index 0000000..d8fff61 --- /dev/null +++ b/doc/classes/Game.src/M000041.html @@ -0,0 +1,48 @@ + + + + + + possible_moves (Game) + + + + +
# File lib/libttc.rb, line 504
+  def possible_moves(die_result, player = @current_player)
+    moves = []
+    @pieces.each do |key, piece|
+      # only move current player's pieces, and only if they're not captured
+      if piece.colour == player and (not piece.captured)
+        (@board.valid_moves[piece.position.place][die_result]).each do |destination|
+          if destination.safe?
+            if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+              moves << Move.new(piece, destination, false)
+            end
+          else
+            moves << Move.new(piece, destination, false) unless destination.base?
+          end
+        end
+        # if we can move to our base (but not already on it), add moves via that...
+        if @board.distance_between[piece.position.place][player] <= die_result and 
+            not piece.position.place == player and
+            not piece.contains.empty?
+          distance_after_base = die_result - @board.distance_between[piece.position.place][player]
+          (@board.valid_moves[player][distance_after_base]).each do |destination|
+            if destination.safe?
+              if (@pieces.find_all {|k, p| p.position == destination}).length < 3
+                moves << Move.new(piece, destination, true)
+              end
+            else
+              moves << Move.new(piece, destination, true)
+            end
+          end
+        end
+      end
+    end
+    moves
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000042.html b/doc/classes/Game.src/M000042.html new file mode 100644 index 0000000..4ba853e --- /dev/null +++ b/doc/classes/Game.src/M000042.html @@ -0,0 +1,26 @@ + + + + + + build_state_string (Game) + + + + +
# File lib/libttc.rb, line 539
+  def build_state_string
+    outstr = "Current player = #{@current_player}\n"
+    @pieces.keys.sort.each do |piece_name|
+      if @pieces[piece_name].captured
+        outstr << "Piece #{piece_name} captured, at #{@pieces[piece_name].position}\n"
+      else
+        outstr << "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}\n"
+      end
+    end
+    outstr
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000043.html b/doc/classes/Game.src/M000043.html new file mode 100644 index 0000000..2b3bc35 --- /dev/null +++ b/doc/classes/Game.src/M000043.html @@ -0,0 +1,25 @@ + + + + + + show_state (Game) + + + + +
# File lib/libttc.rb, line 552
+  def show_state
+    puts build_state_string
+#    @pieces.keys.sort.each do |piece_name|
+#      if @pieces[piece_name].captured
+#        puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}"
+#      else
+#        puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}"
+#      end
+#    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000044.html b/doc/classes/Game.src/M000044.html new file mode 100644 index 0000000..55553f4 --- /dev/null +++ b/doc/classes/Game.src/M000044.html @@ -0,0 +1,18 @@ + + + + + + to_s (Game) + + + + +
# File lib/libttc.rb, line 563
+  def to_s
+    show_state
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000045.html b/doc/classes/Game.src/M000045.html new file mode 100644 index 0000000..4ca247d --- /dev/null +++ b/doc/classes/Game.src/M000045.html @@ -0,0 +1,18 @@ + + + + + + to_str (Game) + + + + +
# File lib/libttc.rb, line 567
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Game.src/M000046.html b/doc/classes/Game.src/M000046.html new file mode 100644 index 0000000..c3e7452 --- /dev/null +++ b/doc/classes/Game.src/M000046.html @@ -0,0 +1,22 @@ + + + + + + read_game (Game) + + + + +
# File lib/libttc.rb, line 576
+  def Game.read_game(gamelines)
+    gamelines.each {|l| l.chomp!}
+    game = Game.new(gamelines[0].to_i, 6, 6, 6, 6)
+    moves = []
+    gamelines[1..-2].each {|m| moves << m.to_move(game)}
+    return game, moves, gamelines[-1].to_i
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.html b/doc/classes/GameHandler.html new file mode 100644 index 0000000..874113e --- /dev/null +++ b/doc/classes/GameHandler.html @@ -0,0 +1,181 @@ + + + + + + Class: GameHandler + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameHandler
In: + + src/play.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Play a game to completion, given a set of player agents. +

+ +
+ + +
+ +
+

Methods

+ +
+ new   + play   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + +
game [R] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

+Create a game handler that uses a set of players +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Play a game of Trap the Cap. If players make illegal moves, disqualify them +and restart the game. Terminate the game if there‘s a winner, +there‘s only one player left, or the game has gone on too long. +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/.svn/all-wcprops b/doc/classes/GameHandler.src/.svn/all-wcprops new file mode 100644 index 0000000..e0a13fb --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/all-wcprops @@ -0,0 +1,41 @@ +K 25 +svn:wc:ra_dav:version-url +V 66 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameHandler.src +END +M000011.html +K 25 +svn:wc:ra_dav:version-url +V 79 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameHandler.src/M000011.html +END +M000012.html +K 25 +svn:wc:ra_dav:version-url +V 79 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameHandler.src/M000012.html +END +M000015.html +K 25 +svn:wc:ra_dav:version-url +V 79 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameHandler.src/M000015.html +END +M000007.html +K 25 +svn:wc:ra_dav:version-url +V 79 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameHandler.src/M000007.html +END +M000016.html +K 25 +svn:wc:ra_dav:version-url +V 79 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameHandler.src/M000016.html +END +M000008.html +K 25 +svn:wc:ra_dav:version-url +V 79 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameHandler.src/M000008.html +END diff --git a/doc/classes/GameHandler.src/.svn/entries b/doc/classes/GameHandler.src/.svn/entries new file mode 100644 index 0000000..40e7c85 --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/entries @@ -0,0 +1,82 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/GameHandler.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +M000011.html +file + + + + +2008-04-23T19:33:07.000000Z +939077acf9214bad9823993b168f41fd +2008-10-16T14:11:23.436422Z +41 + +M000012.html +file + + + + +2008-04-23T19:33:07.000000Z +2b3aed430837f7fcb7efcc0215aa15b1 +2008-10-16T14:11:23.436422Z +41 + +M000015.html +file + + + + +2008-03-28T15:44:41.000000Z +a7006ef4f9d9898134b63084e0f5ee93 +2008-10-16T14:11:23.436422Z +41 + +M000007.html +file + + + + +2008-04-23T19:29:25.000000Z +52c636847bfcbf3e9c7c30bf40a14eb7 +2008-10-16T14:11:23.436422Z +41 + +M000016.html +file + + + + +2008-03-28T15:44:41.000000Z +04d010669eee28801a59cb0aa2d7f136 +2008-10-16T14:11:23.436422Z +41 + +M000008.html +file + + + + +2008-04-23T19:29:25.000000Z +92ef1798c25bf920d3d3fece94068477 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/GameHandler.src/.svn/format b/doc/classes/GameHandler.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/GameHandler.src/.svn/text-base/M000007.html.svn-base b/doc/classes/GameHandler.src/.svn/text-base/M000007.html.svn-base new file mode 100644 index 0000000..7d5ec99 --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/text-base/M000007.html.svn-base @@ -0,0 +1,27 @@ + + + + + + new (GameHandler) + + + + +
# File src/play.rb, line 17
+  def initialize(players, limit = 5000, verbose = false, very_verbose = false)
+    @game = Game.new(players.length)
+    @verbose = verbose
+    @very_verbose = very_verbose
+    @limit = limit
+    
+    # Give each player a name
+    @named_players = Hash.new 
+    (@game.players.zip players).each do |kv|
+      @named_players[kv[0]] = kv[1]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/.svn/text-base/M000008.html.svn-base b/doc/classes/GameHandler.src/.svn/text-base/M000008.html.svn-base new file mode 100644 index 0000000..5799d25 --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/text-base/M000008.html.svn-base @@ -0,0 +1,39 @@ + + + + + + play (GameHandler) + + + + +
# File src/play.rb, line 33
+  def play
+    while @game.history.length < @limit
+      roll = rand(6) + 1
+      move_to_apply = @named_players[@game.current_player].best_move(@game, roll)
+      puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose
+      @game.apply_moves! [move_to_apply]
+      puts @game if @very_verbose
+    end
+    puts "Game terminated after #{@game.history.length} moves" if @verbose
+    [:draw, @limit]
+  rescue GameWonNotice => win_notification
+    winner = win_notification.message[-1,1]
+    puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose
+    [@named_players[winner], @game.history.length]
+  rescue InvalidCaptureError, InvalidMoveError
+    puts "Disqualifying player #{@game.current_player}" if @verbose
+    @named_players.delete @game.current_player
+    if @named_players.length > 1
+      retry
+    else
+      puts "Game won by #{@named_players.keys[0]} by default" if @verbose
+      [@named_players[@named_players.keys[0]], 0]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/.svn/text-base/M000011.html.svn-base b/doc/classes/GameHandler.src/.svn/text-base/M000011.html.svn-base new file mode 100644 index 0000000..c42e4f7 --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/text-base/M000011.html.svn-base @@ -0,0 +1,27 @@ + + + + + + new (GameHandler) + + + + +
# File src/play.rb, line 20
+  def initialize(players, limit = 5000, verbose = false, very_verbose = false)
+    @game = Game.new(players.length)
+    @verbose = verbose
+    @very_verbose = very_verbose
+    @limit = limit
+    
+    # Give each player a name
+    @named_players = Hash.new 
+    (@game.players.zip players).each do |kv|
+      @named_players[kv[0]] = kv[1]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/.svn/text-base/M000012.html.svn-base b/doc/classes/GameHandler.src/.svn/text-base/M000012.html.svn-base new file mode 100644 index 0000000..17018ca --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/text-base/M000012.html.svn-base @@ -0,0 +1,39 @@ + + + + + + play (GameHandler) + + + + +
# File src/play.rb, line 36
+  def play
+    while @game.history.length < @limit
+      roll = rand(6) + 1
+      move_to_apply = @named_players[@game.current_player].best_move(@game, roll)
+      puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose
+      @game.apply_moves! [move_to_apply]
+      puts @game if @very_verbose
+    end
+    puts "Game terminated after #{@game.history.length} moves" if @verbose
+    [:draw, @limit]
+  rescue GameWonNotice => win_notification
+    winner = win_notification.message[-1,1]
+    puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose
+    [@named_players[winner], @game.history.length]
+  rescue InvalidCaptureError, InvalidMoveError
+    puts "Disqualifying player #{@game.current_player}" if @verbose
+    @named_players.delete @game.current_player
+    if @named_players.length > 1
+      retry
+    else
+      puts "Game won by #{@named_players.keys[0]} by default" if @verbose
+      [@named_players[@named_players.keys[0]], 0]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/.svn/text-base/M000015.html.svn-base b/doc/classes/GameHandler.src/.svn/text-base/M000015.html.svn-base new file mode 100644 index 0000000..c8e9e56 --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/text-base/M000015.html.svn-base @@ -0,0 +1,26 @@ + + + + + + new (GameHandler) + + + + +
# File src/play.rb, line 16
+  def initialize(players, verbose = false, limit = 5000)
+    @game = Game.new(players.length)
+    @verbose = verbose
+    @limit = limit
+    
+    # Give each player a name
+    @named_players = Hash.new 
+    (@game.players.zip players).each do |kv|
+      @named_players[kv[0]] = kv[1]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/.svn/text-base/M000016.html.svn-base b/doc/classes/GameHandler.src/.svn/text-base/M000016.html.svn-base new file mode 100644 index 0000000..55ac0de --- /dev/null +++ b/doc/classes/GameHandler.src/.svn/text-base/M000016.html.svn-base @@ -0,0 +1,32 @@ + + + + + + play (GameHandler) + + + + +
# File src/play.rb, line 28
+  def play
+    begin
+      while @game.history.length < @limit
+        roll = rand(6) + 1
+        move_to_apply = @named_players[@game.current_player].best_move(@game, roll)
+        puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose
+        @game.apply_moves! [move_to_apply]
+        puts @game if @verbose
+      end
+      puts "Game terminated after #{@game.history.length} moves" if @verbose
+      [:draw, 0]
+    rescue GameWonNotice => win_notification
+      winner = win_notification.message[-1,1]
+      puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose
+      [@named_players[winner], @game.history.length]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/M000007.html b/doc/classes/GameHandler.src/M000007.html new file mode 100644 index 0000000..7d5ec99 --- /dev/null +++ b/doc/classes/GameHandler.src/M000007.html @@ -0,0 +1,27 @@ + + + + + + new (GameHandler) + + + + +
# File src/play.rb, line 17
+  def initialize(players, limit = 5000, verbose = false, very_verbose = false)
+    @game = Game.new(players.length)
+    @verbose = verbose
+    @very_verbose = very_verbose
+    @limit = limit
+    
+    # Give each player a name
+    @named_players = Hash.new 
+    (@game.players.zip players).each do |kv|
+      @named_players[kv[0]] = kv[1]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/M000008.html b/doc/classes/GameHandler.src/M000008.html new file mode 100644 index 0000000..5799d25 --- /dev/null +++ b/doc/classes/GameHandler.src/M000008.html @@ -0,0 +1,39 @@ + + + + + + play (GameHandler) + + + + +
# File src/play.rb, line 33
+  def play
+    while @game.history.length < @limit
+      roll = rand(6) + 1
+      move_to_apply = @named_players[@game.current_player].best_move(@game, roll)
+      puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose
+      @game.apply_moves! [move_to_apply]
+      puts @game if @very_verbose
+    end
+    puts "Game terminated after #{@game.history.length} moves" if @verbose
+    [:draw, @limit]
+  rescue GameWonNotice => win_notification
+    winner = win_notification.message[-1,1]
+    puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose
+    [@named_players[winner], @game.history.length]
+  rescue InvalidCaptureError, InvalidMoveError
+    puts "Disqualifying player #{@game.current_player}" if @verbose
+    @named_players.delete @game.current_player
+    if @named_players.length > 1
+      retry
+    else
+      puts "Game won by #{@named_players.keys[0]} by default" if @verbose
+      [@named_players[@named_players.keys[0]], 0]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/M000011.html b/doc/classes/GameHandler.src/M000011.html new file mode 100644 index 0000000..c42e4f7 --- /dev/null +++ b/doc/classes/GameHandler.src/M000011.html @@ -0,0 +1,27 @@ + + + + + + new (GameHandler) + + + + +
# File src/play.rb, line 20
+  def initialize(players, limit = 5000, verbose = false, very_verbose = false)
+    @game = Game.new(players.length)
+    @verbose = verbose
+    @very_verbose = very_verbose
+    @limit = limit
+    
+    # Give each player a name
+    @named_players = Hash.new 
+    (@game.players.zip players).each do |kv|
+      @named_players[kv[0]] = kv[1]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/M000012.html b/doc/classes/GameHandler.src/M000012.html new file mode 100644 index 0000000..17018ca --- /dev/null +++ b/doc/classes/GameHandler.src/M000012.html @@ -0,0 +1,39 @@ + + + + + + play (GameHandler) + + + + +
# File src/play.rb, line 36
+  def play
+    while @game.history.length < @limit
+      roll = rand(6) + 1
+      move_to_apply = @named_players[@game.current_player].best_move(@game, roll)
+      puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose
+      @game.apply_moves! [move_to_apply]
+      puts @game if @very_verbose
+    end
+    puts "Game terminated after #{@game.history.length} moves" if @verbose
+    [:draw, @limit]
+  rescue GameWonNotice => win_notification
+    winner = win_notification.message[-1,1]
+    puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose
+    [@named_players[winner], @game.history.length]
+  rescue InvalidCaptureError, InvalidMoveError
+    puts "Disqualifying player #{@game.current_player}" if @verbose
+    @named_players.delete @game.current_player
+    if @named_players.length > 1
+      retry
+    else
+      puts "Game won by #{@named_players.keys[0]} by default" if @verbose
+      [@named_players[@named_players.keys[0]], 0]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/M000015.html b/doc/classes/GameHandler.src/M000015.html new file mode 100644 index 0000000..c8e9e56 --- /dev/null +++ b/doc/classes/GameHandler.src/M000015.html @@ -0,0 +1,26 @@ + + + + + + new (GameHandler) + + + + +
# File src/play.rb, line 16
+  def initialize(players, verbose = false, limit = 5000)
+    @game = Game.new(players.length)
+    @verbose = verbose
+    @limit = limit
+    
+    # Give each player a name
+    @named_players = Hash.new 
+    (@game.players.zip players).each do |kv|
+      @named_players[kv[0]] = kv[1]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameHandler.src/M000016.html b/doc/classes/GameHandler.src/M000016.html new file mode 100644 index 0000000..55ac0de --- /dev/null +++ b/doc/classes/GameHandler.src/M000016.html @@ -0,0 +1,32 @@ + + + + + + play (GameHandler) + + + + +
# File src/play.rb, line 28
+  def play
+    begin
+      while @game.history.length < @limit
+        roll = rand(6) + 1
+        move_to_apply = @named_players[@game.current_player].best_move(@game, roll)
+        puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose
+        @game.apply_moves! [move_to_apply]
+        puts @game if @verbose
+      end
+      puts "Game terminated after #{@game.history.length} moves" if @verbose
+      [:draw, 0]
+    rescue GameWonNotice => win_notification
+      winner = win_notification.message[-1,1]
+      puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose
+      [@named_players[winner], @game.history.length]
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.html b/doc/classes/GameState.html new file mode 100644 index 0000000..dbfa0c2 --- /dev/null +++ b/doc/classes/GameState.html @@ -0,0 +1,185 @@ + + + + + + Class: GameState + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameState
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A class to record each of the states previously found in a game. Note that +this is a deep copy of the pieces and what they‘ve captured, so +you‘ll need to convert back +

+ +
+ + +
+ +
+

Methods

+ +
+ ==   + new   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + +
move [RW] 
pieces_after_move [RW] 
player [RW] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/GameState.src/.svn/all-wcprops b/doc/classes/GameState.src/.svn/all-wcprops new file mode 100644 index 0000000..efe11c7 --- /dev/null +++ b/doc/classes/GameState.src/.svn/all-wcprops @@ -0,0 +1,41 @@ +K 25 +svn:wc:ra_dav:version-url +V 64 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameState.src +END +M000001.html +K 25 +svn:wc:ra_dav:version-url +V 77 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/GameState.src/M000001.html +END +M000002.html +K 25 +svn:wc:ra_dav:version-url +V 77 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/GameState.src/M000002.html +END +M000003.html +K 25 +svn:wc:ra_dav:version-url +V 77 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameState.src/M000003.html +END +M000004.html +K 25 +svn:wc:ra_dav:version-url +V 77 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameState.src/M000004.html +END +M000008.html +K 25 +svn:wc:ra_dav:version-url +V 77 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameState.src/M000008.html +END +M000009.html +K 25 +svn:wc:ra_dav:version-url +V 77 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameState.src/M000009.html +END diff --git a/doc/classes/GameState.src/.svn/entries b/doc/classes/GameState.src/.svn/entries new file mode 100644 index 0000000..aed158f --- /dev/null +++ b/doc/classes/GameState.src/.svn/entries @@ -0,0 +1,98 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/GameState.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000001.html +file + + + + +2008-03-25T12:43:37.000000Z +88a7b482fdcf7df6e919405d4317dbdf +2008-03-28T15:47:09.723420Z +24 +neil + +M000002.html +file + + + + +2008-03-25T12:43:37.000000Z +541cddb93a958e71a9026925d1971c18 +2008-03-28T15:47:09.723420Z +24 +neil + +M000003.html +file + + + + +2008-03-25T11:47:59.000000Z +53d4e4c62b9ea912ba03d54198dbc536 +2008-03-25T12:46:59.166018Z +23 +neil + +M000004.html +file + + + + +2008-03-25T11:47:59.000000Z +7f4e5884a0a391f63029b7789affcd7b +2008-03-25T12:46:59.166018Z +23 +neil + +M000008.html +file + + + + +2008-03-28T15:44:41.000000Z +6b9064aa3d3719b9e478d45316128cb2 +2008-10-16T14:11:23.436422Z +41 + +M000009.html +file + + + + +2008-03-28T15:44:41.000000Z +daadaa01653644bfd2f85328266014c5 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/GameState.src/.svn/format b/doc/classes/GameState.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/GameState.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/GameState.src/.svn/text-base/M000001.html.svn-base b/doc/classes/GameState.src/.svn/text-base/M000001.html.svn-base new file mode 100644 index 0000000..c82f29e --- /dev/null +++ b/doc/classes/GameState.src/.svn/text-base/M000001.html.svn-base @@ -0,0 +1,20 @@ + + + + + + new (GameState) + + + + +
# File lib/libttc.rb, line 305
+  def initialize(move, player, pieces)
+    @move = move
+    @player = player
+    @pieces_after_move = pieces
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/.svn/text-base/M000002.html.svn-base b/doc/classes/GameState.src/.svn/text-base/M000002.html.svn-base new file mode 100644 index 0000000..7f6ef75 --- /dev/null +++ b/doc/classes/GameState.src/.svn/text-base/M000002.html.svn-base @@ -0,0 +1,20 @@ + + + + + + == (GameState) + + + + +
# File lib/libttc.rb, line 311
+  def ==(other)
+    @move.to_s == other.move.to_s and
+      @player == other.player and
+      @piece_after_move == other.pieces_after_move
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/.svn/text-base/M000003.html.svn-base b/doc/classes/GameState.src/.svn/text-base/M000003.html.svn-base new file mode 100644 index 0000000..cbc2dda --- /dev/null +++ b/doc/classes/GameState.src/.svn/text-base/M000003.html.svn-base @@ -0,0 +1,20 @@ + + + + + + new (GameState) + + + + +
# File lib/libttc.rb, line 294
+  def initialize(move, player, pieces)
+    @move = move
+    @player = player
+    @pieces_after_move = pieces
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/.svn/text-base/M000004.html.svn-base b/doc/classes/GameState.src/.svn/text-base/M000004.html.svn-base new file mode 100644 index 0000000..9df9f44 --- /dev/null +++ b/doc/classes/GameState.src/.svn/text-base/M000004.html.svn-base @@ -0,0 +1,20 @@ + + + + + + == (GameState) + + + + +
# File lib/libttc.rb, line 300
+  def ==(other)
+    @move.to_s == other.move.to_s and
+      @player == other.player and
+      @piece_after_move == other.pieces_after_move
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/.svn/text-base/M000008.html.svn-base b/doc/classes/GameState.src/.svn/text-base/M000008.html.svn-base new file mode 100644 index 0000000..0b52bab --- /dev/null +++ b/doc/classes/GameState.src/.svn/text-base/M000008.html.svn-base @@ -0,0 +1,28 @@ + + + + + + new (GameState) + + + + +
# File lib/libttc.rb, line 323
+  def initialize(move, player, pieces)
+    @move = move
+    @player = player
+    @pieces_after_move = Hash.new
+    pieces.each {|k, p| @pieces_after_move[k] = p.dup}
+    @pieces_after_move.each_value {|p| p.contains = []}
+    # and now to make the captured pieces point to the copies
+    pieces.each do |k, p|
+      p.contains.each do |captured_piece|
+        @pieces_after_move[k].capture(@pieces_after_move[captured_piece.name])
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/.svn/text-base/M000009.html.svn-base b/doc/classes/GameState.src/.svn/text-base/M000009.html.svn-base new file mode 100644 index 0000000..a497a37 --- /dev/null +++ b/doc/classes/GameState.src/.svn/text-base/M000009.html.svn-base @@ -0,0 +1,20 @@ + + + + + + == (GameState) + + + + +
# File lib/libttc.rb, line 337
+  def ==(other)
+    @move.to_s == other.move.to_s and
+      @player == other.player and
+      @piece_after_move == other.pieces_after_move
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/M000001.html b/doc/classes/GameState.src/M000001.html new file mode 100644 index 0000000..c82f29e --- /dev/null +++ b/doc/classes/GameState.src/M000001.html @@ -0,0 +1,20 @@ + + + + + + new (GameState) + + + + +
# File lib/libttc.rb, line 305
+  def initialize(move, player, pieces)
+    @move = move
+    @player = player
+    @pieces_after_move = pieces
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/M000002.html b/doc/classes/GameState.src/M000002.html new file mode 100644 index 0000000..7f6ef75 --- /dev/null +++ b/doc/classes/GameState.src/M000002.html @@ -0,0 +1,20 @@ + + + + + + == (GameState) + + + + +
# File lib/libttc.rb, line 311
+  def ==(other)
+    @move.to_s == other.move.to_s and
+      @player == other.player and
+      @piece_after_move == other.pieces_after_move
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/M000003.html b/doc/classes/GameState.src/M000003.html new file mode 100644 index 0000000..cbc2dda --- /dev/null +++ b/doc/classes/GameState.src/M000003.html @@ -0,0 +1,20 @@ + + + + + + new (GameState) + + + + +
# File lib/libttc.rb, line 294
+  def initialize(move, player, pieces)
+    @move = move
+    @player = player
+    @pieces_after_move = pieces
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/M000004.html b/doc/classes/GameState.src/M000004.html new file mode 100644 index 0000000..9df9f44 --- /dev/null +++ b/doc/classes/GameState.src/M000004.html @@ -0,0 +1,20 @@ + + + + + + == (GameState) + + + + +
# File lib/libttc.rb, line 300
+  def ==(other)
+    @move.to_s == other.move.to_s and
+      @player == other.player and
+      @piece_after_move == other.pieces_after_move
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/M000008.html b/doc/classes/GameState.src/M000008.html new file mode 100644 index 0000000..0b52bab --- /dev/null +++ b/doc/classes/GameState.src/M000008.html @@ -0,0 +1,28 @@ + + + + + + new (GameState) + + + + +
# File lib/libttc.rb, line 323
+  def initialize(move, player, pieces)
+    @move = move
+    @player = player
+    @pieces_after_move = Hash.new
+    pieces.each {|k, p| @pieces_after_move[k] = p.dup}
+    @pieces_after_move.each_value {|p| p.contains = []}
+    # and now to make the captured pieces point to the copies
+    pieces.each do |k, p|
+      p.contains.each do |captured_piece|
+        @pieces_after_move[k].capture(@pieces_after_move[captured_piece.name])
+      end
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameState.src/M000009.html b/doc/classes/GameState.src/M000009.html new file mode 100644 index 0000000..a497a37 --- /dev/null +++ b/doc/classes/GameState.src/M000009.html @@ -0,0 +1,20 @@ + + + + + + == (GameState) + + + + +
# File lib/libttc.rb, line 337
+  def ==(other)
+    @move.to_s == other.move.to_s and
+      @player == other.player and
+      @piece_after_move == other.pieces_after_move
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.html b/doc/classes/GameTest.html new file mode 100644 index 0000000..e6067b2 --- /dev/null +++ b/doc/classes/GameTest.html @@ -0,0 +1,287 @@ + + + + + + Class: GameTest + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameTest
In: + + test/libttc_test.rb + +
+
Parent: + Test::Unit::TestCase +
+
+ + +
+ + + +
+ + + +
+ + + +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + + + + +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/all-wcprops b/doc/classes/GameTest.src/.svn/all-wcprops new file mode 100644 index 0000000..76fc176 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/all-wcprops @@ -0,0 +1,119 @@ +K 25 +svn:wc:ra_dav:version-url +V 63 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src +END +M000010.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameTest.src/M000010.html +END +M000011.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameTest.src/M000011.html +END +M000020.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000020.html +END +M000012.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameTest.src/M000012.html +END +M000021.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000021.html +END +M000013.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameTest.src/M000013.html +END +M000022.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000022.html +END +M000014.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameTest.src/M000014.html +END +M000023.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000023.html +END +M000024.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000024.html +END +M000015.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameTest.src/M000015.html +END +M000025.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000025.html +END +M000016.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameTest.src/M000016.html +END +M000026.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000026.html +END +M000017.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000017.html +END +M000018.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000018.html +END +M000009.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/GameTest.src/M000009.html +END +M000027.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000027.html +END +M000019.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/GameTest.src/M000019.html +END diff --git a/doc/classes/GameTest.src/.svn/entries b/doc/classes/GameTest.src/.svn/entries new file mode 100644 index 0000000..7cf6d19 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/entries @@ -0,0 +1,245 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/GameTest.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000010.html +file + + + + +2008-03-25T11:47:59.000000Z +41664b5a552ce096824dfe328f1a0419 +2008-03-25T12:46:59.166018Z +23 +neil + +M000011.html +file + + + + +2008-03-25T11:47:59.000000Z +88dd11dcddcb949ddb41c70328b9971a +2008-03-25T12:46:59.166018Z +23 +neil + +M000020.html +file + + + + +2008-03-28T15:44:41.000000Z +c06b9b14b8954730d685f5faebc7fd8b +2008-10-16T14:11:23.436422Z +41 + +M000021.html +file + + + + +2008-03-28T15:44:41.000000Z +0b48c55cce4696afd66cf634568d2fa2 +2008-10-16T14:11:23.436422Z +41 + +M000012.html +file + + + + +2008-03-25T11:47:59.000000Z +ce453b284de894e64aaaa0e53da14fd7 +2008-03-25T12:46:59.166018Z +23 +neil + +M000013.html +file + + + + +2008-03-25T11:47:59.000000Z +710b8c2b3047574ca452860836b5d5b9 +2008-03-25T12:46:59.166018Z +23 +neil + +M000022.html +file + + + + +2008-03-28T15:44:41.000000Z +5bad73a8a1bae6afcaa0cb8ab8a6fc09 +2008-10-16T14:11:23.436422Z +41 + +M000023.html +file + + + + +2008-03-28T15:44:41.000000Z +49f96f995fcbb23ff379a7aef6e69539 +2008-10-16T14:11:23.436422Z +41 + +M000014.html +file + + + + +2008-03-25T11:47:59.000000Z +09a0da90f8788992851691777e532180 +2008-03-25T12:46:59.166018Z +23 +neil + +M000024.html +file + + + + +2008-03-28T15:44:41.000000Z +5c5be77a77266e23c62e451e553c4091 +2008-10-16T14:11:23.436422Z +41 + +M000015.html +file + + + + +2008-03-25T11:47:59.000000Z +b5127960370e70d7f9cc49e81c098661 +2008-03-25T12:46:59.166018Z +23 +neil + +M000025.html +file + + + + +2008-03-28T15:44:41.000000Z +3d4be49bd838bb8577a2453f5eff6d35 +2008-10-16T14:11:23.436422Z +41 + +M000016.html +file + + + + +2008-03-25T11:48:00.000000Z +50e9359d54aa4411e49ef92055262b1f +2008-03-25T12:46:59.166018Z +23 +neil + +M000017.html +file + + + + +2008-03-28T15:44:41.000000Z +690dbf91a64e38a3b5105b3caf95f786 +2008-10-16T14:11:23.436422Z +41 + +M000026.html +file + + + + +2008-03-28T15:44:41.000000Z +e7761375535f8d2a9330cbacba466743 +2008-10-16T14:11:23.436422Z +41 + +M000018.html +file + + + + +2008-03-28T15:44:41.000000Z +d4745433ba95bd2bee6586382aeb2665 +2008-10-16T14:11:23.436422Z +41 + +M000009.html +file + + + + +2008-03-25T11:47:59.000000Z +55f494fd0b53e9c99c09d26367ecb810 +2008-03-25T12:46:59.166018Z +23 +neil + +M000027.html +file + + + + +2008-03-28T15:44:41.000000Z +77b0ba6cb4134fe7ccc3440ab63be6df +2008-10-16T14:11:23.436422Z +41 + +M000019.html +file + + + + +2008-03-28T15:44:41.000000Z +32cc66129284aee20987aeca730fa83b +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/GameTest.src/.svn/format b/doc/classes/GameTest.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/GameTest.src/.svn/text-base/M000009.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000009.html.svn-base new file mode 100644 index 0000000..8268e17 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000009.html.svn-base @@ -0,0 +1,19 @@ + + + + + + test_init (GameTest) + + + + +
# File test/game-test.rb, line 7
+  def test_init
+    assert_nothing_raised { Game.new(6,6,6,6,6) }
+    assert_equal [], Game.new(6,6,6,6,6).history
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000010.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000010.html.svn-base new file mode 100644 index 0000000..357df0c --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000010.html.svn-base @@ -0,0 +1,47 @@ + + + + + + test_game_init (GameTest) + + + + +
# File test/game-test.rb, line 13
+  def test_game_init
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000011.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000011.html.svn-base new file mode 100644 index 0000000..6b7477f --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000011.html.svn-base @@ -0,0 +1,72 @@ + + + + + + test_single_moves_1 (GameTest) + + + + +
# File test/game-test.rb, line 47
+  def test_single_moves_1
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    assert_raise(InvalidMoveError) {game.apply_move(moveA1A5, 'b')}
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000012.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000012.html.svn-base new file mode 100644 index 0000000..4d6891d --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000012.html.svn-base @@ -0,0 +1,71 @@ + + + + + + test_separate_moves (GameTest) + + + + +
# File test/game-test.rb, line 105
+  def test_separate_moves
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A3, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000013.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000013.html.svn-base new file mode 100644 index 0000000..bf3baf7 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000013.html.svn-base @@ -0,0 +1,72 @@ + + + + + + test_captures (GameTest) + + + + +
# File test/game-test.rb, line 164
+  def test_captures
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A5, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000014.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000014.html.svn-base new file mode 100644 index 0000000..0811e83 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000014.html.svn-base @@ -0,0 +1,71 @@ + + + + + + test_no_captures_on_safe_spaces (GameTest) + + + + +
# File test/game-test.rb, line 223
+  def test_no_captures_on_safe_spaces
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA2A4, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A4, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000015.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000015.html.svn-base new file mode 100644 index 0000000..530159a --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000015.html.svn-base @@ -0,0 +1,98 @@ + + + + + + test_move_after_captures (GameTest) + + + + +
# File test/game-test.rb, line 280
+  def test_move_after_captures
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A5, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveA2A4, 'a')
+    assert_equal game.history.length, 3
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveB2A3, 'b')
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000016.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000016.html.svn-base new file mode 100644 index 0000000..3b435ad --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000016.html.svn-base @@ -0,0 +1,188 @@ + + + + + + test_game (GameTest) + + + + +
# File test/game-test.rb, line 365
+  def test_game
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A3 = Move.new(pieceA1, posA3)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A3, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA2A4, 'a')
+    assert_equal game.history.length, 3
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A5, 'b')
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    assert_raise(InvalidMoveError) {game.apply_move(moveA1A3, 'a')}
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveA2A3, 'a')
+    assert_equal game.history.length, 5
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveB2A4, 'b')
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['a4']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveA2A4, 'a')
+    assert_equal game.history.length, 7
+    assert_equal game.pieces['a1'].position, game.board.positions['a4']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveB2A3, 'b')
+    assert_equal game.history.length, 8
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveA2A3, 'a')
+    assert_equal game.history.length, 9
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert       game.pieces['a2'].contains.include?(pieceA1)
+    assert       game.pieces['a2'].contains.include?(pieceB2)
+    assert_equal game.pieces['a2'].contains.length, 2
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, true
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA2A, 'a')
+    assert_equal game.history.length, 10
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a']
+    assert_equal game.pieces['b2'].captured, true
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000017.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000017.html.svn-base new file mode 100644 index 0000000..6c63804 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000017.html.svn-base @@ -0,0 +1,19 @@ + + + + + + test_init (GameTest) + + + + +
# File test/libttc_test.rb, line 7
+  def test_init
+    assert_nothing_raised { Game.new(6,6,6,6,6) }
+    assert_equal [], Game.new(6,6,6,6,6).history
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000018.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000018.html.svn-base new file mode 100644 index 0000000..bb2ab15 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000018.html.svn-base @@ -0,0 +1,47 @@ + + + + + + test_game_init (GameTest) + + + + +
# File test/libttc_test.rb, line 13
+  def test_game_init
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000019.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000019.html.svn-base new file mode 100644 index 0000000..8716f22 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000019.html.svn-base @@ -0,0 +1,72 @@ + + + + + + test_single_moves_1 (GameTest) + + + + +
# File test/libttc_test.rb, line 47
+  def test_single_moves_1
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    assert_raise(InvalidMoveError) {game.apply_move!(moveA1A5, 'b')}
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000020.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000020.html.svn-base new file mode 100644 index 0000000..25cf3c0 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000020.html.svn-base @@ -0,0 +1,71 @@ + + + + + + test_separate_moves (GameTest) + + + + +
# File test/libttc_test.rb, line 105
+  def test_separate_moves
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A3, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000021.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000021.html.svn-base new file mode 100644 index 0000000..0444f26 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000021.html.svn-base @@ -0,0 +1,72 @@ + + + + + + test_captures (GameTest) + + + + +
# File test/libttc_test.rb, line 164
+  def test_captures
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A5, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000022.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000022.html.svn-base new file mode 100644 index 0000000..1ed16e5 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000022.html.svn-base @@ -0,0 +1,71 @@ + + + + + + test_no_captures_on_safe_spaces (GameTest) + + + + +
# File test/libttc_test.rb, line 223
+  def test_no_captures_on_safe_spaces
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA2A4, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A4, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000023.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000023.html.svn-base new file mode 100644 index 0000000..539feea --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000023.html.svn-base @@ -0,0 +1,98 @@ + + + + + + test_move_after_captures (GameTest) + + + + +
# File test/libttc_test.rb, line 280
+  def test_move_after_captures
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A5, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveA2A4, 'a')
+    assert_equal game.history.length, 3
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveB2A3, 'b')
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000024.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000024.html.svn-base new file mode 100644 index 0000000..9c2f635 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000024.html.svn-base @@ -0,0 +1,188 @@ + + + + + + test_game (GameTest) + + + + +
# File test/libttc_test.rb, line 365
+  def test_game
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A3 = Move.new(pieceA1, posA3)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A3, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA2A4, 'a')
+    assert_equal game.history.length, 3
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A5, 'b')
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    assert_raise(InvalidMoveError) {game.apply_move!(moveA1A3, 'a')}
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveA2A3, 'a')
+    assert_equal game.history.length, 5
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveB2A4, 'b')
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['a4']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveA2A4, 'a')
+    assert_equal game.history.length, 7
+    assert_equal game.pieces['a1'].position, game.board.positions['a4']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveB2A3, 'b')
+    assert_equal game.history.length, 8
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveA2A3, 'a')
+    assert_equal game.history.length, 9
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert       game.pieces['a2'].contains.include?(pieceA1)
+    assert       game.pieces['a2'].contains.include?(pieceB2)
+    assert_equal game.pieces['a2'].contains.length, 2
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, true
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA2A, 'a')
+    assert_equal game.history.length, 10
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a']
+    assert_equal game.pieces['b2'].captured, true
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000025.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000025.html.svn-base new file mode 100644 index 0000000..bbbaeca --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000025.html.svn-base @@ -0,0 +1,22 @@ + + + + + + test_apply_moves! (GameTest) + + + + +
# File test/libttc_test.rb, line 539
+  def test_apply_moves!
+    game = Game.new(3)
+    move_set = ['A1 A2', 'C1 C2', 'E1 E2']
+    assert_nothing_raised { move_set.collect { |m| m.to_move(game) } }
+    move_set_m = move_set.collect { |m| m.to_move(game) }
+    assert_nothing_raised { game.apply_moves! move_set_m }
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000026.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000026.html.svn-base new file mode 100644 index 0000000..8869203 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000026.html.svn-base @@ -0,0 +1,177 @@ + + + + + + test_eliminations (GameTest) + + + + +
# File test/libttc_test.rb, line 547
+  def test_eliminations
+    game = Game.new(3, 6, 6, 6, 2)
+  
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceC1 = game.pieces['c1']
+    pieceC2 = game.pieces['c2']
+    pieceE1 = game.pieces['e1']
+    pieceE2 = game.pieces['e2']
+
+    posAC5 = game.board.positions['ac5']
+    posBC5 = game.board.positions['bc5']
+    posCC5 = game.board.positions['cc5']
+    posEC5 = game.board.positions['ec5']
+    posAC6 = game.board.positions['ac6']
+
+    move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', 
+      'C1 CC5', 'C2 CC5', 'C1 AC6']  # A1 now captured by C1
+    move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1
+    move_set3 = ['A2 AC6'] # E1+C1+A1 captured by A2
+    move_set4 = ['C2 AC6'] # A2+E1+C1+A1 captured by C2.  Player A now eliminated
+    move_set5 = ['E2 BC5'] 
+    move_set6 = ['C2 BC5'] # C2 (plus stack) captures E2.  Player E now eliminated
+    
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    game.apply_moves! move_set1.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, false
+    assert       game.pieces['c1'].contains.include?(pieceA1) 
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+
+    game.apply_moves! move_set2.collect {|m| m.to_move(game)}
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, false
+    assert       game.pieces['e1'].contains.include?(pieceA1) 
+    assert       game.pieces['e1'].contains.include?(pieceC1) 
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    game.apply_moves! move_set3.collect {|m| m.to_move(game)}
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a2'].captured, false
+    assert       game.pieces['a2'].contains.include?(pieceA1) 
+    assert       game.pieces['a2'].contains.include?(pieceC1) 
+    assert       game.pieces['a2'].contains.include?(pieceE1) 
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, true
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'c'
+
+    game.apply_moves! move_set4.collect {|m| m.to_move(game)}
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a2'].captured, true
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c2'].captured, false
+    assert       game.pieces['c2'].contains.include?(pieceA1) 
+    assert       game.pieces['c2'].contains.include?(pieceA2) 
+    assert       game.pieces['c2'].contains.include?(pieceC1) 
+    assert       game.pieces['c2'].contains.include?(pieceE1) 
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, true
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+
+    game.apply_moves! move_set5.collect {|m| m.to_move(game)}
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a2'].captured, true
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c2'].captured, false
+    assert       game.pieces['c2'].contains.include?(pieceA1) 
+    assert       game.pieces['c2'].contains.include?(pieceA2) 
+    assert       game.pieces['c2'].contains.include?(pieceC1) 
+    assert       game.pieces['c2'].contains.include?(pieceE1) 
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, true
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['bc5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'c'
+    
+    assert_raise (GameWonNotice) { game.apply_moves! move_set6.collect {|m| m.to_move(game)} }  
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/.svn/text-base/M000027.html.svn-base b/doc/classes/GameTest.src/.svn/text-base/M000027.html.svn-base new file mode 100644 index 0000000..3319425 --- /dev/null +++ b/doc/classes/GameTest.src/.svn/text-base/M000027.html.svn-base @@ -0,0 +1,281 @@ + + + + + + test_undo_move! (GameTest) + + + + +
# File test/libttc_test.rb, line 710
+  def test_undo_move!
+    game = Game.new(3)
+  
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceC1 = game.pieces['c1']
+    pieceC2 = game.pieces['c2']
+    pieceE1 = game.pieces['e1']
+    pieceE2 = game.pieces['e2']
+    
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'], pieceA1
+    assert_equal game.pieces['a2'], pieceA2
+    assert_equal game.pieces['c1'], pieceC1
+    assert_equal game.pieces['c2'], pieceC2
+    assert_equal game.pieces['e1'], pieceE1
+    assert_equal game.pieces['e2'], pieceE2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+    
+    game.undo_move!
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'], pieceA1
+    assert_equal game.pieces['a2'], pieceA2
+    assert_equal game.pieces['c1'], pieceC1
+    assert_equal game.pieces['c2'], pieceC2
+    assert_equal game.pieces['e1'], pieceE1
+    assert_equal game.pieces['e2'], pieceE2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    game.apply_moves! ['A1 A3'].collect { |m| m.to_move(game) }
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'], pieceA1
+    assert_equal game.pieces['a2'], pieceA2
+    assert_equal game.pieces['c1'], pieceC1
+    assert_equal game.pieces['c2'], pieceC2
+    assert_equal game.pieces['e1'], pieceE1
+    assert_equal game.pieces['e2'], pieceE2
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'c'
+
+    game.undo_move!
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'], pieceA1
+    assert_equal game.pieces['a2'], pieceA2
+    assert_equal game.pieces['c1'], pieceC1
+    assert_equal game.pieces['c2'], pieceC2
+    assert_equal game.pieces['e1'], pieceE1
+    assert_equal game.pieces['e2'], pieceE2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', 
+      'C1 CC5', 'C2 CC5', 'C1 AC6']  # A1 now captured by C1
+    move_set1a = ['C1 AC6']
+    move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1
+    move_set2a = ['E1 AC6']
+
+    game.apply_moves! move_set1.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, false
+    assert       game.pieces['c1'].contains.include?(pieceA1) 
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+
+    game.undo_move!
+    assert_equal game.history.length, 5
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'c'
+
+    game.apply_moves! move_set1a.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, false
+    assert       game.pieces['c1'].contains.include?(pieceA1) 
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+        
+    game.apply_moves! move_set2.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 9
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, false
+    assert       game.pieces['e1'].contains.include?(pieceA1) 
+    assert       game.pieces['e1'].contains.include?(pieceC1) 
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    game.undo_move!
+    assert_equal game.history.length, 8
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].captured, false
+    assert       game.pieces['c1'].contains.include?(pieceA1) 
+
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+
+        assert_equal game.pieces['c1'].position, game.pieces['a1'].position
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+
+    
+    game.apply_moves! move_set2a.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 9
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, false
+    assert       game.pieces['e1'].contains.include?(pieceA1) 
+    assert       game.pieces['e1'].contains.include?(pieceC1) 
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+        
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000009.html b/doc/classes/GameTest.src/M000009.html new file mode 100644 index 0000000..8268e17 --- /dev/null +++ b/doc/classes/GameTest.src/M000009.html @@ -0,0 +1,19 @@ + + + + + + test_init (GameTest) + + + + +
# File test/game-test.rb, line 7
+  def test_init
+    assert_nothing_raised { Game.new(6,6,6,6,6) }
+    assert_equal [], Game.new(6,6,6,6,6).history
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000010.html b/doc/classes/GameTest.src/M000010.html new file mode 100644 index 0000000..357df0c --- /dev/null +++ b/doc/classes/GameTest.src/M000010.html @@ -0,0 +1,47 @@ + + + + + + test_game_init (GameTest) + + + + +
# File test/game-test.rb, line 13
+  def test_game_init
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000011.html b/doc/classes/GameTest.src/M000011.html new file mode 100644 index 0000000..6b7477f --- /dev/null +++ b/doc/classes/GameTest.src/M000011.html @@ -0,0 +1,72 @@ + + + + + + test_single_moves_1 (GameTest) + + + + +
# File test/game-test.rb, line 47
+  def test_single_moves_1
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    assert_raise(InvalidMoveError) {game.apply_move(moveA1A5, 'b')}
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000012.html b/doc/classes/GameTest.src/M000012.html new file mode 100644 index 0000000..4d6891d --- /dev/null +++ b/doc/classes/GameTest.src/M000012.html @@ -0,0 +1,71 @@ + + + + + + test_separate_moves (GameTest) + + + + +
# File test/game-test.rb, line 105
+  def test_separate_moves
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A3, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000013.html b/doc/classes/GameTest.src/M000013.html new file mode 100644 index 0000000..bf3baf7 --- /dev/null +++ b/doc/classes/GameTest.src/M000013.html @@ -0,0 +1,72 @@ + + + + + + test_captures (GameTest) + + + + +
# File test/game-test.rb, line 164
+  def test_captures
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A5, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000014.html b/doc/classes/GameTest.src/M000014.html new file mode 100644 index 0000000..0811e83 --- /dev/null +++ b/doc/classes/GameTest.src/M000014.html @@ -0,0 +1,71 @@ + + + + + + test_no_captures_on_safe_spaces (GameTest) + + + + +
# File test/game-test.rb, line 223
+  def test_no_captures_on_safe_spaces
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA2A4, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A4, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000015.html b/doc/classes/GameTest.src/M000015.html new file mode 100644 index 0000000..530159a --- /dev/null +++ b/doc/classes/GameTest.src/M000015.html @@ -0,0 +1,98 @@ + + + + + + test_move_after_captures (GameTest) + + + + +
# File test/game-test.rb, line 280
+  def test_move_after_captures
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A5, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveA2A4, 'a')
+    assert_equal game.history.length, 3
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveB2A3, 'b')
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000016.html b/doc/classes/GameTest.src/M000016.html new file mode 100644 index 0000000..3b435ad --- /dev/null +++ b/doc/classes/GameTest.src/M000016.html @@ -0,0 +1,188 @@ + + + + + + test_game (GameTest) + + + + +
# File test/game-test.rb, line 365
+  def test_game
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A3 = Move.new(pieceA1, posA3)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A3, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA2A4, 'a')
+    assert_equal game.history.length, 3
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveB2A5, 'b')
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    assert_raise(InvalidMoveError) {game.apply_move(moveA1A3, 'a')}
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveA2A3, 'a')
+    assert_equal game.history.length, 5
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveB2A4, 'b')
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['a4']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveA2A4, 'a')
+    assert_equal game.history.length, 7
+    assert_equal game.pieces['a1'].position, game.board.positions['a4']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveB2A3, 'b')
+    assert_equal game.history.length, 8
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move(moveA2A3, 'a')
+    assert_equal game.history.length, 9
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert       game.pieces['a2'].contains.include?(pieceA1)
+    assert       game.pieces['a2'].contains.include?(pieceB2)
+    assert_equal game.pieces['a2'].contains.length, 2
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, true
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move(moveA2A, 'a')
+    assert_equal game.history.length, 10
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a']
+    assert_equal game.pieces['b2'].captured, true
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000017.html b/doc/classes/GameTest.src/M000017.html new file mode 100644 index 0000000..6c63804 --- /dev/null +++ b/doc/classes/GameTest.src/M000017.html @@ -0,0 +1,19 @@ + + + + + + test_init (GameTest) + + + + +
# File test/libttc_test.rb, line 7
+  def test_init
+    assert_nothing_raised { Game.new(6,6,6,6,6) }
+    assert_equal [], Game.new(6,6,6,6,6).history
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000018.html b/doc/classes/GameTest.src/M000018.html new file mode 100644 index 0000000..bb2ab15 --- /dev/null +++ b/doc/classes/GameTest.src/M000018.html @@ -0,0 +1,47 @@ + + + + + + test_game_init (GameTest) + + + + +
# File test/libttc_test.rb, line 13
+  def test_game_init
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000019.html b/doc/classes/GameTest.src/M000019.html new file mode 100644 index 0000000..8716f22 --- /dev/null +++ b/doc/classes/GameTest.src/M000019.html @@ -0,0 +1,72 @@ + + + + + + test_single_moves_1 (GameTest) + + + + +
# File test/libttc_test.rb, line 47
+  def test_single_moves_1
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    assert_raise(InvalidMoveError) {game.apply_move!(moveA1A5, 'b')}
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000020.html b/doc/classes/GameTest.src/M000020.html new file mode 100644 index 0000000..25cf3c0 --- /dev/null +++ b/doc/classes/GameTest.src/M000020.html @@ -0,0 +1,71 @@ + + + + + + test_separate_moves (GameTest) + + + + +
# File test/libttc_test.rb, line 105
+  def test_separate_moves
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A3, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000021.html b/doc/classes/GameTest.src/M000021.html new file mode 100644 index 0000000..0444f26 --- /dev/null +++ b/doc/classes/GameTest.src/M000021.html @@ -0,0 +1,72 @@ + + + + + + test_captures (GameTest) + + + + +
# File test/libttc_test.rb, line 164
+  def test_captures
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A5, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000022.html b/doc/classes/GameTest.src/M000022.html new file mode 100644 index 0000000..1ed16e5 --- /dev/null +++ b/doc/classes/GameTest.src/M000022.html @@ -0,0 +1,71 @@ + + + + + + test_no_captures_on_safe_spaces (GameTest) + + + + +
# File test/libttc_test.rb, line 223
+  def test_no_captures_on_safe_spaces
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA2A4, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A4, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000023.html b/doc/classes/GameTest.src/M000023.html new file mode 100644 index 0000000..539feea --- /dev/null +++ b/doc/classes/GameTest.src/M000023.html @@ -0,0 +1,98 @@ + + + + + + test_move_after_captures (GameTest) + + + + +
# File test/libttc_test.rb, line 280
+  def test_move_after_captures
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A5, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveA2A4, 'a')
+    assert_equal game.history.length, 3
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveB2A3, 'b')
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000024.html b/doc/classes/GameTest.src/M000024.html new file mode 100644 index 0000000..9c2f635 --- /dev/null +++ b/doc/classes/GameTest.src/M000024.html @@ -0,0 +1,188 @@ + + + + + + test_game (GameTest) + + + + +
# File test/libttc_test.rb, line 365
+  def test_game
+    game = Game.new(6,6,6,6,6)
+
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceB2 = game.pieces['b2']
+
+    posA  = game.board.positions['a']
+    posB  = game.board.positions['b']
+    posA3 = game.board.positions['a3']
+    posA4 = game.board.positions['a4']
+    posA5 = game.board.positions['a5']
+
+    moveA2A  = Move.new(pieceA2, posA , true)
+    moveA1A3 = Move.new(pieceA1, posA3)
+    moveA1A5 = Move.new(pieceA1, posA5)
+    moveA2A4 = Move.new(pieceA2, posA4)
+    moveA2A3 = Move.new(pieceA2, posA3)
+    moveB2A5 = Move.new(pieceB2, posA5)
+    moveB2A3 = Move.new(pieceB2, posA3)
+    moveB2A4 = Move.new(pieceB2, posA4)
+
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA1A5, 'a')
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['b']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A3, 'b')
+    assert_equal game.history.length, 2
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA2A4, 'a')
+    assert_equal game.history.length, 3
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveB2A5, 'b')
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    assert_raise(InvalidMoveError) {game.apply_move!(moveA1A3, 'a')}
+    assert_equal game.history.length, 4
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveA2A3, 'a')
+    assert_equal game.history.length, 5
+    assert_equal game.pieces['a1'].position, game.board.positions['a5']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a5']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveB2A4, 'b')
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['a4']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveA2A4, 'a')
+    assert_equal game.history.length, 7
+    assert_equal game.pieces['a1'].position, game.board.positions['a4']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a4']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveB2A3, 'b')
+    assert_equal game.history.length, 8
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a4']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, false
+    assert       game.pieces['b2'].contains.include?(pieceA1)
+    assert_equal game.pieces['b2'].contains.length, 1
+
+    game.apply_move!(moveA2A3, 'a')
+    assert_equal game.history.length, 9
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a3']
+    assert_equal game.pieces['a2'].captured, false
+    assert       game.pieces['a2'].contains.include?(pieceA1)
+    assert       game.pieces['a2'].contains.include?(pieceB2)
+    assert_equal game.pieces['a2'].contains.length, 2
+    assert_equal game.pieces['b2'].position, game.board.positions['a3']
+    assert_equal game.pieces['b2'].captured, true
+    assert_equal game.pieces['b2'].contains, []
+
+    game.apply_move!(moveA2A, 'a')
+    assert_equal game.history.length, 10
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['b2'].position, game.board.positions['a']
+    assert_equal game.pieces['b2'].captured, true
+    assert_equal game.pieces['b2'].contains, []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000025.html b/doc/classes/GameTest.src/M000025.html new file mode 100644 index 0000000..bbbaeca --- /dev/null +++ b/doc/classes/GameTest.src/M000025.html @@ -0,0 +1,22 @@ + + + + + + test_apply_moves! (GameTest) + + + + +
# File test/libttc_test.rb, line 539
+  def test_apply_moves!
+    game = Game.new(3)
+    move_set = ['A1 A2', 'C1 C2', 'E1 E2']
+    assert_nothing_raised { move_set.collect { |m| m.to_move(game) } }
+    move_set_m = move_set.collect { |m| m.to_move(game) }
+    assert_nothing_raised { game.apply_moves! move_set_m }
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000026.html b/doc/classes/GameTest.src/M000026.html new file mode 100644 index 0000000..8869203 --- /dev/null +++ b/doc/classes/GameTest.src/M000026.html @@ -0,0 +1,177 @@ + + + + + + test_eliminations (GameTest) + + + + +
# File test/libttc_test.rb, line 547
+  def test_eliminations
+    game = Game.new(3, 6, 6, 6, 2)
+  
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceC1 = game.pieces['c1']
+    pieceC2 = game.pieces['c2']
+    pieceE1 = game.pieces['e1']
+    pieceE2 = game.pieces['e2']
+
+    posAC5 = game.board.positions['ac5']
+    posBC5 = game.board.positions['bc5']
+    posCC5 = game.board.positions['cc5']
+    posEC5 = game.board.positions['ec5']
+    posAC6 = game.board.positions['ac6']
+
+    move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', 
+      'C1 CC5', 'C2 CC5', 'C1 AC6']  # A1 now captured by C1
+    move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1
+    move_set3 = ['A2 AC6'] # E1+C1+A1 captured by A2
+    move_set4 = ['C2 AC6'] # A2+E1+C1+A1 captured by C2.  Player A now eliminated
+    move_set5 = ['E2 BC5'] 
+    move_set6 = ['C2 BC5'] # C2 (plus stack) captures E2.  Player E now eliminated
+    
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    game.apply_moves! move_set1.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, false
+    assert       game.pieces['c1'].contains.include?(pieceA1) 
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+
+    game.apply_moves! move_set2.collect {|m| m.to_move(game)}
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, false
+    assert       game.pieces['e1'].contains.include?(pieceA1) 
+    assert       game.pieces['e1'].contains.include?(pieceC1) 
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    game.apply_moves! move_set3.collect {|m| m.to_move(game)}
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a2'].captured, false
+    assert       game.pieces['a2'].contains.include?(pieceA1) 
+    assert       game.pieces['a2'].contains.include?(pieceC1) 
+    assert       game.pieces['a2'].contains.include?(pieceE1) 
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, true
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'c'
+
+    game.apply_moves! move_set4.collect {|m| m.to_move(game)}
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a2'].captured, true
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c2'].captured, false
+    assert       game.pieces['c2'].contains.include?(pieceA1) 
+    assert       game.pieces['c2'].contains.include?(pieceA2) 
+    assert       game.pieces['c2'].contains.include?(pieceC1) 
+    assert       game.pieces['c2'].contains.include?(pieceE1) 
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, true
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+
+    game.apply_moves! move_set5.collect {|m| m.to_move(game)}
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a2'].captured, true
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c2'].captured, false
+    assert       game.pieces['c2'].contains.include?(pieceA1) 
+    assert       game.pieces['c2'].contains.include?(pieceA2) 
+    assert       game.pieces['c2'].contains.include?(pieceC1) 
+    assert       game.pieces['c2'].contains.include?(pieceE1) 
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, true
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['bc5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'c'
+    
+    assert_raise (GameWonNotice) { game.apply_moves! move_set6.collect {|m| m.to_move(game)} }  
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameTest.src/M000027.html b/doc/classes/GameTest.src/M000027.html new file mode 100644 index 0000000..3319425 --- /dev/null +++ b/doc/classes/GameTest.src/M000027.html @@ -0,0 +1,281 @@ + + + + + + test_undo_move! (GameTest) + + + + +
# File test/libttc_test.rb, line 710
+  def test_undo_move!
+    game = Game.new(3)
+  
+    pieceA1 = game.pieces['a1']
+    pieceA2 = game.pieces['a2']
+    pieceC1 = game.pieces['c1']
+    pieceC2 = game.pieces['c2']
+    pieceE1 = game.pieces['e1']
+    pieceE2 = game.pieces['e2']
+    
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'], pieceA1
+    assert_equal game.pieces['a2'], pieceA2
+    assert_equal game.pieces['c1'], pieceC1
+    assert_equal game.pieces['c2'], pieceC2
+    assert_equal game.pieces['e1'], pieceE1
+    assert_equal game.pieces['e2'], pieceE2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+    
+    game.undo_move!
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'], pieceA1
+    assert_equal game.pieces['a2'], pieceA2
+    assert_equal game.pieces['c1'], pieceC1
+    assert_equal game.pieces['c2'], pieceC2
+    assert_equal game.pieces['e1'], pieceE1
+    assert_equal game.pieces['e2'], pieceE2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    game.apply_moves! ['A1 A3'].collect { |m| m.to_move(game) }
+    assert_equal game.history.length, 1
+    assert_equal game.pieces['a1'], pieceA1
+    assert_equal game.pieces['a2'], pieceA2
+    assert_equal game.pieces['c1'], pieceC1
+    assert_equal game.pieces['c2'], pieceC2
+    assert_equal game.pieces['e1'], pieceE1
+    assert_equal game.pieces['e2'], pieceE2
+    assert_equal game.pieces['a1'].position, game.board.positions['a3']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'c'
+
+    game.undo_move!
+    assert_equal [], game.history
+    assert_equal game.pieces['a1'], pieceA1
+    assert_equal game.pieces['a2'], pieceA2
+    assert_equal game.pieces['c1'], pieceC1
+    assert_equal game.pieces['c2'], pieceC2
+    assert_equal game.pieces['e1'], pieceE1
+    assert_equal game.pieces['e2'], pieceE2
+    assert_equal game.pieces['a1'].position, game.board.positions['a']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['a']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['c']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['c']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', 
+      'C1 CC5', 'C2 CC5', 'C1 AC6']  # A1 now captured by C1
+    move_set1a = ['C1 AC6']
+    move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1
+    move_set2a = ['E1 AC6']
+
+    game.apply_moves! move_set1.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, false
+    assert       game.pieces['c1'].contains.include?(pieceA1) 
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+
+    game.undo_move!
+    assert_equal game.history.length, 5
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, false
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c1'].captured, false
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'c'
+
+    game.apply_moves! move_set1a.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 6
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, false
+    assert       game.pieces['c1'].contains.include?(pieceA1) 
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['e']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['e']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+        
+    game.apply_moves! move_set2.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 9
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, false
+    assert       game.pieces['e1'].contains.include?(pieceA1) 
+    assert       game.pieces['e1'].contains.include?(pieceC1) 
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+
+    game.undo_move!
+    assert_equal game.history.length, 8
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].captured, false
+    assert       game.pieces['c1'].contains.include?(pieceA1) 
+
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e1'].captured, false
+    assert_equal game.pieces['e1'].contains, []
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'e'
+
+        assert_equal game.pieces['c1'].position, game.pieces['a1'].position
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+
+    
+    game.apply_moves! move_set2a.collect {|m| m.to_move(game)}
+    assert_equal game.history.length, 9
+    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['a1'].captured, true
+    assert_equal game.pieces['a1'].contains, []
+    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
+    assert_equal game.pieces['a2'].captured, false
+    assert_equal game.pieces['a2'].contains, []
+    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['c1'].captured, true
+    assert_equal game.pieces['c1'].contains, []
+    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
+    assert_equal game.pieces['c2'].captured, false
+    assert_equal game.pieces['c2'].contains, []
+    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
+    assert_equal game.pieces['e1'].captured, false
+    assert       game.pieces['e1'].contains.include?(pieceA1) 
+    assert       game.pieces['e1'].contains.include?(pieceC1) 
+    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
+    assert_equal game.pieces['e2'].captured, false
+    assert_equal game.pieces['e2'].contains, []
+    assert_equal game.current_player, 'a'
+        
+  end
+ + \ No newline at end of file diff --git a/doc/classes/GameWonInHistoryError.html b/doc/classes/GameWonInHistoryError.html new file mode 100644 index 0000000..1814a1a --- /dev/null +++ b/doc/classes/GameWonInHistoryError.html @@ -0,0 +1,111 @@ + + + + + + Class: GameWonInHistoryError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameWonInHistoryError
In: + + src/ttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/GameWonNotice.html b/doc/classes/GameWonNotice.html new file mode 100644 index 0000000..3e1e3fc --- /dev/null +++ b/doc/classes/GameWonNotice.html @@ -0,0 +1,118 @@ + + + + + + Class: GameWonNotice + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGameWonNotice
In: + + lib/libttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ +
+

+Game is won when only one player has uncaptured +pieces +

+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Genome.html b/doc/classes/Genome.html new file mode 100644 index 0000000..496f785 --- /dev/null +++ b/doc/classes/Genome.html @@ -0,0 +1,237 @@ + + + + + + Class: Genome + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassGenome
In: + + lib/libgenetics.rb + +
+ + lib/libpplayer.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A single genome in a population +

+ +
+ + +
+ +
+

Methods

+ +
+ crossover   + mutate   + mutate!   + new   + to_potential_player   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + +
genome [RW] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

+Create a random genome of the given length +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Crossover two genomes at the given point +

+
+
+ +
+ + + + +
+

+Mutate a genome with the given rate per bit +

+
+
+ +
+ + + + +
+

+Mutate a genome in-place with the given rate per bit +

+
+
+ +
+ + + + +
+

+Create a potential player from a genome +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Genome.src/.svn/all-wcprops b/doc/classes/Genome.src/.svn/all-wcprops new file mode 100644 index 0000000..48b5111 --- /dev/null +++ b/doc/classes/Genome.src/.svn/all-wcprops @@ -0,0 +1,35 @@ +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Genome.src +END +M000001.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Genome.src/M000001.html +END +M000002.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Genome.src/M000002.html +END +M000003.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Genome.src/M000003.html +END +M000004.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Genome.src/M000004.html +END +M000005.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Genome.src/M000005.html +END diff --git a/doc/classes/Genome.src/.svn/entries b/doc/classes/Genome.src/.svn/entries new file mode 100644 index 0000000..e45aded --- /dev/null +++ b/doc/classes/Genome.src/.svn/entries @@ -0,0 +1,71 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Genome.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +M000001.html +file + + + + +2008-04-23T19:33:07.000000Z +4da286327eca24da7a742049021bbcd0 +2008-10-16T14:11:23.436422Z +41 + +M000002.html +file + + + + +2008-04-23T19:33:07.000000Z +205ad88e7b17bd199054e2836209fcd3 +2008-10-16T14:11:23.436422Z +41 + +M000003.html +file + + + + +2008-04-23T19:33:07.000000Z +82200bb7f70720fda05beff258c8a3f8 +2008-10-16T14:11:23.436422Z +41 + +M000004.html +file + + + + +2008-04-23T19:33:07.000000Z +73d8bfdd6014a17bf9b588a0567dc95a +2008-10-16T14:11:23.436422Z +41 + +M000005.html +file + + + + +2008-04-23T19:33:07.000000Z +b6e5cf5d5537e99bcbd762c110e79307 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/Genome.src/.svn/format b/doc/classes/Genome.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Genome.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Genome.src/.svn/text-base/M000001.html.svn-base b/doc/classes/Genome.src/.svn/text-base/M000001.html.svn-base new file mode 100644 index 0000000..5d769a6 --- /dev/null +++ b/doc/classes/Genome.src/.svn/text-base/M000001.html.svn-base @@ -0,0 +1,25 @@ + + + + + + new (Genome) + + + + +
# File lib/libgenetics.rb, line 17
+  def initialize(bitstring_or_length)
+    if bitstring_or_length.class == Fixnum
+      @genome = []
+      (1..bitstring_or_length).each do |i|
+        @genome << rand(2)
+      end
+    else
+      @genome = bitstring_or_length
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/.svn/text-base/M000002.html.svn-base b/doc/classes/Genome.src/.svn/text-base/M000002.html.svn-base new file mode 100644 index 0000000..9d370ad --- /dev/null +++ b/doc/classes/Genome.src/.svn/text-base/M000002.html.svn-base @@ -0,0 +1,30 @@ + + + + + + mutate (Genome) + + + + +
# File lib/libgenetics.rb, line 29
+  def mutate(mutation_probability = 0.05)
+    new_genome = Genome.new(@genome.length)
+    (0...@genome.length).each do |i|
+      if rand(1) < mutation_probability
+        if @genome[i] == 0
+          new_genome.genome[i] = 1
+        else
+          new_genome.genome[i] = 0
+        end
+      else
+        new_genome.genome[i] = @genome[i]
+      end
+    end
+    new_genome
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/.svn/text-base/M000003.html.svn-base b/doc/classes/Genome.src/.svn/text-base/M000003.html.svn-base new file mode 100644 index 0000000..d42eca7 --- /dev/null +++ b/doc/classes/Genome.src/.svn/text-base/M000003.html.svn-base @@ -0,0 +1,27 @@ + + + + + + mutate! (Genome) + + + + +
# File lib/libgenetics.rb, line 46
+  def mutate!(mutation_probability = 0.05)
+    (0...@genome.length).each do |i|
+      if rand(1) < mutation_probability
+        if @genome[i] == 0
+          @genome[i] = 1
+        else
+          @genome[i] = 0
+        end
+      end
+    end
+    @genome
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/.svn/text-base/M000004.html.svn-base b/doc/classes/Genome.src/.svn/text-base/M000004.html.svn-base new file mode 100644 index 0000000..b95439d --- /dev/null +++ b/doc/classes/Genome.src/.svn/text-base/M000004.html.svn-base @@ -0,0 +1,24 @@ + + + + + + crossover (Genome) + + + + +
# File lib/libgenetics.rb, line 60
+  def crossover(other_genome, crossover_point)
+    raise ArgumentError, "Different size genomes" if @genome.length != other_genome.genome.length
+    raise ArgumentError, "Our of bounds crossover point" if crossover_point < 0 or crossover_point > @genome.length
+    child1 = Genome.new(0)
+    child2 = Genome.new(0)
+    child1.genome = @genome[0, crossover_point] + other_genome.genome[crossover_point, @genome.length]
+    child1.genome = other_genome.genome[0, crossover_point] + @genome[crossover_point, @genome.length]
+    [child1, child2]
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/.svn/text-base/M000005.html.svn-base b/doc/classes/Genome.src/.svn/text-base/M000005.html.svn-base new file mode 100644 index 0000000..fec8099 --- /dev/null +++ b/doc/classes/Genome.src/.svn/text-base/M000005.html.svn-base @@ -0,0 +1,25 @@ + + + + + + to_potential_player (Genome) + + + + +
# File lib/libpplayer.rb, line 96
+  def to_potential_player
+    friend_pull   = @genome[0,  4].gray_decode.to_decimal.to_f / 4
+    enemy_pull    = @genome[4,  4].gray_decode.to_decimal.to_f / 4
+    base_pull     = @genome[8,  4].gray_decode.to_decimal.to_f / 4
+    safe_bonus    = @genome[12, 4].gray_decode.to_decimal
+    capture_bonus = @genome[16, 4].gray_decode.to_decimal
+    Potential_player.new({:friend_pull => friend_pull, 
+        :enemy_pull => enemy_pull, :base_pull => base_pull, 
+        :safe_bonus => safe_bonus, :capture_bonus => capture_bonus})
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/M000001.html b/doc/classes/Genome.src/M000001.html new file mode 100644 index 0000000..5d769a6 --- /dev/null +++ b/doc/classes/Genome.src/M000001.html @@ -0,0 +1,25 @@ + + + + + + new (Genome) + + + + +
# File lib/libgenetics.rb, line 17
+  def initialize(bitstring_or_length)
+    if bitstring_or_length.class == Fixnum
+      @genome = []
+      (1..bitstring_or_length).each do |i|
+        @genome << rand(2)
+      end
+    else
+      @genome = bitstring_or_length
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/M000002.html b/doc/classes/Genome.src/M000002.html new file mode 100644 index 0000000..9d370ad --- /dev/null +++ b/doc/classes/Genome.src/M000002.html @@ -0,0 +1,30 @@ + + + + + + mutate (Genome) + + + + +
# File lib/libgenetics.rb, line 29
+  def mutate(mutation_probability = 0.05)
+    new_genome = Genome.new(@genome.length)
+    (0...@genome.length).each do |i|
+      if rand(1) < mutation_probability
+        if @genome[i] == 0
+          new_genome.genome[i] = 1
+        else
+          new_genome.genome[i] = 0
+        end
+      else
+        new_genome.genome[i] = @genome[i]
+      end
+    end
+    new_genome
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/M000003.html b/doc/classes/Genome.src/M000003.html new file mode 100644 index 0000000..d42eca7 --- /dev/null +++ b/doc/classes/Genome.src/M000003.html @@ -0,0 +1,27 @@ + + + + + + mutate! (Genome) + + + + +
# File lib/libgenetics.rb, line 46
+  def mutate!(mutation_probability = 0.05)
+    (0...@genome.length).each do |i|
+      if rand(1) < mutation_probability
+        if @genome[i] == 0
+          @genome[i] = 1
+        else
+          @genome[i] = 0
+        end
+      end
+    end
+    @genome
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/M000004.html b/doc/classes/Genome.src/M000004.html new file mode 100644 index 0000000..b95439d --- /dev/null +++ b/doc/classes/Genome.src/M000004.html @@ -0,0 +1,24 @@ + + + + + + crossover (Genome) + + + + +
# File lib/libgenetics.rb, line 60
+  def crossover(other_genome, crossover_point)
+    raise ArgumentError, "Different size genomes" if @genome.length != other_genome.genome.length
+    raise ArgumentError, "Our of bounds crossover point" if crossover_point < 0 or crossover_point > @genome.length
+    child1 = Genome.new(0)
+    child2 = Genome.new(0)
+    child1.genome = @genome[0, crossover_point] + other_genome.genome[crossover_point, @genome.length]
+    child1.genome = other_genome.genome[0, crossover_point] + @genome[crossover_point, @genome.length]
+    [child1, child2]
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Genome.src/M000005.html b/doc/classes/Genome.src/M000005.html new file mode 100644 index 0000000..fec8099 --- /dev/null +++ b/doc/classes/Genome.src/M000005.html @@ -0,0 +1,25 @@ + + + + + + to_potential_player (Genome) + + + + +
# File lib/libpplayer.rb, line 96
+  def to_potential_player
+    friend_pull   = @genome[0,  4].gray_decode.to_decimal.to_f / 4
+    enemy_pull    = @genome[4,  4].gray_decode.to_decimal.to_f / 4
+    base_pull     = @genome[8,  4].gray_decode.to_decimal.to_f / 4
+    safe_bonus    = @genome[12, 4].gray_decode.to_decimal
+    capture_bonus = @genome[16, 4].gray_decode.to_decimal
+    Potential_player.new({:friend_pull => friend_pull, 
+        :enemy_pull => enemy_pull, :base_pull => base_pull, 
+        :safe_bonus => safe_bonus, :capture_bonus => capture_bonus})
+  end
+ + \ No newline at end of file diff --git a/doc/classes/IO.html b/doc/classes/IO.html new file mode 100644 index 0000000..304be5a --- /dev/null +++ b/doc/classes/IO.html @@ -0,0 +1,146 @@ + + + + + + Class: IO + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassIO
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Read a game description file and convert it into a Game object and set of Move +objects. Note that Game.read_game method +returns multiple values, so this one does too. +

+ +
+ + +
+ +
+

Methods

+ +
+ read_game   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Class methods

+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/IO.src/.svn/all-wcprops b/doc/classes/IO.src/.svn/all-wcprops new file mode 100644 index 0000000..e2bc1f0 --- /dev/null +++ b/doc/classes/IO.src/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 57 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/IO.src +END +M000031.html +K 25 +svn:wc:ra_dav:version-url +V 70 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/IO.src/M000031.html +END +M000007.html +K 25 +svn:wc:ra_dav:version-url +V 70 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/IO.src/M000007.html +END +M000017.html +K 25 +svn:wc:ra_dav:version-url +V 70 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/IO.src/M000017.html +END diff --git a/doc/classes/IO.src/.svn/entries b/doc/classes/IO.src/.svn/entries new file mode 100644 index 0000000..09002f0 --- /dev/null +++ b/doc/classes/IO.src/.svn/entries @@ -0,0 +1,63 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/IO.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000031.html +file + + + + +2008-03-28T15:44:41.000000Z +af2b4fd07ed39eb2d35c653b2a5b7045 +2008-10-16T14:11:23.436422Z +41 + +M000007.html +file + + + + +2008-03-25T12:43:37.000000Z +ec9e5266c0301d36db9eb2a68b19175c +2008-03-28T15:47:09.723420Z +24 +neil + +M000017.html +file + + + + +2008-03-25T11:48:00.000000Z +70d6fea878ec9938ce0a457e5f0b6d8b +2008-03-25T12:46:59.166018Z +23 +neil + diff --git a/doc/classes/IO.src/.svn/format b/doc/classes/IO.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/IO.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/IO.src/.svn/text-base/M000007.html.svn-base b/doc/classes/IO.src/.svn/text-base/M000007.html.svn-base new file mode 100644 index 0000000..9d31243 --- /dev/null +++ b/doc/classes/IO.src/.svn/text-base/M000007.html.svn-base @@ -0,0 +1,19 @@ + + + + + + read_game (IO) + + + + +
# File lib/libttc.rb, line 533
+  def IO.read_game(filename)
+    gamelines = IO.readlines(filename)
+    return Game.read_game(gamelines)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/IO.src/.svn/text-base/M000017.html.svn-base b/doc/classes/IO.src/.svn/text-base/M000017.html.svn-base new file mode 100644 index 0000000..66ebbbc --- /dev/null +++ b/doc/classes/IO.src/.svn/text-base/M000017.html.svn-base @@ -0,0 +1,19 @@ + + + + + + read_game (IO) + + + + +
# File lib/libttc.rb, line 515
+  def IO.read_game(filename)
+    gamelines = IO.readlines(filename)
+    return Game.read_game(gamelines)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/IO.src/.svn/text-base/M000031.html.svn-base b/doc/classes/IO.src/.svn/text-base/M000031.html.svn-base new file mode 100644 index 0000000..b48468a --- /dev/null +++ b/doc/classes/IO.src/.svn/text-base/M000031.html.svn-base @@ -0,0 +1,19 @@ + + + + + + read_game (IO) + + + + +
# File lib/libttc.rb, line 611
+  def IO.read_game(filename)
+    gamelines = IO.readlines(filename)
+    return Game.read_game(gamelines)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/IO.src/M000007.html b/doc/classes/IO.src/M000007.html new file mode 100644 index 0000000..9d31243 --- /dev/null +++ b/doc/classes/IO.src/M000007.html @@ -0,0 +1,19 @@ + + + + + + read_game (IO) + + + + +
# File lib/libttc.rb, line 533
+  def IO.read_game(filename)
+    gamelines = IO.readlines(filename)
+    return Game.read_game(gamelines)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/IO.src/M000017.html b/doc/classes/IO.src/M000017.html new file mode 100644 index 0000000..66ebbbc --- /dev/null +++ b/doc/classes/IO.src/M000017.html @@ -0,0 +1,19 @@ + + + + + + read_game (IO) + + + + +
# File lib/libttc.rb, line 515
+  def IO.read_game(filename)
+    gamelines = IO.readlines(filename)
+    return Game.read_game(gamelines)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/IO.src/M000031.html b/doc/classes/IO.src/M000031.html new file mode 100644 index 0000000..b48468a --- /dev/null +++ b/doc/classes/IO.src/M000031.html @@ -0,0 +1,19 @@ + + + + + + read_game (IO) + + + + +
# File lib/libttc.rb, line 611
+  def IO.read_game(filename)
+    gamelines = IO.readlines(filename)
+    return Game.read_game(gamelines)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/InvalidCaptureError.html b/doc/classes/InvalidCaptureError.html new file mode 100644 index 0000000..9e8d0a8 --- /dev/null +++ b/doc/classes/InvalidCaptureError.html @@ -0,0 +1,117 @@ + + + + + + Class: InvalidCaptureError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassInvalidCaptureError
In: + + lib/libttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ +
+

+Pieces can only capture pieces that they‘re on. +

+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/InvalidMoveError.html b/doc/classes/InvalidMoveError.html new file mode 100644 index 0000000..e897961 --- /dev/null +++ b/doc/classes/InvalidMoveError.html @@ -0,0 +1,117 @@ + + + + + + Class: InvalidMoveError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassInvalidMoveError
In: + + lib/libttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ +
+

+Moves can only be [1..6] spaces +

+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/InvalidMoveInHistoryError.html b/doc/classes/InvalidMoveInHistoryError.html new file mode 100644 index 0000000..6c1456b --- /dev/null +++ b/doc/classes/InvalidMoveInHistoryError.html @@ -0,0 +1,111 @@ + + + + + + Class: InvalidMoveInHistoryError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassInvalidMoveInHistoryError
In: + + src/ttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/InvalidRobotError.html b/doc/classes/InvalidRobotError.html new file mode 100644 index 0000000..f68f98e --- /dev/null +++ b/doc/classes/InvalidRobotError.html @@ -0,0 +1,111 @@ + + + + + + Class: InvalidRobotError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassInvalidRobotError
In: + + src/ttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Move.html b/doc/classes/Move.html new file mode 100644 index 0000000..ac70219 --- /dev/null +++ b/doc/classes/Move.html @@ -0,0 +1,212 @@ + + + + + + Class: Move + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassMove
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A move in a game +

+ +
+ + +
+ +
+

Methods

+ +
+ new   + to_s   + to_str   + via_base?   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + +
destination [R] 
piece [R] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+

+Write a move to a string Note the inverse, String#to_move, is defined below +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/all-wcprops b/doc/classes/Move.src/.svn/all-wcprops new file mode 100644 index 0000000..4548d16 --- /dev/null +++ b/doc/classes/Move.src/.svn/all-wcprops @@ -0,0 +1,65 @@ +K 25 +svn:wc:ra_dav:version-url +V 59 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Move.src +END +M000010.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Move.src/M000010.html +END +M000020.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Move.src/M000020.html +END +M000032.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Move.src/M000032.html +END +M000033.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Move.src/M000033.html +END +M000034.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Move.src/M000034.html +END +M000008.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Move.src/M000008.html +END +M000035.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Move.src/M000035.html +END +M000018.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Move.src/M000018.html +END +M000009.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Move.src/M000009.html +END +M000019.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Move.src/M000019.html +END diff --git a/doc/classes/Move.src/.svn/entries b/doc/classes/Move.src/.svn/entries new file mode 100644 index 0000000..ac9a968 --- /dev/null +++ b/doc/classes/Move.src/.svn/entries @@ -0,0 +1,144 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Move.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000010.html +file + + + + +2008-03-25T12:43:37.000000Z +7753cacf5224a23689207a18edccad02 +2008-03-28T15:47:09.723420Z +24 +neil + +M000020.html +file + + + + +2008-03-25T11:48:00.000000Z +f51b24f805dd4e97456643dd6e164193 +2008-03-25T12:46:59.166018Z +23 +neil + +M000032.html +file + + + + +2008-03-28T15:44:41.000000Z +4c945a4b5bf69dc51e92e83d73b70c52 +2008-10-16T14:11:23.436422Z +41 + +M000033.html +file + + + + +2008-03-28T15:44:41.000000Z +7a692bc02ef2fea0bf12b64d4865bc27 +2008-10-16T14:11:23.436422Z +41 + +M000034.html +file + + + + +2008-03-28T15:44:41.000000Z +9c83912d256d6eee20c8fe3366d553b8 +2008-10-16T14:11:23.436422Z +41 + +M000008.html +file + + + + +2008-03-25T12:43:37.000000Z +162b46fe423c2a23b1bddab449e5376f +2008-03-28T15:47:09.723420Z +24 +neil + +M000035.html +file + + + + +2008-03-28T15:44:41.000000Z +ac4172fd876ee8b7e3525bef6061b74a +2008-10-16T14:11:23.436422Z +41 + +M000018.html +file + + + + +2008-03-25T11:48:00.000000Z +895659c1944b11e86eee9275873bf451 +2008-03-25T12:46:59.166018Z +23 +neil + +M000009.html +file + + + + +2008-03-25T12:43:37.000000Z +2446ea3e0e5cb3327148f9856cdce341 +2008-03-28T15:47:09.723420Z +24 +neil + +M000019.html +file + + + + +2008-03-25T11:48:00.000000Z +79aa324191e9a591ccde8698ac38b137 +2008-03-25T12:46:59.166018Z +23 +neil + diff --git a/doc/classes/Move.src/.svn/format b/doc/classes/Move.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Move.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Move.src/.svn/text-base/M000008.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000008.html.svn-base new file mode 100644 index 0000000..6896219 --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000008.html.svn-base @@ -0,0 +1,20 @@ + + + + + + new (Move) + + + + +
# File lib/libttc.rb, line 272
+  def initialize(piece, destination, via_base = false)
+    @piece = piece
+    @destination = destination
+    @via_base = via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000009.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000009.html.svn-base new file mode 100644 index 0000000..25d8c6d --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000009.html.svn-base @@ -0,0 +1,18 @@ + + + + + + via_base? (Move) + + + + +
# File lib/libttc.rb, line 278
+  def via_base?
+    @via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000010.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000010.html.svn-base new file mode 100644 index 0000000..93ac9c4 --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000010.html.svn-base @@ -0,0 +1,26 @@ + + + + + + to_s (Move) + + + + +
# File lib/libttc.rb, line 284
+  def to_s
+    if @via_base
+      if @destination.base?
+        @piece.to_s + " "  + @destination.to_s
+      else
+        @piece.to_s + " " + piece.colour + " " + @destination.to_s
+      end
+    else
+      @piece.to_s + " " + @destination.to_s
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000018.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000018.html.svn-base new file mode 100644 index 0000000..d1ec29e --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000018.html.svn-base @@ -0,0 +1,20 @@ + + + + + + new (Move) + + + + +
# File lib/libttc.rb, line 261
+  def initialize(piece, destination, via_base = false)
+    @piece = piece
+    @destination = destination
+    @via_base = via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000019.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000019.html.svn-base new file mode 100644 index 0000000..14002e4 --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000019.html.svn-base @@ -0,0 +1,18 @@ + + + + + + via_base? (Move) + + + + +
# File lib/libttc.rb, line 267
+  def via_base?
+    @via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000020.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000020.html.svn-base new file mode 100644 index 0000000..4500c41 --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000020.html.svn-base @@ -0,0 +1,26 @@ + + + + + + to_s (Move) + + + + +
# File lib/libttc.rb, line 273
+  def to_s
+    if @via_base
+      if @destination.base?
+        @piece.to_s + " "  + @destination.to_s
+      else
+        @piece.to_s + " " + piece.colour + " " + @destination.to_s
+      end
+    else
+      @piece.to_s + " " + @destination.to_s
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000032.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000032.html.svn-base new file mode 100644 index 0000000..0220fa7 --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000032.html.svn-base @@ -0,0 +1,20 @@ + + + + + + new (Move) + + + + +
# File lib/libttc.rb, line 285
+  def initialize(piece, destination, via_base = false)
+    @piece = piece
+    @destination = destination
+    @via_base = via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000033.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000033.html.svn-base new file mode 100644 index 0000000..09f3fde --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000033.html.svn-base @@ -0,0 +1,18 @@ + + + + + + via_base? (Move) + + + + +
# File lib/libttc.rb, line 291
+  def via_base?
+    @via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000034.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000034.html.svn-base new file mode 100644 index 0000000..b8b07b3 --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000034.html.svn-base @@ -0,0 +1,26 @@ + + + + + + to_s (Move) + + + + +
# File lib/libttc.rb, line 297
+  def to_s
+    if @via_base
+      if @destination.base?
+        @piece.to_s + " "  + @destination.to_s
+      else
+        @piece.to_s + " " + piece.colour + " " + @destination.to_s
+      end
+    else
+      @piece.to_s + " " + @destination.to_s
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/.svn/text-base/M000035.html.svn-base b/doc/classes/Move.src/.svn/text-base/M000035.html.svn-base new file mode 100644 index 0000000..a853ac2 --- /dev/null +++ b/doc/classes/Move.src/.svn/text-base/M000035.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_str (Move) + + + + +
# File lib/libttc.rb, line 309
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000008.html b/doc/classes/Move.src/M000008.html new file mode 100644 index 0000000..6896219 --- /dev/null +++ b/doc/classes/Move.src/M000008.html @@ -0,0 +1,20 @@ + + + + + + new (Move) + + + + +
# File lib/libttc.rb, line 272
+  def initialize(piece, destination, via_base = false)
+    @piece = piece
+    @destination = destination
+    @via_base = via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000009.html b/doc/classes/Move.src/M000009.html new file mode 100644 index 0000000..25d8c6d --- /dev/null +++ b/doc/classes/Move.src/M000009.html @@ -0,0 +1,18 @@ + + + + + + via_base? (Move) + + + + +
# File lib/libttc.rb, line 278
+  def via_base?
+    @via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000010.html b/doc/classes/Move.src/M000010.html new file mode 100644 index 0000000..93ac9c4 --- /dev/null +++ b/doc/classes/Move.src/M000010.html @@ -0,0 +1,26 @@ + + + + + + to_s (Move) + + + + +
# File lib/libttc.rb, line 284
+  def to_s
+    if @via_base
+      if @destination.base?
+        @piece.to_s + " "  + @destination.to_s
+      else
+        @piece.to_s + " " + piece.colour + " " + @destination.to_s
+      end
+    else
+      @piece.to_s + " " + @destination.to_s
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000018.html b/doc/classes/Move.src/M000018.html new file mode 100644 index 0000000..d1ec29e --- /dev/null +++ b/doc/classes/Move.src/M000018.html @@ -0,0 +1,20 @@ + + + + + + new (Move) + + + + +
# File lib/libttc.rb, line 261
+  def initialize(piece, destination, via_base = false)
+    @piece = piece
+    @destination = destination
+    @via_base = via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000019.html b/doc/classes/Move.src/M000019.html new file mode 100644 index 0000000..14002e4 --- /dev/null +++ b/doc/classes/Move.src/M000019.html @@ -0,0 +1,18 @@ + + + + + + via_base? (Move) + + + + +
# File lib/libttc.rb, line 267
+  def via_base?
+    @via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000020.html b/doc/classes/Move.src/M000020.html new file mode 100644 index 0000000..4500c41 --- /dev/null +++ b/doc/classes/Move.src/M000020.html @@ -0,0 +1,26 @@ + + + + + + to_s (Move) + + + + +
# File lib/libttc.rb, line 273
+  def to_s
+    if @via_base
+      if @destination.base?
+        @piece.to_s + " "  + @destination.to_s
+      else
+        @piece.to_s + " " + piece.colour + " " + @destination.to_s
+      end
+    else
+      @piece.to_s + " " + @destination.to_s
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000032.html b/doc/classes/Move.src/M000032.html new file mode 100644 index 0000000..0220fa7 --- /dev/null +++ b/doc/classes/Move.src/M000032.html @@ -0,0 +1,20 @@ + + + + + + new (Move) + + + + +
# File lib/libttc.rb, line 285
+  def initialize(piece, destination, via_base = false)
+    @piece = piece
+    @destination = destination
+    @via_base = via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000033.html b/doc/classes/Move.src/M000033.html new file mode 100644 index 0000000..09f3fde --- /dev/null +++ b/doc/classes/Move.src/M000033.html @@ -0,0 +1,18 @@ + + + + + + via_base? (Move) + + + + +
# File lib/libttc.rb, line 291
+  def via_base?
+    @via_base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000034.html b/doc/classes/Move.src/M000034.html new file mode 100644 index 0000000..b8b07b3 --- /dev/null +++ b/doc/classes/Move.src/M000034.html @@ -0,0 +1,26 @@ + + + + + + to_s (Move) + + + + +
# File lib/libttc.rb, line 297
+  def to_s
+    if @via_base
+      if @destination.base?
+        @piece.to_s + " "  + @destination.to_s
+      else
+        @piece.to_s + " " + piece.colour + " " + @destination.to_s
+      end
+    else
+      @piece.to_s + " " + @destination.to_s
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Move.src/M000035.html b/doc/classes/Move.src/M000035.html new file mode 100644 index 0000000..a853ac2 --- /dev/null +++ b/doc/classes/Move.src/M000035.html @@ -0,0 +1,18 @@ + + + + + + to_str (Move) + + + + +
# File lib/libttc.rb, line 309
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/NoInputFileError.html b/doc/classes/NoInputFileError.html new file mode 100644 index 0000000..590dcb7 --- /dev/null +++ b/doc/classes/NoInputFileError.html @@ -0,0 +1,111 @@ + + + + + + Class: NoInputFileError + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassNoInputFileError
In: + + src/ttc.rb + +
+
Parent: + StandardError +
+
+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Piece.html b/doc/classes/Piece.html new file mode 100644 index 0000000..5a4a698 --- /dev/null +++ b/doc/classes/Piece.html @@ -0,0 +1,251 @@ + + + + + + Class: Piece + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassPiece
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Each piece on the board is an object +

+ +
+ + +
+ +
+

Methods

+ +
+ capture   + move_to   + name   + new   + to_s   + to_str   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + + + + + + +
captured [RW] 
colour [R] 
contains [RW] 
position [RW] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+

+Caputre another piece +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/all-wcprops b/doc/classes/Piece.src/.svn/all-wcprops new file mode 100644 index 0000000..d68e4ee --- /dev/null +++ b/doc/classes/Piece.src/.svn/all-wcprops @@ -0,0 +1,101 @@ +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Piece.src +END +M000020.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Piece.src/M000020.html +END +M000030.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Piece.src/M000030.html +END +M000021.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Piece.src/M000021.html +END +M000031.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Piece.src/M000031.html +END +M000022.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Piece.src/M000022.html +END +M000032.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Piece.src/M000032.html +END +M000050.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Piece.src/M000050.html +END +M000051.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Piece.src/M000051.html +END +M000052.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Piece.src/M000052.html +END +M000018.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Piece.src/M000018.html +END +M000028.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Piece.src/M000028.html +END +M000019.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Piece.src/M000019.html +END +M000029.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Piece.src/M000029.html +END +M000047.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Piece.src/M000047.html +END +M000048.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Piece.src/M000048.html +END +M000049.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Piece.src/M000049.html +END diff --git a/doc/classes/Piece.src/.svn/entries b/doc/classes/Piece.src/.svn/entries new file mode 100644 index 0000000..b33caf5 --- /dev/null +++ b/doc/classes/Piece.src/.svn/entries @@ -0,0 +1,214 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Piece.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000020.html +file + + + + +2008-03-25T12:43:37.000000Z +516609c05816da96ec69d7d4a6751241 +2008-03-28T15:47:09.723420Z +24 +neil + +M000030.html +file + + + + +2008-03-25T11:48:00.000000Z +07e2db4c8070cb086797e7814a39a5de +2008-03-25T12:46:59.166018Z +23 +neil + +M000021.html +file + + + + +2008-03-25T12:43:37.000000Z +fc60fa123a6694e491e9fcf762dca74a +2008-03-28T15:47:09.723420Z +24 +neil + +M000031.html +file + + + + +2008-03-25T11:48:00.000000Z +ed7a8a64462d4848b23e68de6f49a14f +2008-03-25T12:46:59.166018Z +23 +neil + +M000022.html +file + + + + +2008-03-25T12:43:37.000000Z +c32da391f0e26064f9623fda8fdc06bb +2008-03-28T15:47:09.723420Z +24 +neil + +M000032.html +file + + + + +2008-03-25T11:48:00.000000Z +f8de4105bdcf700ae1d93d83e4cfb308 +2008-03-25T12:46:59.166018Z +23 +neil + +M000050.html +file + + + + +2008-03-28T15:44:42.000000Z +10a504d07cbce5caae25630f82048069 +2008-10-16T14:11:23.436422Z +41 + +M000051.html +file + + + + +2008-03-28T15:44:42.000000Z +d876b0d20adfa7b8dee14e9f19910a8f +2008-10-16T14:11:23.436422Z +41 + +M000052.html +file + + + + +2008-03-28T15:44:42.000000Z +5c7c848d7d5eafc6751d590ad1f930d2 +2008-10-16T14:11:23.436422Z +41 + +M000018.html +file + + + + +2008-03-25T12:43:37.000000Z +795c5d80b0f48d5bc1229ddab01654cf +2008-03-28T15:47:09.723420Z +24 +neil + +M000028.html +file + + + + +2008-03-25T11:48:00.000000Z +eb377a89525ee4de2a2ad22164ba947b +2008-03-25T12:46:59.166018Z +23 +neil + +M000019.html +file + + + + +2008-03-25T12:43:37.000000Z +3befe68a477b27596ed5712212e46d45 +2008-03-28T15:47:09.723420Z +24 +neil + +M000029.html +file + + + + +2008-03-25T11:48:00.000000Z +dde4d37af603faeba2e7c4c6a0f85292 +2008-03-25T12:46:59.166018Z +23 +neil + +M000047.html +file + + + + +2008-03-28T15:44:42.000000Z +f76d8ad67b857750ed404694a16605ec +2008-10-16T14:11:23.436422Z +41 + +M000048.html +file + + + + +2008-03-28T15:44:42.000000Z +1d3086ac7edc8b5ab67b54d3a6b08038 +2008-10-16T14:11:23.436422Z +41 + +M000049.html +file + + + + +2008-03-28T15:44:42.000000Z +67c51d585206abb03669d0fdc6cc6f53 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/Piece.src/.svn/format b/doc/classes/Piece.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Piece.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Piece.src/.svn/text-base/M000018.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000018.html.svn-base new file mode 100644 index 0000000..0caa2bc --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000018.html.svn-base @@ -0,0 +1,22 @@ + + + + + + new (Piece) + + + + +
# File lib/libttc.rb, line 231
+  def initialize(number, position, colour)
+    @number = number
+    @position = position
+    @colour = colour
+    @captured = false
+    @contains = []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000019.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000019.html.svn-base new file mode 100644 index 0000000..5927428 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000019.html.svn-base @@ -0,0 +1,18 @@ + + + + + + name (Piece) + + + + +
# File lib/libttc.rb, line 239
+  def name
+    @colour + @number.to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000020.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000020.html.svn-base new file mode 100644 index 0000000..4b07bd8 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000020.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Piece) + + + + +
# File lib/libttc.rb, line 243
+  def to_s
+    self.name
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000021.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000021.html.svn-base new file mode 100644 index 0000000..2b2932f --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000021.html.svn-base @@ -0,0 +1,19 @@ + + + + + + move_to (Piece) + + + + +
# File lib/libttc.rb, line 247
+  def move_to(new_position)
+    @position = new_position
+    @contains.each {|c| c.move_to(new_position)}
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000022.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000022.html.svn-base new file mode 100644 index 0000000..0e85bcb --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000022.html.svn-base @@ -0,0 +1,26 @@ + + + + + + capture (Piece) + + + + +
# File lib/libttc.rb, line 253
+  def capture(other_piece)
+    if @position = other_piece.position
+      @contains << other_piece
+      @contains += other_piece.contains
+      other_piece.contains = []
+      other_piece.captured = true
+    else
+      raise(InvalidCaptureError, 
+        "Piece #{self.name} cannot capture #{other_piece.name}: different locations")
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000028.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000028.html.svn-base new file mode 100644 index 0000000..e0d390a --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000028.html.svn-base @@ -0,0 +1,22 @@ + + + + + + new (Piece) + + + + +
# File lib/libttc.rb, line 221
+  def initialize(number, position, colour)
+    @number = number
+    @position = position
+    @colour = colour
+    @captured = false
+    @contains = []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000029.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000029.html.svn-base new file mode 100644 index 0000000..e7620a3 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000029.html.svn-base @@ -0,0 +1,18 @@ + + + + + + name (Piece) + + + + +
# File lib/libttc.rb, line 229
+  def name
+    @colour + @number.to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000030.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000030.html.svn-base new file mode 100644 index 0000000..9935b8c --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000030.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Piece) + + + + +
# File lib/libttc.rb, line 233
+  def to_s
+    self.name
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000031.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000031.html.svn-base new file mode 100644 index 0000000..52fc2f8 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000031.html.svn-base @@ -0,0 +1,19 @@ + + + + + + move_to (Piece) + + + + +
# File lib/libttc.rb, line 237
+  def move_to(new_position)
+    @position = new_position
+    @contains.each {|c| c.move_to(new_position)}
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000032.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000032.html.svn-base new file mode 100644 index 0000000..f982290 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000032.html.svn-base @@ -0,0 +1,25 @@ + + + + + + capture (Piece) + + + + +
# File lib/libttc.rb, line 243
+  def capture(other_piece)
+    if @position = other_piece.position
+      @contains << other_piece
+      @contains += other_piece.contains
+      other_piece.contains = []
+      other_piece.captured = true
+    else
+      raise(InvalidCaptureError, "Piece #{self.name} cannot capture #{other_piece.name}: different locations")
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000047.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000047.html.svn-base new file mode 100644 index 0000000..df2cbe9 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000047.html.svn-base @@ -0,0 +1,22 @@ + + + + + + new (Piece) + + + + +
# File lib/libttc.rb, line 240
+  def initialize(number, position, colour)
+    @number = number
+    @position = position
+    @colour = colour
+    @captured = false
+    @contains = []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000048.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000048.html.svn-base new file mode 100644 index 0000000..188a338 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000048.html.svn-base @@ -0,0 +1,18 @@ + + + + + + name (Piece) + + + + +
# File lib/libttc.rb, line 248
+  def name
+    @colour + @number.to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000049.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000049.html.svn-base new file mode 100644 index 0000000..5d9ce86 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000049.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Piece) + + + + +
# File lib/libttc.rb, line 252
+  def to_s
+    self.name
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000050.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000050.html.svn-base new file mode 100644 index 0000000..26397c2 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000050.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_str (Piece) + + + + +
# File lib/libttc.rb, line 256
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000051.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000051.html.svn-base new file mode 100644 index 0000000..1127915 --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000051.html.svn-base @@ -0,0 +1,19 @@ + + + + + + move_to (Piece) + + + + +
# File lib/libttc.rb, line 260
+  def move_to(new_position)
+    @position = new_position
+    @contains.each {|c| c.move_to(new_position)}
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/.svn/text-base/M000052.html.svn-base b/doc/classes/Piece.src/.svn/text-base/M000052.html.svn-base new file mode 100644 index 0000000..c20205f --- /dev/null +++ b/doc/classes/Piece.src/.svn/text-base/M000052.html.svn-base @@ -0,0 +1,26 @@ + + + + + + capture (Piece) + + + + +
# File lib/libttc.rb, line 266
+  def capture(other_piece)
+    if @position = other_piece.position
+      @contains << other_piece
+      @contains += other_piece.contains
+      other_piece.contains = []
+      other_piece.captured = true
+    else
+      raise(InvalidCaptureError, 
+        "Piece #{self.name} cannot capture #{other_piece.name}: different locations")
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000018.html b/doc/classes/Piece.src/M000018.html new file mode 100644 index 0000000..0caa2bc --- /dev/null +++ b/doc/classes/Piece.src/M000018.html @@ -0,0 +1,22 @@ + + + + + + new (Piece) + + + + +
# File lib/libttc.rb, line 231
+  def initialize(number, position, colour)
+    @number = number
+    @position = position
+    @colour = colour
+    @captured = false
+    @contains = []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000019.html b/doc/classes/Piece.src/M000019.html new file mode 100644 index 0000000..5927428 --- /dev/null +++ b/doc/classes/Piece.src/M000019.html @@ -0,0 +1,18 @@ + + + + + + name (Piece) + + + + +
# File lib/libttc.rb, line 239
+  def name
+    @colour + @number.to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000020.html b/doc/classes/Piece.src/M000020.html new file mode 100644 index 0000000..4b07bd8 --- /dev/null +++ b/doc/classes/Piece.src/M000020.html @@ -0,0 +1,18 @@ + + + + + + to_s (Piece) + + + + +
# File lib/libttc.rb, line 243
+  def to_s
+    self.name
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000021.html b/doc/classes/Piece.src/M000021.html new file mode 100644 index 0000000..2b2932f --- /dev/null +++ b/doc/classes/Piece.src/M000021.html @@ -0,0 +1,19 @@ + + + + + + move_to (Piece) + + + + +
# File lib/libttc.rb, line 247
+  def move_to(new_position)
+    @position = new_position
+    @contains.each {|c| c.move_to(new_position)}
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000022.html b/doc/classes/Piece.src/M000022.html new file mode 100644 index 0000000..0e85bcb --- /dev/null +++ b/doc/classes/Piece.src/M000022.html @@ -0,0 +1,26 @@ + + + + + + capture (Piece) + + + + +
# File lib/libttc.rb, line 253
+  def capture(other_piece)
+    if @position = other_piece.position
+      @contains << other_piece
+      @contains += other_piece.contains
+      other_piece.contains = []
+      other_piece.captured = true
+    else
+      raise(InvalidCaptureError, 
+        "Piece #{self.name} cannot capture #{other_piece.name}: different locations")
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000028.html b/doc/classes/Piece.src/M000028.html new file mode 100644 index 0000000..e0d390a --- /dev/null +++ b/doc/classes/Piece.src/M000028.html @@ -0,0 +1,22 @@ + + + + + + new (Piece) + + + + +
# File lib/libttc.rb, line 221
+  def initialize(number, position, colour)
+    @number = number
+    @position = position
+    @colour = colour
+    @captured = false
+    @contains = []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000029.html b/doc/classes/Piece.src/M000029.html new file mode 100644 index 0000000..e7620a3 --- /dev/null +++ b/doc/classes/Piece.src/M000029.html @@ -0,0 +1,18 @@ + + + + + + name (Piece) + + + + +
# File lib/libttc.rb, line 229
+  def name
+    @colour + @number.to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000030.html b/doc/classes/Piece.src/M000030.html new file mode 100644 index 0000000..9935b8c --- /dev/null +++ b/doc/classes/Piece.src/M000030.html @@ -0,0 +1,18 @@ + + + + + + to_s (Piece) + + + + +
# File lib/libttc.rb, line 233
+  def to_s
+    self.name
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000031.html b/doc/classes/Piece.src/M000031.html new file mode 100644 index 0000000..52fc2f8 --- /dev/null +++ b/doc/classes/Piece.src/M000031.html @@ -0,0 +1,19 @@ + + + + + + move_to (Piece) + + + + +
# File lib/libttc.rb, line 237
+  def move_to(new_position)
+    @position = new_position
+    @contains.each {|c| c.move_to(new_position)}
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000032.html b/doc/classes/Piece.src/M000032.html new file mode 100644 index 0000000..f982290 --- /dev/null +++ b/doc/classes/Piece.src/M000032.html @@ -0,0 +1,25 @@ + + + + + + capture (Piece) + + + + +
# File lib/libttc.rb, line 243
+  def capture(other_piece)
+    if @position = other_piece.position
+      @contains << other_piece
+      @contains += other_piece.contains
+      other_piece.contains = []
+      other_piece.captured = true
+    else
+      raise(InvalidCaptureError, "Piece #{self.name} cannot capture #{other_piece.name}: different locations")
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000047.html b/doc/classes/Piece.src/M000047.html new file mode 100644 index 0000000..df2cbe9 --- /dev/null +++ b/doc/classes/Piece.src/M000047.html @@ -0,0 +1,22 @@ + + + + + + new (Piece) + + + + +
# File lib/libttc.rb, line 240
+  def initialize(number, position, colour)
+    @number = number
+    @position = position
+    @colour = colour
+    @captured = false
+    @contains = []
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000048.html b/doc/classes/Piece.src/M000048.html new file mode 100644 index 0000000..188a338 --- /dev/null +++ b/doc/classes/Piece.src/M000048.html @@ -0,0 +1,18 @@ + + + + + + name (Piece) + + + + +
# File lib/libttc.rb, line 248
+  def name
+    @colour + @number.to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000049.html b/doc/classes/Piece.src/M000049.html new file mode 100644 index 0000000..5d9ce86 --- /dev/null +++ b/doc/classes/Piece.src/M000049.html @@ -0,0 +1,18 @@ + + + + + + to_s (Piece) + + + + +
# File lib/libttc.rb, line 252
+  def to_s
+    self.name
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000050.html b/doc/classes/Piece.src/M000050.html new file mode 100644 index 0000000..26397c2 --- /dev/null +++ b/doc/classes/Piece.src/M000050.html @@ -0,0 +1,18 @@ + + + + + + to_str (Piece) + + + + +
# File lib/libttc.rb, line 256
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000051.html b/doc/classes/Piece.src/M000051.html new file mode 100644 index 0000000..1127915 --- /dev/null +++ b/doc/classes/Piece.src/M000051.html @@ -0,0 +1,19 @@ + + + + + + move_to (Piece) + + + + +
# File lib/libttc.rb, line 260
+  def move_to(new_position)
+    @position = new_position
+    @contains.each {|c| c.move_to(new_position)}
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Piece.src/M000052.html b/doc/classes/Piece.src/M000052.html new file mode 100644 index 0000000..c20205f --- /dev/null +++ b/doc/classes/Piece.src/M000052.html @@ -0,0 +1,26 @@ + + + + + + capture (Piece) + + + + +
# File lib/libttc.rb, line 266
+  def capture(other_piece)
+    if @position = other_piece.position
+      @contains << other_piece
+      @contains += other_piece.contains
+      other_piece.contains = []
+      other_piece.captured = true
+    else
+      raise(InvalidCaptureError, 
+        "Piece #{self.name} cannot capture #{other_piece.name}: different locations")
+    end
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.html b/doc/classes/Population.html new file mode 100644 index 0000000..2d66c0d --- /dev/null +++ b/doc/classes/Population.html @@ -0,0 +1,255 @@ + + + + + + Class: Population + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassPopulation
In: + + src/selection.rb + +
+ + lib/libgenetics.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+A population of genomes +

+ +
+ + +
+ +
+

Methods

+ + +
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + +
individuals [RW] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

+Create a population of a given size +

+
+
+ +

Public Instance methods

+ +
+ + + + +
+

+Perform the crossover step in a +population, giving a new population +

+
+
+ + + +
+ + + + +
+

+Perform the mutation step in a +population, giving a new population +

+
+
+ +
+ + + + +
+

+Use tournament selection to pick an individual for the next generation +

+
+
+ +
+ + + + +
+

+Select a new population the same size +as the current population +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/all-wcprops b/doc/classes/Population.src/.svn/all-wcprops new file mode 100644 index 0000000..eea1336 --- /dev/null +++ b/doc/classes/Population.src/.svn/all-wcprops @@ -0,0 +1,83 @@ +K 25 +svn:wc:ra_dav:version-url +V 65 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src +END +M000010.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000010.html +END +M000011.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000011.html +END +M000020.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000020.html +END +M000021.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000021.html +END +M000030.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000030.html +END +M000016.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000016.html +END +M000008.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000008.html +END +M000017.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000017.html +END +M000009.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000009.html +END +M000018.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000018.html +END +M000019.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000019.html +END +M000028.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000028.html +END +M000029.html +K 25 +svn:wc:ra_dav:version-url +V 78 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Population.src/M000029.html +END diff --git a/doc/classes/Population.src/.svn/entries b/doc/classes/Population.src/.svn/entries new file mode 100644 index 0000000..7a78b6f --- /dev/null +++ b/doc/classes/Population.src/.svn/entries @@ -0,0 +1,159 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Population.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +M000010.html +file + + + + +2008-04-23T19:30:16.000000Z +019ab7a1fdbfa21cb1d1e099e30e83d4 +2008-10-16T14:11:23.436422Z +41 + +M000011.html +file + + + + +2008-04-23T19:30:16.000000Z +d9375cd19cc9e4eed9923490a93bbee9 +2008-10-16T14:11:23.436422Z +41 + +M000020.html +file + + + + +2008-04-23T19:33:07.000000Z +ff58dc326311308b5be2933597839fd8 +2008-10-16T14:11:23.436422Z +41 + +M000030.html +file + + + + +2008-03-28T15:44:41.000000Z +7930819389ab638d7f116d48ed2481e0 +2008-10-16T14:11:23.436422Z +41 + +M000021.html +file + + + + +2008-04-23T19:33:07.000000Z +c57461174cee0d995caea75051c072fa +2008-10-16T14:11:23.436422Z +41 + +M000016.html +file + + + + +2008-04-23T19:33:07.000000Z +a12e0b906737bae7d960c30635dd3a24 +2008-10-16T14:11:23.436422Z +41 + +M000008.html +file + + + + +2008-04-23T19:30:16.000000Z +f1a767bb69dc09826e84d4e10eb9cdc3 +2008-10-16T14:11:23.436422Z +41 + +M000017.html +file + + + + +2008-04-23T19:33:07.000000Z +2ec7de1679e94df72526d8d00dc15432 +2008-10-16T14:11:23.436422Z +41 + +M000009.html +file + + + + +2008-04-23T19:30:16.000000Z +b733591471885caa25a5593fcd0c484c +2008-10-16T14:11:23.436422Z +41 + +M000018.html +file + + + + +2008-04-23T19:33:07.000000Z +76f8efaf5681eb58cf9ad1cbfadbcc69 +2008-10-16T14:11:23.436422Z +41 + +M000019.html +file + + + + +2008-04-23T19:33:07.000000Z +511f9a56e18cfa02eb03dde24adb02bb +2008-10-16T14:11:23.436422Z +41 + +M000028.html +file + + + + +2008-03-28T15:44:41.000000Z +19cdb4b6accab6582bc702063a246e43 +2008-10-16T14:11:23.436422Z +41 + +M000029.html +file + + + + +2008-03-28T15:44:41.000000Z +bfa85d17b971e9eb4af3079b68ec6e7c +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/Population.src/.svn/format b/doc/classes/Population.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Population.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Population.src/.svn/text-base/M000008.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000008.html.svn-base new file mode 100644 index 0000000..4b69fc7 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000008.html.svn-base @@ -0,0 +1,19 @@ + + + + + + new (Population) + + + + +
# File lib/libgenetics.rb, line 132
+  def initialize(population_size, genome_length)
+    @individuals = []
+    1.upto(population_size) { @individuals << Genome.new(genome_length) }
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000009.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000009.html.svn-base new file mode 100644 index 0000000..396d200 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000009.html.svn-base @@ -0,0 +1,31 @@ + + + + + + crossover (Population) + + + + +
# File lib/libgenetics.rb, line 138
+  def crossover(crossover_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 1
+      parent1 = parents.delete_at(rand(parents.length))
+      parent2 = parents.delete_at(rand(parents.length))
+      if rand < crossover_rate        
+        child1, child2 = parent1.crossover parent2, rand(parent1.genome.length)
+        next_population.individuals << child1 << child2
+      else
+        next_population.individuals << parent1 << parent2
+      end
+    end
+    next_population += parents # pick up any parents that didn't get a chance to mate
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000010.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000010.html.svn-base new file mode 100644 index 0000000..9808fa0 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000010.html.svn-base @@ -0,0 +1,25 @@ + + + + + + mutation (Population) + + + + +
# File lib/libgenetics.rb, line 156
+  def mutation(mutation_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 0
+      parent = parents.pop
+      child = parent.mutate mutation_rate
+      next_population.individuals << child
+    end
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000011.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000011.html.svn-base new file mode 100644 index 0000000..4549c43 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000011.html.svn-base @@ -0,0 +1,20 @@ + + + + + + make_next_generation (Population) + + + + +
# File lib/libgenetics.rb, line 167
+  def make_next_generation(tournament_winner_success_rate = 0.8, game_length = 1000, crossover_rate = 0.7, mutation_rate = 0.05)
+    @individuals = tournament_select_population(tournament_winner_success_rate, game_length, true)
+    @individuals = crossover(crossover_rate)
+    @individuals = mutation(mutation_rate)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000016.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000016.html.svn-base new file mode 100644 index 0000000..d380a46 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000016.html.svn-base @@ -0,0 +1,31 @@ + + + + + + tournament_select_one (Population) + + + + +
# File src/selection.rb, line 19
+  def tournament_select_one(winner_success_chance = 0.8, max_game_length= 1000, verbose = false)
+    player_count = rand(5) + 2
+    pool_size = @individuals.length
+    players = []
+    1.upto(player_count) { players << @individuals[rand(pool_size)].to_potential_player }
+    game = GameHandler.new(players, max_game_length, false, false)
+    winner, length = game.play
+    puts "Winner = #{winner} in #{length} moves.  Game had #{player_count} players" if verbose
+    # If the game was a draw, or the winner is unlucky, pick a parent at random
+    if winner == :draw or rand > winner_success_chance
+      successful_player = players[rand(player_count)]
+    else
+      successful_player = winner
+    end
+    successful_player
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000017.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000017.html.svn-base new file mode 100644 index 0000000..d3937be --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000017.html.svn-base @@ -0,0 +1,23 @@ + + + + + + tournament_select_population (Population) + + + + +
# File src/selection.rb, line 37
+  def tournament_select_population(winner_success_chance = 0.8, max_game_length = 1000, verbose = false)
+    new_population = []
+    1.upto(@individuals.length) do
+      new_population << tournament_select_one(winner_success_chance, max_game_length, verbose).to_genome
+      puts "Created #{new_population.length} indivduals" if verbose
+    end
+    new_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000018.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000018.html.svn-base new file mode 100644 index 0000000..e71f4ce --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000018.html.svn-base @@ -0,0 +1,19 @@ + + + + + + new (Population) + + + + +
# File lib/libgenetics.rb, line 135
+  def initialize(population_size, genome_length)
+    @individuals = []
+    1.upto(population_size) { @individuals << Genome.new(genome_length) }
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000019.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000019.html.svn-base new file mode 100644 index 0000000..788ef32 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000019.html.svn-base @@ -0,0 +1,31 @@ + + + + + + crossover (Population) + + + + +
# File lib/libgenetics.rb, line 141
+  def crossover(crossover_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 1
+      parent1 = parents.delete_at(rand(parents.length))
+      parent2 = parents.delete_at(rand(parents.length))
+      if rand < crossover_rate        
+        child1, child2 = parent1.crossover parent2, rand(parent1.genome.length)
+        next_population.individuals << child1 << child2
+      else
+        next_population.individuals << parent1 << parent2
+      end
+    end
+    next_population += parents # pick up any parents that didn't get a chance to mate
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000020.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000020.html.svn-base new file mode 100644 index 0000000..c30e82e --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000020.html.svn-base @@ -0,0 +1,25 @@ + + + + + + mutation (Population) + + + + +
# File lib/libgenetics.rb, line 159
+  def mutation(mutation_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 0
+      parent = parents.pop
+      child = parent.mutate mutation_rate
+      next_population.individuals << child
+    end
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000021.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000021.html.svn-base new file mode 100644 index 0000000..61ae6a8 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000021.html.svn-base @@ -0,0 +1,20 @@ + + + + + + make_next_generation (Population) + + + + +
# File lib/libgenetics.rb, line 170
+  def make_next_generation(tournament_winner_success_rate = 0.8, game_length = 1000, crossover_rate = 0.7, mutation_rate = 0.05)
+    @individuals = tournament_select_population(tournament_winner_success_rate, game_length, true)
+    @individuals = crossover(crossover_rate)
+    @individuals = mutation(mutation_rate)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000028.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000028.html.svn-base new file mode 100644 index 0000000..0a99dd6 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000028.html.svn-base @@ -0,0 +1,19 @@ + + + + + + new (Population) + + + + +
# File lib/libgenetics.rb, line 71
+  def initialize(population_size, genome_length)
+    @individuals = []
+    1.upto(population_size) { |i| @individuals << Genome.new(genome_length) }
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000029.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000029.html.svn-base new file mode 100644 index 0000000..89714e1 --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000029.html.svn-base @@ -0,0 +1,31 @@ + + + + + + crossover (Population) + + + + +
# File lib/libgenetics.rb, line 77
+  def crossover(crossover_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 1
+      parent1 = parents.delete_at(rand(parents.length))
+      parent2 = parents.delete_at(rand(parents.length))
+      if rand < crossover_rate        
+        child1, child2 = parent1.crossover parent2, rand(parent1.genome.length)
+        next_population.individuals << child1 << child2
+      else
+        next_population.individuals << parent1 << parent2
+      end
+    end
+    next_population += parents # pick up any parents that didn't get a chance to mate
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/.svn/text-base/M000030.html.svn-base b/doc/classes/Population.src/.svn/text-base/M000030.html.svn-base new file mode 100644 index 0000000..24a12cc --- /dev/null +++ b/doc/classes/Population.src/.svn/text-base/M000030.html.svn-base @@ -0,0 +1,25 @@ + + + + + + mutation (Population) + + + + +
# File lib/libgenetics.rb, line 95
+  def mutation(mutation_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 0
+      parent = parents.pop
+      child = parent.mutate mutation_rate
+      next_population.individuals << child
+    end
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000008.html b/doc/classes/Population.src/M000008.html new file mode 100644 index 0000000..4b69fc7 --- /dev/null +++ b/doc/classes/Population.src/M000008.html @@ -0,0 +1,19 @@ + + + + + + new (Population) + + + + +
# File lib/libgenetics.rb, line 132
+  def initialize(population_size, genome_length)
+    @individuals = []
+    1.upto(population_size) { @individuals << Genome.new(genome_length) }
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000009.html b/doc/classes/Population.src/M000009.html new file mode 100644 index 0000000..396d200 --- /dev/null +++ b/doc/classes/Population.src/M000009.html @@ -0,0 +1,31 @@ + + + + + + crossover (Population) + + + + +
# File lib/libgenetics.rb, line 138
+  def crossover(crossover_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 1
+      parent1 = parents.delete_at(rand(parents.length))
+      parent2 = parents.delete_at(rand(parents.length))
+      if rand < crossover_rate        
+        child1, child2 = parent1.crossover parent2, rand(parent1.genome.length)
+        next_population.individuals << child1 << child2
+      else
+        next_population.individuals << parent1 << parent2
+      end
+    end
+    next_population += parents # pick up any parents that didn't get a chance to mate
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000010.html b/doc/classes/Population.src/M000010.html new file mode 100644 index 0000000..9808fa0 --- /dev/null +++ b/doc/classes/Population.src/M000010.html @@ -0,0 +1,25 @@ + + + + + + mutation (Population) + + + + +
# File lib/libgenetics.rb, line 156
+  def mutation(mutation_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 0
+      parent = parents.pop
+      child = parent.mutate mutation_rate
+      next_population.individuals << child
+    end
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000011.html b/doc/classes/Population.src/M000011.html new file mode 100644 index 0000000..4549c43 --- /dev/null +++ b/doc/classes/Population.src/M000011.html @@ -0,0 +1,20 @@ + + + + + + make_next_generation (Population) + + + + +
# File lib/libgenetics.rb, line 167
+  def make_next_generation(tournament_winner_success_rate = 0.8, game_length = 1000, crossover_rate = 0.7, mutation_rate = 0.05)
+    @individuals = tournament_select_population(tournament_winner_success_rate, game_length, true)
+    @individuals = crossover(crossover_rate)
+    @individuals = mutation(mutation_rate)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000016.html b/doc/classes/Population.src/M000016.html new file mode 100644 index 0000000..d380a46 --- /dev/null +++ b/doc/classes/Population.src/M000016.html @@ -0,0 +1,31 @@ + + + + + + tournament_select_one (Population) + + + + +
# File src/selection.rb, line 19
+  def tournament_select_one(winner_success_chance = 0.8, max_game_length= 1000, verbose = false)
+    player_count = rand(5) + 2
+    pool_size = @individuals.length
+    players = []
+    1.upto(player_count) { players << @individuals[rand(pool_size)].to_potential_player }
+    game = GameHandler.new(players, max_game_length, false, false)
+    winner, length = game.play
+    puts "Winner = #{winner} in #{length} moves.  Game had #{player_count} players" if verbose
+    # If the game was a draw, or the winner is unlucky, pick a parent at random
+    if winner == :draw or rand > winner_success_chance
+      successful_player = players[rand(player_count)]
+    else
+      successful_player = winner
+    end
+    successful_player
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000017.html b/doc/classes/Population.src/M000017.html new file mode 100644 index 0000000..d3937be --- /dev/null +++ b/doc/classes/Population.src/M000017.html @@ -0,0 +1,23 @@ + + + + + + tournament_select_population (Population) + + + + +
# File src/selection.rb, line 37
+  def tournament_select_population(winner_success_chance = 0.8, max_game_length = 1000, verbose = false)
+    new_population = []
+    1.upto(@individuals.length) do
+      new_population << tournament_select_one(winner_success_chance, max_game_length, verbose).to_genome
+      puts "Created #{new_population.length} indivduals" if verbose
+    end
+    new_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000018.html b/doc/classes/Population.src/M000018.html new file mode 100644 index 0000000..e71f4ce --- /dev/null +++ b/doc/classes/Population.src/M000018.html @@ -0,0 +1,19 @@ + + + + + + new (Population) + + + + +
# File lib/libgenetics.rb, line 135
+  def initialize(population_size, genome_length)
+    @individuals = []
+    1.upto(population_size) { @individuals << Genome.new(genome_length) }
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000019.html b/doc/classes/Population.src/M000019.html new file mode 100644 index 0000000..788ef32 --- /dev/null +++ b/doc/classes/Population.src/M000019.html @@ -0,0 +1,31 @@ + + + + + + crossover (Population) + + + + +
# File lib/libgenetics.rb, line 141
+  def crossover(crossover_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 1
+      parent1 = parents.delete_at(rand(parents.length))
+      parent2 = parents.delete_at(rand(parents.length))
+      if rand < crossover_rate        
+        child1, child2 = parent1.crossover parent2, rand(parent1.genome.length)
+        next_population.individuals << child1 << child2
+      else
+        next_population.individuals << parent1 << parent2
+      end
+    end
+    next_population += parents # pick up any parents that didn't get a chance to mate
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000020.html b/doc/classes/Population.src/M000020.html new file mode 100644 index 0000000..c30e82e --- /dev/null +++ b/doc/classes/Population.src/M000020.html @@ -0,0 +1,25 @@ + + + + + + mutation (Population) + + + + +
# File lib/libgenetics.rb, line 159
+  def mutation(mutation_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 0
+      parent = parents.pop
+      child = parent.mutate mutation_rate
+      next_population.individuals << child
+    end
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000021.html b/doc/classes/Population.src/M000021.html new file mode 100644 index 0000000..61ae6a8 --- /dev/null +++ b/doc/classes/Population.src/M000021.html @@ -0,0 +1,20 @@ + + + + + + make_next_generation (Population) + + + + +
# File lib/libgenetics.rb, line 170
+  def make_next_generation(tournament_winner_success_rate = 0.8, game_length = 1000, crossover_rate = 0.7, mutation_rate = 0.05)
+    @individuals = tournament_select_population(tournament_winner_success_rate, game_length, true)
+    @individuals = crossover(crossover_rate)
+    @individuals = mutation(mutation_rate)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000028.html b/doc/classes/Population.src/M000028.html new file mode 100644 index 0000000..0a99dd6 --- /dev/null +++ b/doc/classes/Population.src/M000028.html @@ -0,0 +1,19 @@ + + + + + + new (Population) + + + + +
# File lib/libgenetics.rb, line 71
+  def initialize(population_size, genome_length)
+    @individuals = []
+    1.upto(population_size) { |i| @individuals << Genome.new(genome_length) }
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000029.html b/doc/classes/Population.src/M000029.html new file mode 100644 index 0000000..89714e1 --- /dev/null +++ b/doc/classes/Population.src/M000029.html @@ -0,0 +1,31 @@ + + + + + + crossover (Population) + + + + +
# File lib/libgenetics.rb, line 77
+  def crossover(crossover_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 1
+      parent1 = parents.delete_at(rand(parents.length))
+      parent2 = parents.delete_at(rand(parents.length))
+      if rand < crossover_rate        
+        child1, child2 = parent1.crossover parent2, rand(parent1.genome.length)
+        next_population.individuals << child1 << child2
+      else
+        next_population.individuals << parent1 << parent2
+      end
+    end
+    next_population += parents # pick up any parents that didn't get a chance to mate
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Population.src/M000030.html b/doc/classes/Population.src/M000030.html new file mode 100644 index 0000000..24a12cc --- /dev/null +++ b/doc/classes/Population.src/M000030.html @@ -0,0 +1,25 @@ + + + + + + mutation (Population) + + + + +
# File lib/libgenetics.rb, line 95
+  def mutation(mutation_rate)
+    parents = @individuals.dup # genomes that haven't been parents yet
+    next_population = Population.new(0)
+    while parents.length > 0
+      parent = parents.pop
+      child = parent.mutate mutation_rate
+      next_population.individuals << child
+    end
+    next_population
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.html b/doc/classes/Position.html new file mode 100644 index 0000000..02b8993 --- /dev/null +++ b/doc/classes/Position.html @@ -0,0 +1,235 @@ + + + + + + Class: Position + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassPosition
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Each possible position for a piece is an object Each neighbour is another +position object +

+ +
+ + +
+ +
+

Methods

+ +
+ base?   + new   + safe?   + to_s   + to_str   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + +
contains [RW] 
neighbours [RW] 
place [R] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+

+Is this position a base? +

+
+
+ +
+ + + + +
+

+is this position a safety one (i.e. no captures allowed)? +

+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/all-wcprops b/doc/classes/Position.src/.svn/all-wcprops new file mode 100644 index 0000000..f110c9f --- /dev/null +++ b/doc/classes/Position.src/.svn/all-wcprops @@ -0,0 +1,71 @@ +K 25 +svn:wc:ra_dav:version-url +V 63 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Position.src +END +M000010.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Position.src/M000010.html +END +M000011.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Position.src/M000011.html +END +M000003.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Position.src/M000003.html +END +M000012.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Position.src/M000012.html +END +M000004.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/Position.src/M000004.html +END +M000013.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Position.src/M000013.html +END +M000005.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Position.src/M000005.html +END +M000014.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Position.src/M000014.html +END +M000006.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Position.src/M000006.html +END +M000007.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Position.src/M000007.html +END +M000008.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/Position.src/M000008.html +END diff --git a/doc/classes/Position.src/.svn/entries b/doc/classes/Position.src/.svn/entries new file mode 100644 index 0000000..6ee756d --- /dev/null +++ b/doc/classes/Position.src/.svn/entries @@ -0,0 +1,155 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Position.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000010.html +file + + + + +2008-03-28T15:44:41.000000Z +70bbe77b1e8ace7c866fe9b5db57a559 +2008-10-16T14:11:23.436422Z +41 + +M000011.html +file + + + + +2008-03-28T15:44:41.000000Z +bdb4b68377c7f4ed4048ebc837e76472 +2008-10-16T14:11:23.436422Z +41 + +M000003.html +file + + + + +2008-03-25T12:43:37.000000Z +70bbe77b1e8ace7c866fe9b5db57a559 +2008-03-28T15:47:09.723420Z +24 +neil + +M000012.html +file + + + + +2008-03-28T15:44:41.000000Z +57b4a841f7c5d2c5c7fbc362d11b70b6 +2008-10-16T14:11:23.436422Z +41 + +M000004.html +file + + + + +2008-03-25T12:43:37.000000Z +bdb4b68377c7f4ed4048ebc837e76472 +2008-03-28T15:47:09.723420Z +24 +neil + +M000013.html +file + + + + +2008-03-28T15:44:41.000000Z +482e56a988543978f1551b1868c81181 +2008-10-16T14:11:23.436422Z +41 + +M000005.html +file + + + + +2008-03-25T12:43:37.000000Z +57b4a841f7c5d2c5c7fbc362d11b70b6 +2008-03-25T12:46:59.166018Z +23 +neil + +M000014.html +file + + + + +2008-03-28T15:44:41.000000Z +cddafce3ea25a58f5cf35d0b83ada3d3 +2008-10-16T14:11:23.436422Z +41 + +M000006.html +file + + + + +2008-03-25T12:43:37.000000Z +482e56a988543978f1551b1868c81181 +2008-03-25T12:46:59.166018Z +23 +neil + +M000007.html +file + + + + +2008-03-25T11:47:59.000000Z +6b16c6742da639f2a0350d0e63709fc2 +2008-03-25T12:46:59.166018Z +23 +neil + +M000008.html +file + + + + +2008-03-25T11:47:59.000000Z +a44d46d097ae553026b55ebff05e41e3 +2008-03-25T12:46:59.166018Z +23 +neil + diff --git a/doc/classes/Position.src/.svn/format b/doc/classes/Position.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Position.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Position.src/.svn/text-base/M000003.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000003.html.svn-base new file mode 100644 index 0000000..1c2d469 --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000003.html.svn-base @@ -0,0 +1,21 @@ + + + + + + new (Position) + + + + +
# File lib/libttc.rb, line 56
+  def initialize(place, safety, base)
+    @place = place
+    @safe = safety
+    @base = base
+    @neighbours = Array.new
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000004.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000004.html.svn-base new file mode 100644 index 0000000..b10934e --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000004.html.svn-base @@ -0,0 +1,18 @@ + + + + + + safe? (Position) + + + + +
# File lib/libttc.rb, line 64
+  def safe?
+    @safe
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000005.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000005.html.svn-base new file mode 100644 index 0000000..8e40e9b --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000005.html.svn-base @@ -0,0 +1,18 @@ + + + + + + base? (Position) + + + + +
# File lib/libttc.rb, line 69
+  def base?
+    @base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000006.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000006.html.svn-base new file mode 100644 index 0000000..447a70b --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000006.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Position) + + + + +
# File lib/libttc.rb, line 73
+  def to_s
+    @place
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000007.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000007.html.svn-base new file mode 100644 index 0000000..0dc6e10 --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000007.html.svn-base @@ -0,0 +1,18 @@ + + + + + + base? (Position) + + + + +
# File lib/libttc.rb, line 61
+  def base?
+    @base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000008.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000008.html.svn-base new file mode 100644 index 0000000..e39467f --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000008.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Position) + + + + +
# File lib/libttc.rb, line 65
+  def to_s
+    @place
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000010.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000010.html.svn-base new file mode 100644 index 0000000..1c2d469 --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000010.html.svn-base @@ -0,0 +1,21 @@ + + + + + + new (Position) + + + + +
# File lib/libttc.rb, line 56
+  def initialize(place, safety, base)
+    @place = place
+    @safe = safety
+    @base = base
+    @neighbours = Array.new
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000011.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000011.html.svn-base new file mode 100644 index 0000000..b10934e --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000011.html.svn-base @@ -0,0 +1,18 @@ + + + + + + safe? (Position) + + + + +
# File lib/libttc.rb, line 64
+  def safe?
+    @safe
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000012.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000012.html.svn-base new file mode 100644 index 0000000..8e40e9b --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000012.html.svn-base @@ -0,0 +1,18 @@ + + + + + + base? (Position) + + + + +
# File lib/libttc.rb, line 69
+  def base?
+    @base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000013.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000013.html.svn-base new file mode 100644 index 0000000..447a70b --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000013.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_s (Position) + + + + +
# File lib/libttc.rb, line 73
+  def to_s
+    @place
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/.svn/text-base/M000014.html.svn-base b/doc/classes/Position.src/.svn/text-base/M000014.html.svn-base new file mode 100644 index 0000000..af5af32 --- /dev/null +++ b/doc/classes/Position.src/.svn/text-base/M000014.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_str (Position) + + + + +
# File lib/libttc.rb, line 77
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000003.html b/doc/classes/Position.src/M000003.html new file mode 100644 index 0000000..1c2d469 --- /dev/null +++ b/doc/classes/Position.src/M000003.html @@ -0,0 +1,21 @@ + + + + + + new (Position) + + + + +
# File lib/libttc.rb, line 56
+  def initialize(place, safety, base)
+    @place = place
+    @safe = safety
+    @base = base
+    @neighbours = Array.new
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000004.html b/doc/classes/Position.src/M000004.html new file mode 100644 index 0000000..b10934e --- /dev/null +++ b/doc/classes/Position.src/M000004.html @@ -0,0 +1,18 @@ + + + + + + safe? (Position) + + + + +
# File lib/libttc.rb, line 64
+  def safe?
+    @safe
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000005.html b/doc/classes/Position.src/M000005.html new file mode 100644 index 0000000..8e40e9b --- /dev/null +++ b/doc/classes/Position.src/M000005.html @@ -0,0 +1,18 @@ + + + + + + base? (Position) + + + + +
# File lib/libttc.rb, line 69
+  def base?
+    @base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000006.html b/doc/classes/Position.src/M000006.html new file mode 100644 index 0000000..447a70b --- /dev/null +++ b/doc/classes/Position.src/M000006.html @@ -0,0 +1,18 @@ + + + + + + to_s (Position) + + + + +
# File lib/libttc.rb, line 73
+  def to_s
+    @place
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000007.html b/doc/classes/Position.src/M000007.html new file mode 100644 index 0000000..0dc6e10 --- /dev/null +++ b/doc/classes/Position.src/M000007.html @@ -0,0 +1,18 @@ + + + + + + base? (Position) + + + + +
# File lib/libttc.rb, line 61
+  def base?
+    @base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000008.html b/doc/classes/Position.src/M000008.html new file mode 100644 index 0000000..e39467f --- /dev/null +++ b/doc/classes/Position.src/M000008.html @@ -0,0 +1,18 @@ + + + + + + to_s (Position) + + + + +
# File lib/libttc.rb, line 65
+  def to_s
+    @place
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000010.html b/doc/classes/Position.src/M000010.html new file mode 100644 index 0000000..1c2d469 --- /dev/null +++ b/doc/classes/Position.src/M000010.html @@ -0,0 +1,21 @@ + + + + + + new (Position) + + + + +
# File lib/libttc.rb, line 56
+  def initialize(place, safety, base)
+    @place = place
+    @safe = safety
+    @base = base
+    @neighbours = Array.new
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000011.html b/doc/classes/Position.src/M000011.html new file mode 100644 index 0000000..b10934e --- /dev/null +++ b/doc/classes/Position.src/M000011.html @@ -0,0 +1,18 @@ + + + + + + safe? (Position) + + + + +
# File lib/libttc.rb, line 64
+  def safe?
+    @safe
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000012.html b/doc/classes/Position.src/M000012.html new file mode 100644 index 0000000..8e40e9b --- /dev/null +++ b/doc/classes/Position.src/M000012.html @@ -0,0 +1,18 @@ + + + + + + base? (Position) + + + + +
# File lib/libttc.rb, line 69
+  def base?
+    @base
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000013.html b/doc/classes/Position.src/M000013.html new file mode 100644 index 0000000..447a70b --- /dev/null +++ b/doc/classes/Position.src/M000013.html @@ -0,0 +1,18 @@ + + + + + + to_s (Position) + + + + +
# File lib/libttc.rb, line 73
+  def to_s
+    @place
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Position.src/M000014.html b/doc/classes/Position.src/M000014.html new file mode 100644 index 0000000..af5af32 --- /dev/null +++ b/doc/classes/Position.src/M000014.html @@ -0,0 +1,18 @@ + + + + + + to_str (Position) + + + + +
# File lib/libttc.rb, line 77
+  def to_str
+    to_s
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.html b/doc/classes/Potential_player.html new file mode 100644 index 0000000..2940688 --- /dev/null +++ b/doc/classes/Potential_player.html @@ -0,0 +1,251 @@ + + + + + + Class: Potential_player + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassPotential_player
In: + + lib/libpplayer.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Play Trap the Cap by using potential fields. For each possible move, +calculate the field strength and pick the move with the lowest potential +

+ +
+ + +
+ +
+

Methods

+ +
+ best_move   + new   + score_position   + to_bitstring   + to_genome   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
base_pull [R] 
capture_bonus [R] 
enemy_pull [R] 
friend_pull [R] 
safe_bonus [R] 
+
+
+ + + + +
+

Public Class methods

+ + + +

Public Instance methods

+ +
+ + + + +
+

+Find the best move of the possible ones +

+
+
+ +
+ + + + +
+

+Calculate the potential score of a position for a given player +

+
+
+ +
+ + + + +
+

+Convert a player to a bitstring +

+
+
+ +
+ + + + +
+

+Convert a player to a genome +

+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/all-wcprops b/doc/classes/Potential_player.src/.svn/all-wcprops new file mode 100644 index 0000000..7725c7e --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/all-wcprops @@ -0,0 +1,59 @@ +K 25 +svn:wc:ra_dav:version-url +V 71 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src +END +M000010.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000010.html +END +M000002.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000002.html +END +M000003.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000003.html +END +M000004.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000004.html +END +M000005.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000005.html +END +M000006.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000006.html +END +M000007.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000007.html +END +M000008.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000008.html +END +M000009.html +K 25 +svn:wc:ra_dav:version-url +V 84 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/Potential_player.src/M000009.html +END diff --git a/doc/classes/Potential_player.src/.svn/entries b/doc/classes/Potential_player.src/.svn/entries new file mode 100644 index 0000000..c0e271a --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/entries @@ -0,0 +1,115 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/Potential_player.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +M000010.html +file + + + + +2008-04-23T19:33:07.000000Z +a17a65209784f73ce372eaae6630092a +2008-10-16T14:11:23.436422Z +41 + +M000002.html +file + + + + +2008-04-23T19:29:25.000000Z +149829f922648619748d7f4d1c2e7130 +2008-10-16T14:11:23.436422Z +41 + +M000003.html +file + + + + +2008-04-23T19:29:25.000000Z +9b5ecdecaf201d9385ecbdb3ed301b4f +2008-10-16T14:11:23.436422Z +41 + +M000004.html +file + + + + +2008-04-23T19:29:25.000000Z +f47f937d8af031514a674ff62bf37ee9 +2008-10-16T14:11:23.436422Z +41 + +M000005.html +file + + + + +2008-04-23T19:29:25.000000Z +735261c857222981035cc28ed6def8e9 +2008-10-16T14:11:23.436422Z +41 + +M000006.html +file + + + + +2008-04-23T19:33:07.000000Z +4b3dd51bded36491f7257ccf146416a7 +2008-10-16T14:11:23.436422Z +41 + +M000007.html +file + + + + +2008-04-23T19:33:07.000000Z +8f709c92f7983a517a5c0d2e3d324d50 +2008-10-16T14:11:23.436422Z +41 + +M000008.html +file + + + + +2008-04-23T19:33:07.000000Z +c730b64ee755a3435f822cd501cc7ab3 +2008-10-16T14:11:23.436422Z +41 + +M000009.html +file + + + + +2008-04-23T19:33:07.000000Z +4dd74593d118059f9479f6ae113748fc +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/Potential_player.src/.svn/format b/doc/classes/Potential_player.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000002.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000002.html.svn-base new file mode 100644 index 0000000..75451bc --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000002.html.svn-base @@ -0,0 +1,24 @@ + + + + + + new (Potential_player) + + + + +
# File lib/libpplayer.rb, line 20
+  def initialize(args, verbose = false)
+    @friend_pull   = args[:friend_pull]   || 1
+    @enemy_pull    = args[:enemy_pull]    || 0.5
+    @base_pull     = args[:base_pull]     || 2
+    @safe_bonus    = args[:safe_bonus]    || 8
+    @capture_bonus = args[:capture_bonus] || 10
+    
+    @verbose = verbose
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000003.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000003.html.svn-base new file mode 100644 index 0000000..95e682e --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000003.html.svn-base @@ -0,0 +1,33 @@ + + + + + + best_move (Potential_player) + + + + +
# File lib/libpplayer.rb, line 31
+  def best_move(game, die_result)
+    me = game.current_player
+    possible_moves = game.possible_moves(die_result, me)
+    scored_moves = possible_moves.collect do |m| 
+      begin
+        game.apply_move! m
+        score = score_position(game, me)
+#        game.undo_move!
+      rescue GameWonNotice
+        score = 10000
+      ensure
+        game.undo_move!
+      end 
+      puts "#{m} scores #{score}" if @verbose
+      [m, score]
+    end
+    best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0]
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000004.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000004.html.svn-base new file mode 100644 index 0000000..2558dbd --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000004.html.svn-base @@ -0,0 +1,36 @@ + + + + + + score_position (Potential_player) + + + + +
# File lib/libpplayer.rb, line 51
+  def score_position(game, player)
+    score = 0
+    game.pieces.each_value do |piece|
+      here = piece.position
+      if piece.colour == player
+        game.pieces.each_value do |other_piece|
+          if other_piece.colour == player
+            score += game.board.distance_between[here.place][other_piece.position.place] * @friend_pull
+          else
+            score += game.board.distance_between[here.place][other_piece.position.place] * @enemy_pull
+          end
+        end
+        score += piece.contains.length * @capture_bonus
+        score += game.board.distance_between[here.place][game.board.positions[player].place] * 
+        piece.contains.length * @base_pull
+      elsif here == game.board.positions[player]
+        score += @safe_bonus
+      end
+    end
+    score
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000005.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000005.html.svn-base new file mode 100644 index 0000000..8afdea7 --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000005.html.svn-base @@ -0,0 +1,22 @@ + + + + + + to_bitstring (Potential_player) + + + + +
# File lib/libpplayer.rb, line 75
+  def to_bitstring
+    (@friend_pull * 4).to_i.to_bitstring(4).gray_encode +
+      (@enemy_pull * 4).to_i.to_bitstring(4).gray_encode +
+      (@base_pull * 4).to_i.to_bitstring(4).gray_encode +
+      @safe_bonus.to_bitstring(4).gray_encode +
+      @capture_bonus.to_bitstring(4).gray_encode
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000006.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000006.html.svn-base new file mode 100644 index 0000000..c70badd --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000006.html.svn-base @@ -0,0 +1,24 @@ + + + + + + new (Potential_player) + + + + +
# File lib/libpplayer.rb, line 23
+  def initialize(args, verbose = false)
+    @friend_pull   = args[:friend_pull]   || 1
+    @enemy_pull    = args[:enemy_pull]    || 0.5
+    @base_pull     = args[:base_pull]     || 2
+    @safe_bonus    = args[:safe_bonus]    || 8
+    @capture_bonus = args[:capture_bonus] || 10
+    
+    @verbose = verbose
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000007.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000007.html.svn-base new file mode 100644 index 0000000..39eef10 --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000007.html.svn-base @@ -0,0 +1,33 @@ + + + + + + best_move (Potential_player) + + + + +
# File lib/libpplayer.rb, line 34
+  def best_move(game, die_result)
+    me = game.current_player
+    possible_moves = game.possible_moves(die_result, me)
+    scored_moves = possible_moves.collect do |m| 
+      begin
+        game.apply_move! m
+        score = score_position(game, me)
+#        game.undo_move!
+      rescue GameWonNotice
+        score = 10000
+      ensure
+        game.undo_move!
+      end 
+      puts "#{m} scores #{score}" if @verbose
+      [m, score]
+    end
+    best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0]
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000008.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000008.html.svn-base new file mode 100644 index 0000000..471952a --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000008.html.svn-base @@ -0,0 +1,36 @@ + + + + + + score_position (Potential_player) + + + + +
# File lib/libpplayer.rb, line 54
+  def score_position(game, player)
+    score = 0
+    game.pieces.each_value do |piece|
+      here = piece.position
+      if piece.colour == player
+        game.pieces.each_value do |other_piece|
+          if other_piece.colour == player
+            score += game.board.distance_between[here.place][other_piece.position.place] * @friend_pull
+          else
+            score += game.board.distance_between[here.place][other_piece.position.place] * @enemy_pull
+          end
+        end
+        score += piece.contains.length * @capture_bonus
+        score += game.board.distance_between[here.place][game.board.positions[player].place] * 
+        piece.contains.length * @base_pull
+      elsif here == game.board.positions[player]
+        score += @safe_bonus
+      end
+    end
+    score
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000009.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000009.html.svn-base new file mode 100644 index 0000000..f9f63d8 --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000009.html.svn-base @@ -0,0 +1,22 @@ + + + + + + to_bitstring (Potential_player) + + + + +
# File lib/libpplayer.rb, line 78
+  def to_bitstring
+    (@friend_pull * 4).to_i.to_bitstring(4).gray_encode +
+      (@enemy_pull * 4).to_i.to_bitstring(4).gray_encode +
+      (@base_pull * 4).to_i.to_bitstring(4).gray_encode +
+      @safe_bonus.to_bitstring(4).gray_encode +
+      @capture_bonus.to_bitstring(4).gray_encode
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/.svn/text-base/M000010.html.svn-base b/doc/classes/Potential_player.src/.svn/text-base/M000010.html.svn-base new file mode 100644 index 0000000..240325e --- /dev/null +++ b/doc/classes/Potential_player.src/.svn/text-base/M000010.html.svn-base @@ -0,0 +1,18 @@ + + + + + + to_genome (Potential_player) + + + + +
# File lib/libpplayer.rb, line 87
+  def to_genome
+    Genome.new(self.to_bitstring)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000002.html b/doc/classes/Potential_player.src/M000002.html new file mode 100644 index 0000000..75451bc --- /dev/null +++ b/doc/classes/Potential_player.src/M000002.html @@ -0,0 +1,24 @@ + + + + + + new (Potential_player) + + + + +
# File lib/libpplayer.rb, line 20
+  def initialize(args, verbose = false)
+    @friend_pull   = args[:friend_pull]   || 1
+    @enemy_pull    = args[:enemy_pull]    || 0.5
+    @base_pull     = args[:base_pull]     || 2
+    @safe_bonus    = args[:safe_bonus]    || 8
+    @capture_bonus = args[:capture_bonus] || 10
+    
+    @verbose = verbose
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000003.html b/doc/classes/Potential_player.src/M000003.html new file mode 100644 index 0000000..95e682e --- /dev/null +++ b/doc/classes/Potential_player.src/M000003.html @@ -0,0 +1,33 @@ + + + + + + best_move (Potential_player) + + + + +
# File lib/libpplayer.rb, line 31
+  def best_move(game, die_result)
+    me = game.current_player
+    possible_moves = game.possible_moves(die_result, me)
+    scored_moves = possible_moves.collect do |m| 
+      begin
+        game.apply_move! m
+        score = score_position(game, me)
+#        game.undo_move!
+      rescue GameWonNotice
+        score = 10000
+      ensure
+        game.undo_move!
+      end 
+      puts "#{m} scores #{score}" if @verbose
+      [m, score]
+    end
+    best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0]
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000004.html b/doc/classes/Potential_player.src/M000004.html new file mode 100644 index 0000000..2558dbd --- /dev/null +++ b/doc/classes/Potential_player.src/M000004.html @@ -0,0 +1,36 @@ + + + + + + score_position (Potential_player) + + + + +
# File lib/libpplayer.rb, line 51
+  def score_position(game, player)
+    score = 0
+    game.pieces.each_value do |piece|
+      here = piece.position
+      if piece.colour == player
+        game.pieces.each_value do |other_piece|
+          if other_piece.colour == player
+            score += game.board.distance_between[here.place][other_piece.position.place] * @friend_pull
+          else
+            score += game.board.distance_between[here.place][other_piece.position.place] * @enemy_pull
+          end
+        end
+        score += piece.contains.length * @capture_bonus
+        score += game.board.distance_between[here.place][game.board.positions[player].place] * 
+        piece.contains.length * @base_pull
+      elsif here == game.board.positions[player]
+        score += @safe_bonus
+      end
+    end
+    score
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000005.html b/doc/classes/Potential_player.src/M000005.html new file mode 100644 index 0000000..8afdea7 --- /dev/null +++ b/doc/classes/Potential_player.src/M000005.html @@ -0,0 +1,22 @@ + + + + + + to_bitstring (Potential_player) + + + + +
# File lib/libpplayer.rb, line 75
+  def to_bitstring
+    (@friend_pull * 4).to_i.to_bitstring(4).gray_encode +
+      (@enemy_pull * 4).to_i.to_bitstring(4).gray_encode +
+      (@base_pull * 4).to_i.to_bitstring(4).gray_encode +
+      @safe_bonus.to_bitstring(4).gray_encode +
+      @capture_bonus.to_bitstring(4).gray_encode
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000006.html b/doc/classes/Potential_player.src/M000006.html new file mode 100644 index 0000000..c70badd --- /dev/null +++ b/doc/classes/Potential_player.src/M000006.html @@ -0,0 +1,24 @@ + + + + + + new (Potential_player) + + + + +
# File lib/libpplayer.rb, line 23
+  def initialize(args, verbose = false)
+    @friend_pull   = args[:friend_pull]   || 1
+    @enemy_pull    = args[:enemy_pull]    || 0.5
+    @base_pull     = args[:base_pull]     || 2
+    @safe_bonus    = args[:safe_bonus]    || 8
+    @capture_bonus = args[:capture_bonus] || 10
+    
+    @verbose = verbose
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000007.html b/doc/classes/Potential_player.src/M000007.html new file mode 100644 index 0000000..39eef10 --- /dev/null +++ b/doc/classes/Potential_player.src/M000007.html @@ -0,0 +1,33 @@ + + + + + + best_move (Potential_player) + + + + +
# File lib/libpplayer.rb, line 34
+  def best_move(game, die_result)
+    me = game.current_player
+    possible_moves = game.possible_moves(die_result, me)
+    scored_moves = possible_moves.collect do |m| 
+      begin
+        game.apply_move! m
+        score = score_position(game, me)
+#        game.undo_move!
+      rescue GameWonNotice
+        score = 10000
+      ensure
+        game.undo_move!
+      end 
+      puts "#{m} scores #{score}" if @verbose
+      [m, score]
+    end
+    best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0]
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000008.html b/doc/classes/Potential_player.src/M000008.html new file mode 100644 index 0000000..471952a --- /dev/null +++ b/doc/classes/Potential_player.src/M000008.html @@ -0,0 +1,36 @@ + + + + + + score_position (Potential_player) + + + + +
# File lib/libpplayer.rb, line 54
+  def score_position(game, player)
+    score = 0
+    game.pieces.each_value do |piece|
+      here = piece.position
+      if piece.colour == player
+        game.pieces.each_value do |other_piece|
+          if other_piece.colour == player
+            score += game.board.distance_between[here.place][other_piece.position.place] * @friend_pull
+          else
+            score += game.board.distance_between[here.place][other_piece.position.place] * @enemy_pull
+          end
+        end
+        score += piece.contains.length * @capture_bonus
+        score += game.board.distance_between[here.place][game.board.positions[player].place] * 
+        piece.contains.length * @base_pull
+      elsif here == game.board.positions[player]
+        score += @safe_bonus
+      end
+    end
+    score
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000009.html b/doc/classes/Potential_player.src/M000009.html new file mode 100644 index 0000000..f9f63d8 --- /dev/null +++ b/doc/classes/Potential_player.src/M000009.html @@ -0,0 +1,22 @@ + + + + + + to_bitstring (Potential_player) + + + + +
# File lib/libpplayer.rb, line 78
+  def to_bitstring
+    (@friend_pull * 4).to_i.to_bitstring(4).gray_encode +
+      (@enemy_pull * 4).to_i.to_bitstring(4).gray_encode +
+      (@base_pull * 4).to_i.to_bitstring(4).gray_encode +
+      @safe_bonus.to_bitstring(4).gray_encode +
+      @capture_bonus.to_bitstring(4).gray_encode
+  end
+ + \ No newline at end of file diff --git a/doc/classes/Potential_player.src/M000010.html b/doc/classes/Potential_player.src/M000010.html new file mode 100644 index 0000000..240325e --- /dev/null +++ b/doc/classes/Potential_player.src/M000010.html @@ -0,0 +1,18 @@ + + + + + + to_genome (Potential_player) + + + + +
# File lib/libpplayer.rb, line 87
+  def to_genome
+    Genome.new(self.to_bitstring)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/String.html b/doc/classes/String.html new file mode 100644 index 0000000..ea7c8cc --- /dev/null +++ b/doc/classes/String.html @@ -0,0 +1,145 @@ + + + + + + Class: String + + + + + + + + + + +
+ + + + + + + + + + + + + + +
ClassString
In: + + lib/libttc.rb + +
+
Parent: + Object +
+
+ + +
+ + + +
+ +
+

+Extension to String class to convert a +move-description string into a Move object. This is +the inverse of the Move#to_s method +

+ +
+ + +
+ +
+

Methods

+ +
+ to_move   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ +
+ + + + +
+
+
+ + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/classes/String.src/.svn/all-wcprops b/doc/classes/String.src/.svn/all-wcprops new file mode 100644 index 0000000..d83d449 --- /dev/null +++ b/doc/classes/String.src/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/String.src +END +M000023.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/doc/classes/String.src/M000023.html +END +M000033.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/classes/String.src/M000033.html +END +M000053.html +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/classes/String.src/M000053.html +END diff --git a/doc/classes/String.src/.svn/entries b/doc/classes/String.src/.svn/entries new file mode 100644 index 0000000..0928d54 --- /dev/null +++ b/doc/classes/String.src/.svn/entries @@ -0,0 +1,63 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/classes/String.src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +M000023.html +file + + + + +2008-03-25T12:43:37.000000Z +5379a14f8396caafa9cc2b9efeec7c6f +2008-03-28T15:47:09.723420Z +24 +neil + +M000033.html +file + + + + +2008-03-25T11:48:00.000000Z +cd7c03584fe23acc665ee89ef6a37f4c +2008-03-25T12:46:59.166018Z +23 +neil + +M000053.html +file + + + + +2008-03-28T15:44:42.000000Z +4f1fed17fd24df46a33ecd6aaba77c43 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/classes/String.src/.svn/format b/doc/classes/String.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/classes/String.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/classes/String.src/.svn/text-base/M000023.html.svn-base b/doc/classes/String.src/.svn/text-base/M000023.html.svn-base new file mode 100644 index 0000000..0dd82bc --- /dev/null +++ b/doc/classes/String.src/.svn/text-base/M000023.html.svn-base @@ -0,0 +1,29 @@ + + + + + + to_move (String) + + + + +
# File lib/libttc.rb, line 513
+  def to_move(game)
+    move_elements = self.downcase.split
+    piece_name = move_elements[0]
+    destination_name = move_elements[-1]
+    if destination_name.length > 2 and 
+        destination_name[-2,2] == game.board.centre.place[-2,2]
+      destination_name = game.board.centre.place
+    end
+    raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name)
+    raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name)
+    # Deal with the synonyms for the centre position
+    via_base = (destination_name.length == 1 or move_elements.length > 2)
+    Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/String.src/.svn/text-base/M000033.html.svn-base b/doc/classes/String.src/.svn/text-base/M000033.html.svn-base new file mode 100644 index 0000000..cb5d59b --- /dev/null +++ b/doc/classes/String.src/.svn/text-base/M000033.html.svn-base @@ -0,0 +1,29 @@ + + + + + + to_move (String) + + + + +
# File lib/libttc.rb, line 495
+  def to_move(game)
+    move_elements = self.downcase.split
+    piece_name = move_elements[0]
+    destination_name = move_elements[-1]
+    if destination_name.length > 2 and 
+        destination_name[-2,2] == game.board.centre.place[-2,2]
+      destination_name = game.board.centre.place
+    end
+    raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name)
+    raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name)
+    # Deal with the synonyms for the centre position
+    via_base = (destination_name.length == 1 or move_elements.length > 2)
+    Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/String.src/.svn/text-base/M000053.html.svn-base b/doc/classes/String.src/.svn/text-base/M000053.html.svn-base new file mode 100644 index 0000000..5c8ce89 --- /dev/null +++ b/doc/classes/String.src/.svn/text-base/M000053.html.svn-base @@ -0,0 +1,29 @@ + + + + + + to_move (String) + + + + +
# File lib/libttc.rb, line 591
+  def to_move(game)
+    move_elements = self.downcase.split
+    piece_name = move_elements[0]
+    destination_name = move_elements[-1]
+    if destination_name.length > 2 and 
+        destination_name[-2,2] == game.board.centre.place[-2,2]
+      destination_name = game.board.centre.place
+    end
+    raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name)
+    raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name)
+    # Deal with the synonyms for the centre position
+    via_base = (destination_name.length == 1 or move_elements.length > 2)
+    Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/String.src/M000023.html b/doc/classes/String.src/M000023.html new file mode 100644 index 0000000..0dd82bc --- /dev/null +++ b/doc/classes/String.src/M000023.html @@ -0,0 +1,29 @@ + + + + + + to_move (String) + + + + +
# File lib/libttc.rb, line 513
+  def to_move(game)
+    move_elements = self.downcase.split
+    piece_name = move_elements[0]
+    destination_name = move_elements[-1]
+    if destination_name.length > 2 and 
+        destination_name[-2,2] == game.board.centre.place[-2,2]
+      destination_name = game.board.centre.place
+    end
+    raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name)
+    raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name)
+    # Deal with the synonyms for the centre position
+    via_base = (destination_name.length == 1 or move_elements.length > 2)
+    Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/String.src/M000033.html b/doc/classes/String.src/M000033.html new file mode 100644 index 0000000..cb5d59b --- /dev/null +++ b/doc/classes/String.src/M000033.html @@ -0,0 +1,29 @@ + + + + + + to_move (String) + + + + +
# File lib/libttc.rb, line 495
+  def to_move(game)
+    move_elements = self.downcase.split
+    piece_name = move_elements[0]
+    destination_name = move_elements[-1]
+    if destination_name.length > 2 and 
+        destination_name[-2,2] == game.board.centre.place[-2,2]
+      destination_name = game.board.centre.place
+    end
+    raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name)
+    raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name)
+    # Deal with the synonyms for the centre position
+    via_base = (destination_name.length == 1 or move_elements.length > 2)
+    Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base)
+  end
+ + \ No newline at end of file diff --git a/doc/classes/String.src/M000053.html b/doc/classes/String.src/M000053.html new file mode 100644 index 0000000..5c8ce89 --- /dev/null +++ b/doc/classes/String.src/M000053.html @@ -0,0 +1,29 @@ + + + + + + to_move (String) + + + + +
# File lib/libttc.rb, line 591
+  def to_move(game)
+    move_elements = self.downcase.split
+    piece_name = move_elements[0]
+    destination_name = move_elements[-1]
+    if destination_name.length > 2 and 
+        destination_name[-2,2] == game.board.centre.place[-2,2]
+      destination_name = game.board.centre.place
+    end
+    raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name)
+    raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name)
+    # Deal with the synonyms for the centre position
+    via_base = (destination_name.length == 1 or move_elements.length > 2)
+    Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base)
+  end
+ + \ No newline at end of file diff --git a/doc/created.rid b/doc/created.rid new file mode 100644 index 0000000..89e065f --- /dev/null +++ b/doc/created.rid @@ -0,0 +1 @@ +Wed, 23 Apr 2008 20:33:07 +0100 diff --git a/doc/files/.svn/all-wcprops b/doc/files/.svn/all-wcprops new file mode 100644 index 0000000..6a762f7 --- /dev/null +++ b/doc/files/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files +END +main_rb.html +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/main_rb.html +END diff --git a/doc/files/.svn/entries b/doc/files/.svn/entries new file mode 100644 index 0000000..95727b7 --- /dev/null +++ b/doc/files/.svn/entries @@ -0,0 +1,48 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/files +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +test +dir + +lib +dir + +src +dir + +main_rb.html +file + + + + +2008-04-23T19:12:55.000000Z +8533a2e395b529f6f6cffea4bca55f81 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/files/.svn/format b/doc/files/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/files/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/files/.svn/text-base/main_rb.html.svn-base b/doc/files/.svn/text-base/main_rb.html.svn-base new file mode 100644 index 0000000..1977f74 --- /dev/null +++ b/doc/files/.svn/text-base/main_rb.html.svn-base @@ -0,0 +1,109 @@ + + + + + + File: main.rb + + + + + + + + + + +
+

main.rb

+ + + + + + + + + +
Path:main.rb +
Last Update:Fri Apr 18 16:35:11 +0100 2008
+
+ + +
+ + + +
+ + +
+

Required files

+ +
+ src/play   + src/selection   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/lib/.svn/all-wcprops b/doc/files/lib/.svn/all-wcprops new file mode 100644 index 0000000..eaa8eb7 --- /dev/null +++ b/doc/files/lib/.svn/all-wcprops @@ -0,0 +1,29 @@ +K 25 +svn:wc:ra_dav:version-url +V 52 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/lib +END +libttc_rb.html +K 25 +svn:wc:ra_dav:version-url +V 67 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/lib/libttc_rb.html +END +libpplayer_rb.html +K 25 +svn:wc:ra_dav:version-url +V 71 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/lib/libpplayer_rb.html +END +main_rb.html +K 25 +svn:wc:ra_dav:version-url +V 65 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/lib/main_rb.html +END +libgenetics_rb.html +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/lib/libgenetics_rb.html +END diff --git a/doc/files/lib/.svn/entries b/doc/files/lib/.svn/entries new file mode 100644 index 0000000..f702220 --- /dev/null +++ b/doc/files/lib/.svn/entries @@ -0,0 +1,74 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/files/lib +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +libttc_rb.html +file + + + + +2008-03-28T15:44:42.000000Z +2c89b18d16593fd3d4929dde5513b80b +2008-10-16T14:11:23.436422Z +41 +neil + +libpplayer_rb.html +file + + + + +2008-04-23T19:33:08.000000Z +f3cb337746afa0964b387d117dc9fc52 +2008-10-16T14:11:23.436422Z +41 + +main_rb.html +file + + + + +2008-03-25T11:48:00.000000Z +a162380b5d5bb9335017066ddb06016a +2008-03-25T12:46:59.166018Z +23 +neil + +libgenetics_rb.html +file + + + + +2008-04-23T19:33:08.000000Z +f7083efb84c5691d9f45473ff09c2f77 +2008-10-16T14:11:23.436422Z +41 + diff --git a/doc/files/lib/.svn/format b/doc/files/lib/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/files/lib/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/files/lib/.svn/text-base/libgenetics_rb.html.svn-base b/doc/files/lib/.svn/text-base/libgenetics_rb.html.svn-base new file mode 100644 index 0000000..5fe1efb --- /dev/null +++ b/doc/files/lib/.svn/text-base/libgenetics_rb.html.svn-base @@ -0,0 +1,118 @@ + + + + + + File: libgenetics.rb + + + + + + + + + + +
+

libgenetics.rb

+ + + + + + + + + +
Path:lib/libgenetics.rb +
Last Update:Wed Apr 23 20:32:33 +0100 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Library to support genetic algorithms +

+

Author

+

+Neil Smith +

+

Change history

+ + +
Version 1.1:23 April 2008 + +
+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/lib/.svn/text-base/libpplayer_rb.html.svn-base b/doc/files/lib/.svn/text-base/libpplayer_rb.html.svn-base new file mode 100644 index 0000000..e296c63 --- /dev/null +++ b/doc/files/lib/.svn/text-base/libpplayer_rb.html.svn-base @@ -0,0 +1,127 @@ + + + + + + File: libpplayer.rb + + + + + + + + + + +
+

libpplayer.rb

+ + + + + + + + + +
Path:lib/libpplayer.rb +
Last Update:Wed Apr 23 20:33:01 +0100 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Library to support a Trap the Cap player that uses potentials to select the +best move +

+

Author

+

+Neil Smith +

+

Change history

+ + +
Version 1.1:23 April 2008 + +
+ +
+ +
+

Required files

+ +
+ lib/libttc   + lib/libgenetics   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/lib/.svn/text-base/libttc_rb.html.svn-base b/doc/files/lib/.svn/text-base/libttc_rb.html.svn-base new file mode 100644 index 0000000..b1f7c88 --- /dev/null +++ b/doc/files/lib/.svn/text-base/libttc_rb.html.svn-base @@ -0,0 +1,165 @@ + + + + + + File: libttc.rb + + + + + + + + + + +
+

libttc.rb

+ + + + + + + + + +
Path:lib/libttc.rb +
Last Update:Thu Mar 27 16:06:40 +0000 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Library to support Trap the Cap play +

+

Author

+

+Neil Smith +

+

+This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) +any later version. +

+

+This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. +

+

+You should have received a copy of the GNU General Public License along +with this program. If not, see <www.gnu.org/licenses/>. +

+

Change history

+ + + + +
Version 1.1:07 Sep 2007 + +
    +
  • Changed format for showing moves via bases. + +
  • +
  • Raise error when moving via base without captured pieces + +
  • +
  • Raise error when moving onto a safe space with 3 or more pieces already +there + +
  • +
+
Version 1.2:10 Sep 2007 + + +
Version 1.3:25 Mar 2008 + +
    +
  • Fixed bug to detect a winner, and also eliminate players that have no +uncaptured pieces. + +
  • +
+
+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/lib/.svn/text-base/main_rb.html.svn-base b/doc/files/lib/.svn/text-base/main_rb.html.svn-base new file mode 100644 index 0000000..edd1339 --- /dev/null +++ b/doc/files/lib/.svn/text-base/main_rb.html.svn-base @@ -0,0 +1,108 @@ + + + + + + File: main.rb + + + + + + + + + + +
+

main.rb

+ + + + + + + + + +
Path:lib/main.rb +
Last Update:Tue Mar 25 11:38:01 +0000 2008
+
+ + +
+ + + +
+ +
+

+To change this template, choose Tools | Templates and open the template in +the editor. +

+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/lib/libgenetics_rb.html b/doc/files/lib/libgenetics_rb.html new file mode 100644 index 0000000..5fe1efb --- /dev/null +++ b/doc/files/lib/libgenetics_rb.html @@ -0,0 +1,118 @@ + + + + + + File: libgenetics.rb + + + + + + + + + + +
+

libgenetics.rb

+ + + + + + + + + +
Path:lib/libgenetics.rb +
Last Update:Wed Apr 23 20:32:33 +0100 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Library to support genetic algorithms +

+

Author

+

+Neil Smith +

+

Change history

+ + +
Version 1.1:23 April 2008 + +
+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/lib/libpplayer_rb.html b/doc/files/lib/libpplayer_rb.html new file mode 100644 index 0000000..e296c63 --- /dev/null +++ b/doc/files/lib/libpplayer_rb.html @@ -0,0 +1,127 @@ + + + + + + File: libpplayer.rb + + + + + + + + + + +
+

libpplayer.rb

+ + + + + + + + + +
Path:lib/libpplayer.rb +
Last Update:Wed Apr 23 20:33:01 +0100 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Library to support a Trap the Cap player that uses potentials to select the +best move +

+

Author

+

+Neil Smith +

+

Change history

+ + +
Version 1.1:23 April 2008 + +
+ +
+ +
+

Required files

+ +
+ lib/libttc   + lib/libgenetics   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/lib/libttc_rb.html b/doc/files/lib/libttc_rb.html new file mode 100644 index 0000000..b1f7c88 --- /dev/null +++ b/doc/files/lib/libttc_rb.html @@ -0,0 +1,165 @@ + + + + + + File: libttc.rb + + + + + + + + + + +
+

libttc.rb

+ + + + + + + + + +
Path:lib/libttc.rb +
Last Update:Thu Mar 27 16:06:40 +0000 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Library to support Trap the Cap play +

+

Author

+

+Neil Smith +

+

+This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) +any later version. +

+

+This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. +

+

+You should have received a copy of the GNU General Public License along +with this program. If not, see <www.gnu.org/licenses/>. +

+

Change history

+ + + + +
Version 1.1:07 Sep 2007 + +
    +
  • Changed format for showing moves via bases. + +
  • +
  • Raise error when moving via base without captured pieces + +
  • +
  • Raise error when moving onto a safe space with 3 or more pieces already +there + +
  • +
+
Version 1.2:10 Sep 2007 + + +
Version 1.3:25 Mar 2008 + +
    +
  • Fixed bug to detect a winner, and also eliminate players that have no +uncaptured pieces. + +
  • +
+
+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/lib/main_rb.html b/doc/files/lib/main_rb.html new file mode 100644 index 0000000..edd1339 --- /dev/null +++ b/doc/files/lib/main_rb.html @@ -0,0 +1,108 @@ + + + + + + File: main.rb + + + + + + + + + + +
+

main.rb

+ + + + + + + + + +
Path:lib/main.rb +
Last Update:Tue Mar 25 11:38:01 +0000 2008
+
+ + +
+ + + +
+ +
+

+To change this template, choose Tools | Templates and open the template in +the editor. +

+ +
+ + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/main_rb.html b/doc/files/main_rb.html new file mode 100644 index 0000000..1977f74 --- /dev/null +++ b/doc/files/main_rb.html @@ -0,0 +1,109 @@ + + + + + + File: main.rb + + + + + + + + + + +
+

main.rb

+ + + + + + + + + +
Path:main.rb +
Last Update:Fri Apr 18 16:35:11 +0100 2008
+
+ + +
+ + + +
+ + +
+

Required files

+ +
+ src/play   + src/selection   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/.svn/all-wcprops b/doc/files/src/.svn/all-wcprops new file mode 100644 index 0000000..9862770 --- /dev/null +++ b/doc/files/src/.svn/all-wcprops @@ -0,0 +1,35 @@ +K 25 +svn:wc:ra_dav:version-url +V 52 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/src +END +ttc_rb.html +K 25 +svn:wc:ra_dav:version-url +V 64 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/src/ttc_rb.html +END +clockwise-p1_rb.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/src/clockwise-p1_rb.html +END +play_rb.html +K 25 +svn:wc:ra_dav:version-url +V 65 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/src/play_rb.html +END +selection_rb.html +K 25 +svn:wc:ra_dav:version-url +V 70 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/src/selection_rb.html +END +clockwise-cloud_rb.html +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/src/clockwise-cloud_rb.html +END diff --git a/doc/files/src/.svn/entries b/doc/files/src/.svn/entries new file mode 100644 index 0000000..3e64c38 --- /dev/null +++ b/doc/files/src/.svn/entries @@ -0,0 +1,92 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/files/src +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +clockwise-cloud_rb.src +dir + +ttc_rb.html +file + + + + +2008-03-25T11:48:00.000000Z +cfdcf2338281c75233dd289ff30a6f6d +2008-03-25T12:46:59.166018Z +23 +neil + +clockwise-p1_rb.html +file + + + + +2008-03-25T11:48:00.000000Z +7cff2abe6c45d314ada57ad526923065 +2008-03-25T12:46:59.166018Z +23 +neil + +clockwise-p1_rb.src +dir + +play_rb.html +file + + + + +2008-04-23T19:33:07.000000Z +84c21cf0058efa8f08e5f5deafa5f649 +2008-10-16T14:11:23.436422Z +41 + +selection_rb.html +file + + + + +2008-04-23T19:33:08.000000Z +89fe891785af82f906da594cc0fe7566 +2008-10-16T14:11:23.436422Z +41 + +clockwise-cloud_rb.html +file + + + + +2008-03-25T11:48:00.000000Z +84d08f5c1677571581fe800b6b074b25 +2008-03-25T12:46:59.166018Z +23 +neil + diff --git a/doc/files/src/.svn/format b/doc/files/src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/files/src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/files/src/.svn/text-base/clockwise-cloud_rb.html.svn-base b/doc/files/src/.svn/text-base/clockwise-cloud_rb.html.svn-base new file mode 100644 index 0000000..8b416a5 --- /dev/null +++ b/doc/files/src/.svn/text-base/clockwise-cloud_rb.html.svn-base @@ -0,0 +1,170 @@ + + + + + + File: clockwise-cloud.rb + + + + + + + + + + +
+

clockwise-cloud.rb

+ + + + + + + + + +
Path:src/clockwise-cloud.rb +
Last Update:Fri Aug 31 20:04:34 +0100 2007
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Play one move of a Trap the Cap game +

+

Usage

+

+clockwise-p1 +

+
+ Game state file read on STDIN
+ Move produced on STDOUT
+
+

Author

+

+Neil Smith +

+

+This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) +any later version. +

+

+This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. +

+

+You should have received a copy of the GNU General Public License along +with this program. If not, see <www.gnu.org/licenses/>. +

+ +
+ +
+

Required files

+ +
+ libttc   +
+
+ +
+ +
+

Methods

+ +
+ more_clockwise   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ + + + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/.svn/text-base/clockwise-p1_rb.html.svn-base b/doc/files/src/.svn/text-base/clockwise-p1_rb.html.svn-base new file mode 100644 index 0000000..6e5729b --- /dev/null +++ b/doc/files/src/.svn/text-base/clockwise-p1_rb.html.svn-base @@ -0,0 +1,154 @@ + + + + + + File: clockwise-p1.rb + + + + + + + + + + +
+

clockwise-p1.rb

+ + + + + + + + + +
Path:src/clockwise-p1.rb +
Last Update:Fri Aug 31 12:19:53 +0100 2007
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Play one move of a Trap the Cap game +

+

Usage

+

+clockwise-p1 +

+
+ Game state file read on STDIN
+ Move produced on STDOUT
+
+

Author

+

+Neil Smith +

+ +
+ +
+

Required files

+ +
+ libttc   + rdoc/usage   +
+
+ +
+ +
+

Methods

+ +
+ more_clockwise   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ + + + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/.svn/text-base/play_rb.html.svn-base b/doc/files/src/.svn/text-base/play_rb.html.svn-base new file mode 100644 index 0000000..27c3639 --- /dev/null +++ b/doc/files/src/.svn/text-base/play_rb.html.svn-base @@ -0,0 +1,126 @@ + + + + + + File: play.rb + + + + + + + + + + +
+

play.rb

+ + + + + + + + + +
Path:src/play.rb +
Last Update:Wed Apr 23 20:32:54 +0100 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Play a game of Trap the Cap. +

+

Author

+

+Neil Smith +

+

Change history

+ + +
Version 1.1:23 April 2008 + +
+ +
+ +
+

Required files

+ +
+ lib/libttc   + lib/libpplayer   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/.svn/text-base/selection_rb.html.svn-base b/doc/files/src/.svn/text-base/selection_rb.html.svn-base new file mode 100644 index 0000000..3add792 --- /dev/null +++ b/doc/files/src/.svn/text-base/selection_rb.html.svn-base @@ -0,0 +1,128 @@ + + + + + + File: selection.rb + + + + + + + + + + +
+

selection.rb

+ + + + + + + + + +
Path:src/selection.rb +
Last Update:Wed Apr 23 20:32:29 +0100 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Use a GA to breed a good potential player +

+

Author

+

+Neil Smith +

+

Change history

+ + +
Version 1.1:23 April 2008 + +
+ +
+ +
+

Required files

+ +
+ lib/libttc   + lib/libpplayer   + lib/libgenetics   + src/play   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/.svn/text-base/ttc_rb.html.svn-base b/doc/files/src/.svn/text-base/ttc_rb.html.svn-base new file mode 100644 index 0000000..cdb1269 --- /dev/null +++ b/doc/files/src/.svn/text-base/ttc_rb.html.svn-base @@ -0,0 +1,127 @@ + + + + + + File: ttc.rb + + + + + + + + + + +
+

ttc.rb

+ + + + + + + + + +
Path:src/ttc.rb +
Last Update:Tue Mar 25 11:46:58 +0000 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Play one move of a Trap the Cap game +

+

Usage

+

+ttc [ -b | —board-size SIZE ] [ -i | —input FILE ] [ -r | +—robot ROBOT ] [ -h | —help ] +

+

Author

+

+Neil Smith +

+ +
+ +
+

Required files

+ +
+ open3   + timeout   + optparse   + rdoc/usage   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/clockwise-cloud_rb.html b/doc/files/src/clockwise-cloud_rb.html new file mode 100644 index 0000000..8b416a5 --- /dev/null +++ b/doc/files/src/clockwise-cloud_rb.html @@ -0,0 +1,170 @@ + + + + + + File: clockwise-cloud.rb + + + + + + + + + + +
+

clockwise-cloud.rb

+ + + + + + + + + +
Path:src/clockwise-cloud.rb +
Last Update:Fri Aug 31 20:04:34 +0100 2007
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Play one move of a Trap the Cap game +

+

Usage

+

+clockwise-p1 +

+
+ Game state file read on STDIN
+ Move produced on STDOUT
+
+

Author

+

+Neil Smith +

+

+This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) +any later version. +

+

+This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. +

+

+You should have received a copy of the GNU General Public License along +with this program. If not, see <www.gnu.org/licenses/>. +

+ +
+ +
+

Required files

+ +
+ libttc   +
+
+ +
+ +
+

Methods

+ +
+ more_clockwise   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ + + + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/clockwise-cloud_rb.src/.svn/all-wcprops b/doc/files/src/clockwise-cloud_rb.src/.svn/all-wcprops new file mode 100644 index 0000000..9fd92ad --- /dev/null +++ b/doc/files/src/clockwise-cloud_rb.src/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 75 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/src/clockwise-cloud_rb.src +END +M000001.html +K 25 +svn:wc:ra_dav:version-url +V 88 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/src/clockwise-cloud_rb.src/M000001.html +END diff --git a/doc/files/src/clockwise-cloud_rb.src/.svn/entries b/doc/files/src/clockwise-cloud_rb.src/.svn/entries new file mode 100644 index 0000000..1fa1703 --- /dev/null +++ b/doc/files/src/clockwise-cloud_rb.src/.svn/entries @@ -0,0 +1,28 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/files/src/clockwise-cloud_rb.src +http://scripts.njae.me.uk/svn/njae + + + +2008-03-25T12:46:59.166018Z +23 +neil + + +svn:special svn:externals svn:needs-lock + +M000001.html +file + + + + +2008-03-25T11:47:59.000000Z +fad522266e3a910a73d91411620f5ae9 +2008-03-25T12:46:59.166018Z +23 +neil + diff --git a/doc/files/src/clockwise-cloud_rb.src/.svn/format b/doc/files/src/clockwise-cloud_rb.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/files/src/clockwise-cloud_rb.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/files/src/clockwise-cloud_rb.src/.svn/text-base/M000001.html.svn-base b/doc/files/src/clockwise-cloud_rb.src/.svn/text-base/M000001.html.svn-base new file mode 100644 index 0000000..0328a09 --- /dev/null +++ b/doc/files/src/clockwise-cloud_rb.src/.svn/text-base/M000001.html.svn-base @@ -0,0 +1,41 @@ + + + + + + more_clockwise (src/clockwise-cloud.rb) + + + + +
# File src/clockwise-cloud.rb, line 31
+def more_clockwise(this, other)
+  here = this.place
+  there = other.place
+  
+  # if both are on a spoke, choose the one with the lowest number (nearer the rim)
+  if here =~ /.c./ and there =~ /.c./
+    # break ties by preferring the most clockwise arc
+    if here[-1] == there[-1]
+      return here[0] <=> there[0]
+    else
+      return -1 * (here[-1] <=> there[-1])
+    end
+    # If one is one a spoke and the other is on the rim, choose the one on the rim
+  elsif here =~ /.c./ or there =~ /.c./
+    return -1 * (here.length <=> there.length)
+    # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a'
+  elsif here[0,1] == 'a' and there[0,1] == 'f'
+    return +1
+  elsif here[0,1] == 'f' and there[0,1] == 'a'
+    return -1
+    # Otherwise, choose the one with highest arc code
+  else
+    return here <=> there
+  end
+  
+end
+ + \ No newline at end of file diff --git a/doc/files/src/clockwise-cloud_rb.src/M000001.html b/doc/files/src/clockwise-cloud_rb.src/M000001.html new file mode 100644 index 0000000..0328a09 --- /dev/null +++ b/doc/files/src/clockwise-cloud_rb.src/M000001.html @@ -0,0 +1,41 @@ + + + + + + more_clockwise (src/clockwise-cloud.rb) + + + + +
# File src/clockwise-cloud.rb, line 31
+def more_clockwise(this, other)
+  here = this.place
+  there = other.place
+  
+  # if both are on a spoke, choose the one with the lowest number (nearer the rim)
+  if here =~ /.c./ and there =~ /.c./
+    # break ties by preferring the most clockwise arc
+    if here[-1] == there[-1]
+      return here[0] <=> there[0]
+    else
+      return -1 * (here[-1] <=> there[-1])
+    end
+    # If one is one a spoke and the other is on the rim, choose the one on the rim
+  elsif here =~ /.c./ or there =~ /.c./
+    return -1 * (here.length <=> there.length)
+    # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a'
+  elsif here[0,1] == 'a' and there[0,1] == 'f'
+    return +1
+  elsif here[0,1] == 'f' and there[0,1] == 'a'
+    return -1
+    # Otherwise, choose the one with highest arc code
+  else
+    return here <=> there
+  end
+  
+end
+ + \ No newline at end of file diff --git a/doc/files/src/clockwise-p1_rb.html b/doc/files/src/clockwise-p1_rb.html new file mode 100644 index 0000000..6e5729b --- /dev/null +++ b/doc/files/src/clockwise-p1_rb.html @@ -0,0 +1,154 @@ + + + + + + File: clockwise-p1.rb + + + + + + + + + + +
+

clockwise-p1.rb

+ + + + + + + + + +
Path:src/clockwise-p1.rb +
Last Update:Fri Aug 31 12:19:53 +0100 2007
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Play one move of a Trap the Cap game +

+

Usage

+

+clockwise-p1 +

+
+ Game state file read on STDIN
+ Move produced on STDOUT
+
+

Author

+

+Neil Smith +

+ +
+ +
+

Required files

+ +
+ libttc   + rdoc/usage   +
+
+ +
+ +
+

Methods

+ +
+ more_clockwise   +
+
+ +
+ + + + +
+ + + + + + + + + +
+

Public Instance methods

+ + + + +
+ + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/clockwise-p1_rb.src/.svn/all-wcprops b/doc/files/src/clockwise-p1_rb.src/.svn/all-wcprops new file mode 100644 index 0000000..08c3dce --- /dev/null +++ b/doc/files/src/clockwise-p1_rb.src/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/src/clockwise-p1_rb.src +END +M000002.html +K 25 +svn:wc:ra_dav:version-url +V 85 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/src/clockwise-p1_rb.src/M000002.html +END diff --git a/doc/files/src/clockwise-p1_rb.src/.svn/entries b/doc/files/src/clockwise-p1_rb.src/.svn/entries new file mode 100644 index 0000000..1f202d7 --- /dev/null +++ b/doc/files/src/clockwise-p1_rb.src/.svn/entries @@ -0,0 +1,28 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/files/src/clockwise-p1_rb.src +http://scripts.njae.me.uk/svn/njae + + + +2008-03-25T12:46:59.166018Z +23 +neil + + +svn:special svn:externals svn:needs-lock + +M000002.html +file + + + + +2008-03-25T11:47:59.000000Z +a06f76e237cec1ce328cc97a5084e027 +2008-03-25T12:46:59.166018Z +23 +neil + diff --git a/doc/files/src/clockwise-p1_rb.src/.svn/format b/doc/files/src/clockwise-p1_rb.src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/files/src/clockwise-p1_rb.src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/files/src/clockwise-p1_rb.src/.svn/text-base/M000002.html.svn-base b/doc/files/src/clockwise-p1_rb.src/.svn/text-base/M000002.html.svn-base new file mode 100644 index 0000000..89f6822 --- /dev/null +++ b/doc/files/src/clockwise-p1_rb.src/.svn/text-base/M000002.html.svn-base @@ -0,0 +1,41 @@ + + + + + + more_clockwise (src/clockwise-p1.rb) + + + + +
# File src/clockwise-p1.rb, line 19
+def more_clockwise(this, other)
+  here = this.destination.place
+  there = other.destination.place
+  
+  # if both are on a spoke, choose the one with the lowest number (nearer the rim)
+  if here =~ /.c./ and there =~ /.c./
+    # break ties by preferring the most clockwise arc
+    if here[-1] == there[-1]
+      return here[0] <=> there[0]
+    else
+      return -1 * (here[-1] <=> there[-1])
+    end
+    # If one is one a spoke and the other is on the rim, choose the one on the rim
+  elsif here =~ /.c./ or there =~ /.c./
+    return -1 * (here.length <=> there.length)
+    # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a'
+  elsif here[0,1] == 'a' and there[0,1] == 'f'
+    return +1
+  elsif here[0,1] == 'f' and there[0,1] == 'a'
+    return -1
+    # Otherwise, choose the one with highest arc code
+  else
+    return here <=> there
+  end
+  
+end
+ + \ No newline at end of file diff --git a/doc/files/src/clockwise-p1_rb.src/M000002.html b/doc/files/src/clockwise-p1_rb.src/M000002.html new file mode 100644 index 0000000..89f6822 --- /dev/null +++ b/doc/files/src/clockwise-p1_rb.src/M000002.html @@ -0,0 +1,41 @@ + + + + + + more_clockwise (src/clockwise-p1.rb) + + + + +
# File src/clockwise-p1.rb, line 19
+def more_clockwise(this, other)
+  here = this.destination.place
+  there = other.destination.place
+  
+  # if both are on a spoke, choose the one with the lowest number (nearer the rim)
+  if here =~ /.c./ and there =~ /.c./
+    # break ties by preferring the most clockwise arc
+    if here[-1] == there[-1]
+      return here[0] <=> there[0]
+    else
+      return -1 * (here[-1] <=> there[-1])
+    end
+    # If one is one a spoke and the other is on the rim, choose the one on the rim
+  elsif here =~ /.c./ or there =~ /.c./
+    return -1 * (here.length <=> there.length)
+    # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a'
+  elsif here[0,1] == 'a' and there[0,1] == 'f'
+    return +1
+  elsif here[0,1] == 'f' and there[0,1] == 'a'
+    return -1
+    # Otherwise, choose the one with highest arc code
+  else
+    return here <=> there
+  end
+  
+end
+ + \ No newline at end of file diff --git a/doc/files/src/play_rb.html b/doc/files/src/play_rb.html new file mode 100644 index 0000000..27c3639 --- /dev/null +++ b/doc/files/src/play_rb.html @@ -0,0 +1,126 @@ + + + + + + File: play.rb + + + + + + + + + + +
+

play.rb

+ + + + + + + + + +
Path:src/play.rb +
Last Update:Wed Apr 23 20:32:54 +0100 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Play a game of Trap the Cap. +

+

Author

+

+Neil Smith +

+

Change history

+ + +
Version 1.1:23 April 2008 + +
+ +
+ +
+

Required files

+ +
+ lib/libttc   + lib/libpplayer   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/selection_rb.html b/doc/files/src/selection_rb.html new file mode 100644 index 0000000..3add792 --- /dev/null +++ b/doc/files/src/selection_rb.html @@ -0,0 +1,128 @@ + + + + + + File: selection.rb + + + + + + + + + + +
+

selection.rb

+ + + + + + + + + +
Path:src/selection.rb +
Last Update:Wed Apr 23 20:32:29 +0100 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Use a GA to breed a good potential player +

+

Author

+

+Neil Smith +

+

Change history

+ + +
Version 1.1:23 April 2008 + +
+ +
+ +
+

Required files

+ +
+ lib/libttc   + lib/libpplayer   + lib/libgenetics   + src/play   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/src/ttc_rb.html b/doc/files/src/ttc_rb.html new file mode 100644 index 0000000..cdb1269 --- /dev/null +++ b/doc/files/src/ttc_rb.html @@ -0,0 +1,127 @@ + + + + + + File: ttc.rb + + + + + + + + + + +
+

ttc.rb

+ + + + + + + + + +
Path:src/ttc.rb +
Last Update:Tue Mar 25 11:46:58 +0000 2008
+
+ + +
+ + + +
+ +
+

Synopsis

+

+Play one move of a Trap the Cap game +

+

Usage

+

+ttc [ -b | —board-size SIZE ] [ -i | —input FILE ] [ -r | +—robot ROBOT ] [ -h | —help ] +

+

Author

+

+Neil Smith +

+ +
+ +
+

Required files

+ +
+ open3   + timeout   + optparse   + rdoc/usage   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/test/.svn/all-wcprops b/doc/files/test/.svn/all-wcprops new file mode 100644 index 0000000..dd8d75c --- /dev/null +++ b/doc/files/test/.svn/all-wcprops @@ -0,0 +1,17 @@ +K 25 +svn:wc:ra_dav:version-url +V 53 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/test +END +libttc_test_rb.html +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/doc/files/test/libttc_test_rb.html +END +game-test_rb.html +K 25 +svn:wc:ra_dav:version-url +V 71 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/doc/files/test/game-test_rb.html +END diff --git a/doc/files/test/.svn/entries b/doc/files/test/.svn/entries new file mode 100644 index 0000000..49d6419 --- /dev/null +++ b/doc/files/test/.svn/entries @@ -0,0 +1,51 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/doc/files/test +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +libttc_test_rb.html +file + + + + +2008-03-28T15:44:42.000000Z +b48377e2e4dc19c1515aff86b65339d7 +2008-10-16T14:11:23.436422Z +41 + +game-test_rb.html +file + + + + +2008-03-25T11:48:00.000000Z +614083683ed97a5066c4af451fd873d7 +2008-03-25T12:46:59.166018Z +23 +neil + diff --git a/doc/files/test/.svn/format b/doc/files/test/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/doc/files/test/.svn/format @@ -0,0 +1 @@ +8 diff --git a/doc/files/test/.svn/text-base/game-test_rb.html.svn-base b/doc/files/test/.svn/text-base/game-test_rb.html.svn-base new file mode 100644 index 0000000..7fd7a4c --- /dev/null +++ b/doc/files/test/.svn/text-base/game-test_rb.html.svn-base @@ -0,0 +1,114 @@ + + + + + + File: game-test.rb + + + + + + + + + + +
+

game-test.rb

+ + + + + + + + + +
Path:test/game-test.rb +
Last Update:Thu Aug 09 14:55:47 +0100 2007
+
+ + +
+ + + +
+ +
+

+test/game_test.rb +

+ +
+ +
+

Required files

+ +
+ test/unit   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/test/.svn/text-base/libttc_test_rb.html.svn-base b/doc/files/test/.svn/text-base/libttc_test_rb.html.svn-base new file mode 100644 index 0000000..5c6c0a6 --- /dev/null +++ b/doc/files/test/.svn/text-base/libttc_test_rb.html.svn-base @@ -0,0 +1,114 @@ + + + + + + File: libttc_test.rb + + + + + + + + + + +
+

libttc_test.rb

+ + + + + + + + + +
Path:test/libttc_test.rb +
Last Update:Wed Mar 26 13:52:59 +0000 2008
+
+ + +
+ + + +
+ +
+

+test/game_test.rb +

+ +
+ +
+

Required files

+ +
+ test/unit   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/test/game-test_rb.html b/doc/files/test/game-test_rb.html new file mode 100644 index 0000000..7fd7a4c --- /dev/null +++ b/doc/files/test/game-test_rb.html @@ -0,0 +1,114 @@ + + + + + + File: game-test.rb + + + + + + + + + + +
+

game-test.rb

+ + + + + + + + + +
Path:test/game-test.rb +
Last Update:Thu Aug 09 14:55:47 +0100 2007
+
+ + +
+ + + +
+ +
+

+test/game_test.rb +

+ +
+ +
+

Required files

+ +
+ test/unit   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/files/test/libttc_test_rb.html b/doc/files/test/libttc_test_rb.html new file mode 100644 index 0000000..5c6c0a6 --- /dev/null +++ b/doc/files/test/libttc_test_rb.html @@ -0,0 +1,114 @@ + + + + + + File: libttc_test.rb + + + + + + + + + + +
+

libttc_test.rb

+ + + + + + + + + +
Path:test/libttc_test.rb +
Last Update:Wed Mar 26 13:52:59 +0000 2008
+
+ + +
+ + + +
+ +
+

+test/game_test.rb +

+ +
+ +
+

Required files

+ +
+ test/unit   +
+
+ +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+

[Validate]

+
+ + + \ No newline at end of file diff --git a/doc/fr_class_index.html b/doc/fr_class_index.html new file mode 100644 index 0000000..386985b --- /dev/null +++ b/doc/fr_class_index.html @@ -0,0 +1,32 @@ + + + + + + + + Classes + + + + + +
+

Classes

+ +
+ + \ No newline at end of file diff --git a/doc/fr_file_index.html b/doc/fr_file_index.html new file mode 100644 index 0000000..1521d1c --- /dev/null +++ b/doc/fr_file_index.html @@ -0,0 +1,30 @@ + + + + + + + + Files + + + + + +
+

Files

+ +
+ + \ No newline at end of file diff --git a/doc/fr_method_index.html b/doc/fr_method_index.html new file mode 100644 index 0000000..d9c748a --- /dev/null +++ b/doc/fr_method_index.html @@ -0,0 +1,48 @@ + + + + + + + + Methods + + + + + +
+

Methods

+ +
+ + \ No newline at end of file diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..e3c61b6 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,24 @@ + + + + + + + RDoc Documentation + + + + + + + + + + + \ No newline at end of file diff --git a/doc/rdoc-style.css b/doc/rdoc-style.css new file mode 100644 index 0000000..44c7b3d --- /dev/null +++ b/doc/rdoc-style.css @@ -0,0 +1,208 @@ + +body { + font-family: Verdana,Arial,Helvetica,sans-serif; + font-size: 90%; + margin: 0; + margin-left: 40px; + padding: 0; + background: white; +} + +h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; } +h1 { font-size: 150%; } +h2,h3,h4 { margin-top: 1em; } + +a { background: #eef; color: #039; text-decoration: none; } +a:hover { background: #039; color: #eef; } + +/* Override the base stylesheet's Anchor inside a table cell */ +td > a { + background: transparent; + color: #039; + text-decoration: none; +} + +/* and inside a section title */ +.section-title > a { + background: transparent; + color: #eee; + text-decoration: none; +} + +/* === Structural elements =================================== */ + +div#index { + margin: 0; + margin-left: -40px; + padding: 0; + font-size: 90%; +} + + +div#index a { + margin-left: 0.7em; +} + +div#index .section-bar { + margin-left: 0px; + padding-left: 0.7em; + background: #ccc; + font-size: small; +} + + +div#classHeader, div#fileHeader { + width: auto; + color: white; + padding: 0.5em 1.5em 0.5em 1.5em; + margin: 0; + margin-left: -40px; + border-bottom: 3px solid #006; +} + +div#classHeader a, div#fileHeader a { + background: inherit; + color: white; +} + +div#classHeader td, div#fileHeader td { + background: inherit; + color: white; +} + + +div#fileHeader { + background: #057; +} + +div#classHeader { + background: #048; +} + + +.class-name-in-header { + font-size: 180%; + font-weight: bold; +} + + +div#bodyContent { + padding: 0 1.5em 0 1.5em; +} + +div#description { + padding: 0.5em 1.5em; + background: #efefef; + border: 1px dotted #999; +} + +div#description h1,h2,h3,h4,h5,h6 { + color: #125;; + background: transparent; +} + +div#validator-badges { + text-align: center; +} +div#validator-badges img { border: 0; } + +div#copyright { + color: #333; + background: #efefef; + font: 0.75em sans-serif; + margin-top: 5em; + margin-bottom: 0; + padding: 0.5em 2em; +} + + +/* === Classes =================================== */ + +table.header-table { + color: white; + font-size: small; +} + +.type-note { + font-size: small; + color: #DEDEDE; +} + +.xxsection-bar { + background: #eee; + color: #333; + padding: 3px; +} + +.section-bar { + color: #333; + border-bottom: 1px solid #999; + margin-left: -20px; +} + + +.section-title { + background: #79a; + color: #eee; + padding: 3px; + margin-top: 2em; + margin-left: -30px; + border: 1px solid #999; +} + +.top-aligned-row { vertical-align: top } +.bottom-aligned-row { vertical-align: bottom } + +/* --- Context section classes ----------------------- */ + +.context-row { } +.context-item-name { font-family: monospace; font-weight: bold; color: black; } +.context-item-value { font-size: small; color: #448; } +.context-item-desc { color: #333; padding-left: 2em; } + +/* --- Method classes -------------------------- */ +.method-detail { + background: #efefef; + padding: 0; + margin-top: 0.5em; + margin-bottom: 1em; + border: 1px dotted #ccc; +} +.method-heading { + color: black; + background: #ccc; + border-bottom: 1px solid #666; + padding: 0.2em 0.5em 0 0.5em; +} +.method-signature { color: black; background: inherit; } +.method-name { font-weight: bold; } +.method-args { font-style: italic; } +.method-description { padding: 0 0.5em 0 0.5em; } + +/* --- Source code sections -------------------- */ + +a.source-toggle { font-size: 90%; } +div.method-source-code { + background: #262626; + color: #ffdead; + margin: 1em; + padding: 0.5em; + border: 1px dashed #999; + overflow: hidden; +} + +div.method-source-code pre { color: #ffdead; overflow: hidden; } + +/* --- Ruby keyword styles --------------------- */ + +.standalone-code { background: #221111; color: #ffdead; overflow: hidden; } + +.ruby-constant { color: #7fffd4; background: transparent; } +.ruby-keyword { color: #00ffff; background: transparent; } +.ruby-ivar { color: #eedd82; background: transparent; } +.ruby-operator { color: #00ffee; background: transparent; } +.ruby-identifier { color: #ffdead; background: transparent; } +.ruby-node { color: #ffa07a; background: transparent; } +.ruby-comment { color: #b22222; font-weight: bold; background: transparent; } +.ruby-regexp { color: #ffa07a; background: transparent; } +.ruby-value { color: #7fffd4; background: transparent; } \ No newline at end of file diff --git a/ga-logs/gen-153.txt b/ga-logs/gen-153.txt new file mode 100644 index 0000000..b42fc92 --- /dev/null +++ b/ga-logs/gen-153.txt @@ -0,0 +1,402 @@ +Generation 153 +00000000000010000011 +00000000000010100011 +00000000000010000001 +00000000000010100011 +00000000000010000001 +00000000000011100001 +00000000000010000001 +00000000000010100011 +00000000000010010011 +00000000000010000011 +00000000000010110011 +00000000000010000001 +00000000000010000001 +00000000000010000001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010010010 +00000000000010000011 +00000000000010100001 +00000000000010110001 +00000000000010010011 +00000000000010110001 +00000000000010010010 +00000000000010000011 +00000000000010110011 +00000000000010110001 +00000000000010000011 +00000000000010100011 +00000000000010100011 +00000000000010010010 +00000000000010000011 +00000000000010010010 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010100011 +00000000000010100001 +00000000000010000011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010000011 +00000000000010110011 +00000000000010000001 +00000000000010000011 +00000000000010100001 +00000000000010000011 +00000000000010100011 +00000000000010100011 +00000000000010100001 +00000000000010100001 +00000000000010110011 +00000000000010000001 +00000000000010000001 +00000000000010100001 +00000000000010110000 +00000000000010110011 +00000000000010000010 +00000000000010110011 +00000000000010000011 +00000000000010100011 +00000000000010000011 +00000000000010010011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010010010 +00000000000010010010 +00000000000010100001 +00000000000010100011 +00000000000010110010 +00000000000010100001 +00000000000010100011 +00000000000010000011 +00000000000010010011 +00000000000010000011 +00000000000010100001 +00000000000010100001 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010100011 +00000000000010000011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000010100001 +00000000000010100001 +00000000000010110001 +00000000000010100011 +00000000000010000011 +00000000000010110001 +00000000000010100011 +00000000000010000001 +00000000000010100011 +00000000000010100001 +00000000000010000011 +00000000000010110011 +00000000000010000011 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010000001 +00000000000010100001 +00000000000010110011 +00000000000010100001 +00000000000010000011 +00000000000010000011 +00000000000010110000 +00000000000010100001 +00000000000011100001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010000001 +00000000000010000001 +00000000000010100011 +00000000000010000001 +00000000000010110011 +00000000000010100001 +00000000000010000001 +00000000000010000001 +00000000000010000001 +00000000000010010001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010000001 +00000000000010000011 +00000000000010100011 +00000000000010110011 +00000000000010000001 +00000000000010110001 +00000000000010010001 +00000000000010010010 +00000000000010110011 +00000000000010000011 +00000000000010100011 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010000001 +00000000000010000011 +00000000000010100011 +00000000000010000001 +00000000000010000001 +00000000000010100001 +00000000000011110011 +00000000000010100001 +00000000000010000011 +00000000000010110011 +00000000000010100011 +00000000000010000001 +00000000000010100011 +00000000000010010011 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100001 +00000000000010010001 +00000000000010100011 +00000000000010010011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010000001 +00000000000010000001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010000001 +00000000000010000001 +00000000000010000001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010100011 +00000000000010000011 +00000000000010110010 +00000000000010110011 +00000000000010000001 +00000000000010100001 +00000000000010010010 +00000000000010000001 +00000000000010100011 +00000000000010100011 +00000000000010100001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010010010 +00000000000010100001 +00000000000010000001 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010010011 +00000000000010100011 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010010011 +00000000000010100011 +00000000000010000011 +00000000000010100001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010000011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110010 +00000000000010010011 +00000000000010000001 +00000000000010000001 +00000000000010000011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010010011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000011100001 +00000000000010100001 +00000000000010000011 +00000000000010000001 +00000000000010100001 +00000000000010110001 +00000000000010100011 +00000000000010000011 +00000000000010000001 +00000000000010110001 +00000000000010100011 +00000000000010000011 +00000000000010110011 +00000000000010100011 +00000000000010000011 +00000000000010100001 +00000000000010000001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010010010 +00000000000010100011 +00000000000010000001 +00000000000010000001 +00000000000010100001 +00000000000010000011 +00000000000010100011 +00000000000010110000 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010000001 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110001 +00000000000010110011 +00000000000010000001 +00000000000010010001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010010010 +00000000000010000001 +00000000000010100011 +00000000000010110011 +00000000000010010001 +00000000000010100011 +00000000000010100011 +00000000000010010010 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010000001 +00000000000010110000 +00000000000010110001 +00000000000010000011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010010011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010000001 +00000000000010000011 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010000011 +00000000000010110010 +00000000000010000011 +00000000000010000001 +00000000000010110000 +00000000000010010010 +00000000000010010001 +00000000000010100001 +00000000000010000011 +00000000000010110011 +00000000000010100011 +00000000000010010010 +00000000000010010011 +00000000000010100011 +00000000000011100001 +00000000000010000001 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010100001 +00000000000010010010 +00000000000010000011 +00000000000010110011 +00000000000010000011 +00000000000010010011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010010011 +00000000000010000001 +00000000000010100001 +00000000000010110011 +00000000000010010001 +Completed generation 153 in 413.86847 seconds diff --git a/ga-logs/gen-177.post.txt b/ga-logs/gen-177.post.txt new file mode 100644 index 0000000..5ec4c47 --- /dev/null +++ b/ga-logs/gen-177.post.txt @@ -0,0 +1,1615 @@ +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110001 +00000000000010010010 +00000000000010100001 +00000000000010010010 +00000000000010100011 +00000000000010100011 +00000000000010010010 +00000000000010100001 +00000000000010110010 +00000000000010100011 +00000000000010110001 +00000000000011100001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010110011 +00000000000010010001 +00000000000010100001 +00000000000011100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010010011 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010110001 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010010010 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010100010 +00000000000010100011 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000011100001 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110010 +00000000000010110011 +00000000000010110010 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000011100001 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110010 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010000001 +00000000000010110011 +00000000000010110001 +00000000000010110010 +00000000000011100001 +00000000000010110001 +00000000000010110001 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010110010 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100001 +00000000000010000011 +00000000000010110011 +00000000000010110011 +00000000000011100010 +00000000000010110011 +00000000000011100011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010100001 +00000000000010000001 +00000000000011110001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010100010 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000011100011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000011110011 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000011110001 +00000000000010100001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010000001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010110001 +00000000000011110001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100010 +00000000000011100001 +00000000000010010001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010100010 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010010001 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010010011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000011110001 +00000000000010010001 +00000000000010010001 +00000000000010110001 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000011110011 +00000000000010100011 +00000000000010100010 +00000000000010100011 +00000000000010110010 +00000000000010110001 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010110011 +00000000000010110011 +00000000000011100001 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010110001 +00000000000011100011 +00000000000010110001 +00000000000010000001 +00000000000010110011 +00000000000011110011 +00000000000010010001 +00000000000010100011 +00000000000010010011 +00000000000011100011 +00000000000010010011 +00000000000010100011 +00000000000010100011 +00000000000011100000 +00000000000010110011 +00000000000011100011 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010100011 +00000000000010000001 +00000000000010110011 +00000000000010100001 +00000000000010110010 +00000000000010110010 +00000000000010010011 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110010 +00000000000010110011 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010000001 +00000000000010110011 +00000000000010100010 +00000000000011100011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010010010 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010110001 +00000000000010000001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100010 +00000000000010110001 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000011100010 +After selection: + + +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110001 +00000000000010010010 +00000000000010100001 +00000000000010010010 +00000000000010100011 +00000000000010100011 +00000000000010010010 +00000000000010100001 +00000000000010110010 +00000000000010100011 +00000000000010110001 +00000000000011100001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010110011 +00000000000010010001 +00000000000010100001 +00000000000011100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010010011 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010110001 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010010010 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010100010 +00000000000010100011 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000011100001 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110010 +00000000000010110011 +00000000000010110010 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000011100001 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110010 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010000001 +00000000000010110011 +00000000000010110001 +00000000000010110010 +00000000000011100001 +00000000000010110001 +00000000000010110001 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010110010 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100001 +00000000000010000011 +00000000000010110011 +00000000000010110011 +00000000000011100010 +00000000000010110011 +00000000000011100011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010100001 +00000000000010000001 +00000000000011110001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010100010 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000011100011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000011110011 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000011110001 +00000000000010100001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010000001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010110001 +00000000000011110001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100010 +00000000000011100001 +00000000000010010001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010100010 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010010001 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010010011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000011110001 +00000000000010010001 +00000000000010010001 +00000000000010110001 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000011110011 +00000000000010100011 +00000000000010100010 +00000000000010100011 +00000000000010110010 +00000000000010110001 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010110011 +00000000000010110011 +00000000000011100001 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010110001 +00000000000011100011 +00000000000010110001 +00000000000010000001 +00000000000010110011 +00000000000011110011 +00000000000010010001 +00000000000010100011 +00000000000010010011 +00000000000011100011 +00000000000010010011 +00000000000010100011 +00000000000010100011 +00000000000011100000 +00000000000010110011 +00000000000011100011 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010100011 +00000000000010000001 +00000000000010110011 +00000000000010100001 +00000000000010110010 +00000000000010110010 +00000000000010010011 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110010 +00000000000010110011 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010000001 +00000000000010110011 +00000000000010100010 +00000000000011100011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010010010 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010110001 +00000000000010000001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100010 +00000000000010110001 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000011100010 + + + +After crossover: + + +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000011100001 +00000000000010010001 +00000000000011100011 +00000000000011100011 +00000000000011110001 +00000000000010100011 +00000000000010110001 +00000000000010000001 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010000001 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010010001 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010100010 +00000000000010110001 +00000000000010110010 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000011100011 +00000000000010110001 +00000000000010100011 +00000000000011100011 +00000000000010100001 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010010011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000011100001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110010 +00000000000011100001 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010000001 +00000000000010110001 +00000000000010100011 +00000000000010010010 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010010001 +00000000000010100011 +00000000000010100010 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000011110001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010010011 +00000000000010100001 +00000000000010110001 +00000000000010010010 +00000000000011110001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000011100001 +00000000000010110001 +00000000000011100001 +00000000000010110011 +00000000000010010001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100010 +00000000000011100011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000011100001 +00000000000010000001 +00000000000010000001 +00000000000010100010 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010010001 +00000000000010100001 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000011110001 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010100001 +00000000000010110010 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010110010 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010000001 +00000000000010110001 +00000000000010110001 +00000000000010010001 +00000000000010100011 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010110010 +00000000000010000001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010100001 +00000000000010100011 +00000000000010100011 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010110010 +00000000000010110011 +00000000000010100010 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000011110011 +00000000000010100011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010100010 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010100001 +00000000000010110001 +00000000000010010001 +00000000000010110011 +00000000000010100011 +00000000000010110010 +00000000000010010001 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010110011 +00000000000010100010 +00000000000010010001 +00000000000010010001 +00000000000010100001 +00000000000011110011 +00000000000010100011 +00000000000010000001 +00000000000011100011 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110010 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010110010 +00000000000010010001 +00000000000010110011 +00000000000010110010 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000010110001 +00000000000010110001 +00000000000010000001 +00000000000010100001 +00000000000010000001 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000011100011 +00000000000010110001 +00000000000010110011 +00000000000011100010 +00000000000010010010 +00000000000010100001 +00000000000010110001 +00000000000010110011 +00000000000010110010 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000011100010 +00000000000010010010 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010010011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000011100001 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000011100000 +00000000000010110001 +00000000000010100011 +00000000000010010011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010010011 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000011100011 +00000000000010000001 +00000000000010100011 +00000000000011100001 +00000000000010110010 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010010011 +00000000000010100011 +00000000000011110011 +00000000000010100001 +00000000000010110001 +00000000000010110011 +00000000000010100001 +00000000000010010010 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010000001 +00000000000010110001 +00000000000010110010 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010010010 +00000000000011100011 +00000000000010100011 +00000000000010010001 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010100001 +00000000000010010011 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000011100001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000011110011 +00000000000010110010 +00000000000010110011 + + + +After mutation: + + +00000000000010111011 +01000100000010110110 +00000000000011110011 +00000000000010110010 +00000000010010110011 +01000100000010100011 +00000000000111100001 +00000000010010110011 +00100000001010110001 +00000000000010100011 +00000000000010110000 +00000000000010110001 +01000000000111010011 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000001000010110011 +00000000000010110001 +00000000000010110001 +00000000000011100011 +00000000001011100011 +01000010000010010010 +00000000000010100011 +00000000001010110001 +00000000000010110000 +00000000000000100011 +00000000000010110011 +00001000000010110010 +00000000000010010010 +00000000000000110001 +00000001000010000001 +10000000000010100011 +00001000000010100011 +00000000000010110011 +00000010000010110001 +01000000000010100011 +00000000000010100011 +00100100000010100011 +00000000000010010000 +00000000000000100001 +00000000000010110010 +00000000000010110000 +00000000000010110001 +00000000001011110011 +00000000000010100011 +00000000100010010011 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000010010110010 +00000001000010110001 +00001000000010110001 +00100000000010110010 +00000000000011100001 +00000000000010100111 +00000000000010000011 +00000000000011100011 +00000000000010100011 +00000000000010110011 +00000000000011100011 +00000000000110110001 +00000000000110110011 +00000000000010110001 +00000000000010010011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010111011 +00000000000010010011 +10000000000010110011 +00000000000010110001 +00000100000011100000 +00000010000000110000 +00000000000010110011 +00000000000010111011 +00000000000011110011 +00000000000010110011 +01000100100010110011 +00000000000010110011 +00000000000011100010 +00000000000011100001 +00000000100010010110 +00000100000010110001 +00000000000010110001 +00000000001010110011 +00000000000010111011 +00100000000010110011 +00000000000010010011 +00000000000010110001 +00000000000010110011 +10000000000010010001 +01000000000010010010 +00000000000011101010 +00000001000010100011 +00000100000010110001 +00000000000010110011 +00000000010010110010 +00000000000010110011 +00000000000010110001 +00000000000010100001 +01000000110010010010 +00110010000011100010 +00000000000010110011 +00000100000011110001 +00000000100011100111 +00000000001011111011 +00010000000010100011 +01000000000010100011 +00000000000010000001 +00000000100010100001 +01000000000010000001 +00000000000010110001 +00000000000010100001 +00001100000010010001 +00100000000010100111 +00010000000010100011 +00000000000010110001 +00000000000010110011 +00000000000000100011 +00000100000011100011 +00000000001010110011 +01000000000010110001 +00000000000010110001 +00000101000010111010 +00000000001010110011 +00010010010010101010 +00000000000010100011 +00000000001010110011 +00000000000010111101 +00000001000010110011 +00000000000010100011 +00010000000010010011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010100011 +00010000000010110001 +00000000000110110010 +10000000000010110011 +00000000000010000001 +00000000000010110010 +00000000000010100010 +00000000001010000011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +01000000000010100001 +10000000000010100011 +01000000010010110010 +00000100000010110011 +10000000000010110011 +00000000100010100011 +00000100000010100011 +00001000000010110011 +00000000000011100011 +00000000000011000001 +00000000000010100011 +00010000000011110011 +00000000000010100001 +00000000000010010001 +01000000000010000001 +00000000000010100010 +00000000000010110001 +00000000000010100001 +00000000000010100011 +10000000000010110011 +00000000000010110011 +00010000000010000011 +10100000000010110001 +00000000001010110001 +00000000000010110001 +00000000000010010001 +00000000000010110010 +00000000000010100011 +00000100000010110011 +00000000000010010001 +00010000000110110001 +00000000000010100001 +00000000000010100001 +00000000000010110111 +00000001000010100011 +00000000000010000011 +00000000000010100010 +00000000000011100010 +00000000100010110011 +10000000001010100001 +00000000000010110011 +00000000000010101111 +00000000000001110010 +00000000000010110001 +00000000000010110011 +00000000000010101011 +10000000000010010011 +00100000001010100011 +00000001000010110001 +00000000000010110011 +00000000010010110111 +00000000000010100010 +00000000000010110011 +00000000000000110010 +00000000000010001011 +00000000000010110001 +00000000000010100011 +10000000000010110011 +10000000000010110010 +00000000001010110011 +00000000010010110011 +00000000000010100011 +00001000100010100011 +00000000000010110011 +00000000000010110011 +00000000000011100011 +00000000000010000011 +00000000000010100010 +01000101000110100001 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00001000000010000000 +00000000000010110010 +00000000000110110011 +00000000000000100011 +00001000000010100001 +00000000000010000011 +00100000000010000001 +00000100001010010001 +00000000000010110001 +00000000000010000000 +00000000001010110011 +00000001000010110001 +00100000000010110000 +00000000000010110011 +00000000000010110011 +00000000000010110010 +00000000001010100000 +00000000000010110010 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000001010100001 +00010000000011110011 +00000000000010000001 +00100000000010110101 +00001001000010110001 +00000000000010110011 +00000000000010100011 +00001010000000110001 +00000000000011010010 +00000001000010100001 +00000000000010110011 +00000000000010100001 +00000000010010010011 +00000000000011110001 +00000000000010100011 +00000000000010111011 +00000001000010110011 +10010000000010110001 +00010000000010100001 +00000000011010000001 +00000000000010010000 +10100000000010000011 +00000000001010100000 +00000000100010110011 +00000000000010010001 +00000010000010110001 +00000000000010100011 +00001000111010110011 +00000000000010110011 +00100000000010110011 +00000000000100110011 +01101000000010100011 +00000000000010100010 +00000010000010010001 +01000000100010100001 +00000000000011100001 +00000000000010110011 +00010000000010010011 +00000000000010111001 +00000000010000100011 +00000000000011100111 +00000000000010100010 +00000100000010100011 +00000000001001110011 +00000000110010110011 +00010000000010010001 +00000000000010110011 +00000000000011100001 +00010000001010110001 +00010000000011110001 +00010000000010100011 +00000000001010110011 +00000000000010110001 +00100010000010110011 +00000000000011110101 +00000000010010010010 +00000000000010100001 +00000000000010100001 +00000000000010010010 +10000000000110110011 +00000000000011000001 +00000000000000100011 +00000000000010110011 +00000000000110110011 +00000000000110110011 +00100000000010110011 +00000000000011110001 +00000000000010100011 +00000000000010100011 +00000010001010110011 +00010000000010100010 +00100000000010100011 +00000100000110010001 +00000010001010010011 +00000000000010110011 +00100000000010110001 +00000000000010110011 +10000000010010010010 +00000001000010100010 +01000011000010110001 +00001100001010000001 +00000000000010010011 +00000000100110110011 +00000000000010100011 +00000000000010110001 +00000000000010100011 +01000000000000110011 +00000000000010110011 +00010000000010110011 +00000000000011100011 +00000000000010110011 +10001000000011100001 +00001000000010110010 +00000000000010100011 +00000000010010110011 +00000000000010110011 +01000000000010110001 +00001000000011100001 +10000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010110001 +01000000000010010011 +00000000000010110011 +00000000000010110011 +00000000000000110011 +00000000000010110011 +00000000010010100001 +00000100000011110011 +00000000000010100011 +11000000000010110001 +00000000000011100011 +10000000000010100011 +00000000000010110010 +00000000000010100011 +00000000000000110001 +00000000000010100011 +01001000000010110001 +00100010010010100011 +00000000000000100011 +00010000000010110010 +00000000000010110001 +00000000000011100010 +00000001000110110011 +00000000100010110001 +00000000100010100011 +00000000000010110011 +00000000000010011001 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000001000010100001 +00010000000010110001 +00000000100010000001 +00000000000010100011 +00000000000010111011 +00000000000010110011 +00000000000010110011 +00000000000110110001 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000100010000001 +00000000000010110001 +10000100010010100011 +00000000000011110001 +00000000000011100011 +00000000001011101011 +00000010000010010001 +00100001000011100001 +00000000000010000011 +00000000000010110011 +00000000000010110011 +00000001000011110001 +00001000000010100011 +00000000000010100011 +00000000100010100011 diff --git a/ga-logs/gen-177.txt b/ga-logs/gen-177.txt new file mode 100644 index 0000000..bb86ccb --- /dev/null +++ b/ga-logs/gen-177.txt @@ -0,0 +1,400 @@ +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110001 +00000000000010010010 +00000000000010100001 +00000000000010010010 +00000000000010100011 +00000000000010100011 +00000000000010010010 +00000000000010100001 +00000000000010110010 +00000000000010100011 +00000000000010110001 +00000000000011100001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010110011 +00000000000010010001 +00000000000010100001 +00000000000011100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010010011 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010110001 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010010010 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010100010 +00000000000010100011 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000011100001 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010110010 +00000000000010110011 +00000000000010110010 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000011100001 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110010 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010000001 +00000000000010110011 +00000000000010110001 +00000000000010110010 +00000000000011100001 +00000000000010110001 +00000000000010110001 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010110010 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100001 +00000000000010000011 +00000000000010110011 +00000000000010110011 +00000000000011100010 +00000000000010110011 +00000000000011100011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010100001 +00000000000010000001 +00000000000011110001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010100010 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000011100011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010010001 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000011110011 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000011110001 +00000000000010100001 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010000001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010100001 +00000000000010110001 +00000000000011110001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010100010 +00000000000011100001 +00000000000010010001 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010100010 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010010001 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000010100011 +00000000000010110011 +00000000000010110010 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010010011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000011110001 +00000000000010010001 +00000000000010010001 +00000000000010110001 +00000000000010100001 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000011110011 +00000000000010100011 +00000000000010100010 +00000000000010100011 +00000000000010110010 +00000000000010110001 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010110001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010110011 +00000000000010110011 +00000000000011100001 +00000000000011100011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000011100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010110001 +00000000000011100011 +00000000000010110001 +00000000000010000001 +00000000000010110011 +00000000000011110011 +00000000000010010001 +00000000000010100011 +00000000000010010011 +00000000000011100011 +00000000000010010011 +00000000000010100011 +00000000000010100011 +00000000000011100000 +00000000000010110011 +00000000000011100011 +00000000000010100001 +00000000000010110001 +00000000000010110001 +00000000000010010010 +00000000000010100011 +00000000000010000001 +00000000000010110011 +00000000000010100001 +00000000000010110010 +00000000000010110010 +00000000000010010011 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010100011 +00000000000010110010 +00000000000010110011 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010000001 +00000000000010110011 +00000000000010100010 +00000000000011100011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010010001 +00000000000010110011 +00000000000010110011 +00000000000010000001 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000011100001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000011100001 +00000000000010110011 +00000000000010110001 +00000000000010110011 +00000000000010100011 +00000000000010110001 +00000000000010010010 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000010100011 +00000000000010100011 +00000000000010110001 +00000000000010110001 +00000000000010100011 +00000000000010110001 +00000000000010110011 +00000000000010110011 +00000000000010100001 +00000000000010110011 +00000000000010110001 +00000000000010000001 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010100011 +00000000000010110011 +00000000000010110001 +00000000000010100011 +00000000000010110011 +00000000000010010011 +00000000000010110011 +00000000000010110011 +00000000000010110011 +00000000000010100010 +00000000000010110001 +00000000000010110010 +00000000000010110011 +00000000000010100011 +00000000000011100010 diff --git a/ga-logs/generation-1006.txt b/ga-logs/generation-1006.txt new file mode 100644 index 0000000..a43a8c5 --- /dev/null +++ b/ga-logs/generation-1006.txt @@ -0,0 +1,400 @@ +01000100110001110110 +00001001001010100011 +00000001010101011001 +00000000010101010010 +00000001000000010001 +00001000000011110010 +00000000000111010011 +00000000000010010111 +01000010000000111001 +00011100000000111110 +00000001010101100011 +00100010011100101000 +00010011000110000101 +01100000000111010010 +10010111101110001110 +01100000100011100011 +00000000010010010011 +00011001001000000000 +10000000000111000010 +10011011011111011011 +00000001000011110000 +00000000000011111111 +00010010000010011111 +01000000000111101101 +00100000100011110111 +00000000000011101101 +01000010100001010110 +01000100100101001010 +00000000001001100000 +00000000000011000110 +00000000000001000011 +00000111001010001110 +00000000101000110001 +01000010001100010101 +00000000101000101100 +00101100001101110001 +00001000000111110100 +00000000100010000001 +00011001101010011011 +00000001000011110011 +01000100110101101011 +00001100010101000101 +00000000000001000000 +00001000000011110010 +00100000010111010001 +00000010000001110011 +00010001000001000010 +00000000011110010111 +00100001000011111101 +00000001001010010100 +00000000000010100001 +11000010110010000010 +00000011000111010000 +00001111111000001110 +00000000000010110100 +01000100010101010101 +01000000010101111001 +00000000100010011111 +00100100001010001100 +10000100000101011110 +00000100001011011011 +00000000010110101000 +01001000010101110101 +00000000001111010111 +00010100010100001001 +00000000000001000111 +00000001100101111101 +01000000010001100110 +00000100000000010010 +00000010000101001001 +00000000100011000001 +00010111001010001100 +00000000001010000110 +00000000000111100010 +00000000010001010011 +00001000001010001010 +00000100010010100101 +00000001010111110001 +00000100000011010000 +00100000010000110010 +00000000000000110110 +10000010011011000100 +00000001001011111111 +10000011000010100100 +00000000000110010100 +00001010000001111010 +00010011000110000100 +01010110000110001110 +00000011001110101010 +00000000000111100110 +00100010100111100010 +00000100100111110111 +10010010100010001100 +00011011001011111110 +00000000000111110011 +00000000101001110001 +01010110001100001110 +00000001000011000011 +00010001100010110110 +00000100000100110010 +00000000000000111011 +00000000000111010010 +00001000000011001110 +00000100110011010011 +00000000000000010011 +00000100000011111110 +01000010101111011100 +10000000110001110110 +00010011000111110101 +10000001000110000100 +00000011100010000100 +00000000000011010001 +10000010101010100001 +00000000010110101010 +00000001000010000010 +00000001101101110001 +01000001010110011111 +00000000011100010101 +00100110100001111101 +01010000001001010111 +00000100110111110001 +00000000000000010111 +00000000000011001110 +00000001000010000110 +01000000001011110010 +00000000011110101000 +01110011000001111110 +00000010100011000001 +00000011110010100001 +01110100101010010001 +00000001000010010001 +10011101011110011001 +00010000000110000011 +11000000001110110000 +01000010000001010010 +00000000111110001101 +00000000001111110000 +00100000000011111100 +11000011000010011011 +00110011110000110110 +00100000000010010110 +00100011000011111100 +10011011111001001011 +00010000000011110010 +00001011000101111001 +00000010101001110000 +10000001001000000101 +00001000000001010000 +00000011000110010110 +00000111100100110110 +00100001111100001100 +00001111110001110101 +01010000000111110011 +10100001010011010000 +00000000001010010010 +00000000100001110111 +00000000000100100001 +00100010000000111010 +01001000001110101000 +00000010000001111110 +01000001000110111000 +00000000000100010111 +11010110100100010101 +00000001000011111111 +00000010100010000100 +00010000000011010010 +00000111001001111100 +00100001100010111101 +00010110100010010000 +00000110001001011011 +00000100100010000011 +01010000000011010110 +00000001110011110001 +00000110010101010010 +00100000010010110110 +00000100000001000010 +10000000000011111100 +00010011011000110010 +00000011001010001100 +00111000011011000100 +00000000011110010111 +00000110110101010101 +00000000000101111001 +00000100011111010100 +01000000001111010000 +00100100010101001111 +00001000000111111101 +01101000000111110010 +00100100001010100011 +00001100001010001000 +01000010011100110101 +00000001000010110100 +10000100001010000011 +00011000000111101100 +00000000010010000010 +01000100000010001010 +01000001100001101011 +00011010001010111001 +00001111111111000011 +00000000000000001000 +01011100011011100111 +00000001011011000000 +10000000000111111010 +00000100010010100100 +01000000010011001110 +11100010000101010110 +10100011010011000000 +00100100010100001000 +00010100000111010111 +00000000010011111100 +00100010101000111110 +11000110100011000001 +00011000000001000100 +00000011101000110000 +00000010000001100101 +00010011000010010011 +01010010010110001110 +00100010110010100111 +00000001111111000111 +00100000001011000111 +00000000000011001100 +00000001010110001011 +01000000011011000011 +00000000000111110010 +01010110001110101011 +00000000000111110110 +00100010100111100111 +01010110000110001010 +00001000000010000010 +00000000000001001100 +10001001011001110001 +00000000000000010111 +10000000100001110011 +01000000000111100011 +00011000000110100011 +00000100101110000010 +00001000100011111010 +00000000000011000000 +00000000100000010010 +00000000000010011101 +10000000000011000000 +00010110000000010111 +00001010100000111111 +01101010110011010011 +00000010010010111000 +00000010010010111000 +00000010000000000111 +00100100100011110111 +01110011001111010011 +00010110101010001010 +00100000110010001000 +01011100011011110011 +00000010000101110001 +00000001100010010011 +00000001000001000011 +00010001000011010110 +00000000000011000101 +00100000001101100001 +00000000000111010011 +00111010100011011010 +01000000000001010101 +00100000000011100101 +00000000100011101000 +00000010000011100011 +00001001011110000111 +00000000001110100010 +00001011001111110000 +00000100010010010011 +10000100100001010110 +00000000000011100011 +01000000000111110000 +00100010101001110011 +00000000001010100100 +00000000001001110001 +00000000100011100011 +00010000111001110111 +00110000000000010110 +00000100100101111111 +00000000000111010100 +00011000000110010010 +00000010100010101000 +00001001000011110000 +00100000110010100010 +10011001011110110001 +10000100010100001011 +01001100101010001000 +00000110001110101011 +10001110000010010110 +00010100010011010110 +10000010001000111100 +00010110001110010111 +01000001000101110001 +00000000010000110000 +00000000011111110110 +00000010001010001011 +00100000010011011001 +00001100011101111001 +01011100001010001010 +00000000010010100001 +00110011000110001100 +00000000000001110011 +00000001000001000010 +00001011010010010011 +00100010000110001010 +00000000100110000010 +00000100101010110110 +00000100000110101100 +00100000000001100100 +00000000010011110101 +01000001011001100000 +00000010000111010011 +00000000000010000010 +01010000010011110000 +00100000010110001110 +00000000011000101011 +00000100000010100100 +01000001000111010010 +01110001000010001111 +00000001000001010000 +10011000000110110110 +00001011001111011010 +00011011000000101000 +00000001000011011010 +00010010010100111100 +00000100000010110000 +00001110111000011010 +00000000001010110010 +00100100000100101101 +00000001000010010110 +01000100000010001010 +00000000000011111001 +00000010000000110110 +00000000110011100011 +00100011010010010011 +10000000000000010111 +00000000011110010110 +00000000000011100010 +00000010000010000110 +00001010000011011010 +00000000000001110011 +00100000111100001010 +01000111000010001010 +00000011001110101110 +00000011001100101111 +01011100011010001000 +01000100000001111110 +10000000000110001110 +00000001000111010011 +00011010000010111001 +00010010000011111010 +00000000000000111011 +00010000000110000011 +00000011000010010110 +00000000000111001010 +00000000101000110010 +11100010010110010111 +00001100011110101010 +00000111111100000100 +00001100011011110000 +01000100101010000011 +00000000000011110010 +00000000001010010011 +00010000000000001100 +00100001000011001001 +00001110100011110100 +00010011010010010011 +00000001010100001011 +00000001111100010011 +00000100001100110011 +00100000000111000100 +01000001100101110001 +00001001001011010010 +11100010000101001110 +00100000001110010011 +00000100000101010011 +00000001110010000010 +10000000000011011011 +00010000000101000010 +00000100001000010110 +00110010100010011111 +00000001011010010011 +10000000001001010011 +01000001000010000000 +00010100111110001101 +10000100001100010111 +01000011000010011011 +10001000000001010011 +00000000000100010110 +01000001010001011001 +00000100100011001000 +00011100100011001011 +00000000010011111100 +00000000111010111010 +00001110100011111110 +10011011011101011011 +00000000010000110010 +00100000000100110101 +00000001100001011101 +00010001000010000000 +00000011001100001101 diff --git a/ga-logs/generation-115.txt b/ga-logs/generation-115.txt new file mode 100644 index 0000000..e6a5292 --- /dev/null +++ b/ga-logs/generation-115.txt @@ -0,0 +1,400 @@ +10101101111110011111 +10101100011000100000 +00001010111110111001 +00001011100110000011 +00101011111010101000 +00011001110111100101 +00010011101011010001 +01001010110110111001 +00000001111011100111 +00110100010010011111 +00011111010100111111 +00011001111000101101 +00101110110101011101 +00011010011110001010 +00100001101010001100 +00111010111101001111 +00001010111110000111 +10000111010001011110 +00100101101000000111 +00111111010111001000 +00100101010110001111 +00011111010010111110 +00101110110101011011 +00101011100110000101 +00100110101111010000 +10111110010111010100 +00011111110011100101 +00011010101000110100 +00001010011011001111 +00000101010110101111 +00010010010000011101 +01101110111010011101 +00011101111001101111 +01011101011100110111 +00010111100110111111 +10110111010000011110 +01001000110010111110 +00011011010101000010 +00011011100010111011 +00010110010101010110 +10100110000011011110 +10010100100110011101 +00001011001100001000 +00100111000011101111 +01010110001011010011 +00110011111001101011 +00111010001010000010 +00100110100110101101 +00000100010110001110 +00000111010000000110 +00011100001010100010 +00011000111100010100 +10110100110000001011 +11110110010011101000 +00001111110100101001 +00011001010001111100 +01101001011101101010 +00000111101011001111 +01110110110100001010 +00011011110011000001 +01010100110101110110 +10011111100110010110 +00010110101110011010 +00111110001110011110 +01111010110111001100 +00101110000101011000 +01101110011110101101 +00101010010010001001 +00101000010011101011 +01001011010110010111 +01101100001010001111 +11001001100001100101 +00001011100011101111 +10111100010100011001 +01011011100010011010 +00111001111111101111 +00010010010001011101 +00110001010010111100 +00101110000110001100 +00011011101011110001 +01111010000111011011 +10001000100111011101 +00111011110010111010 +00111001011110111000 +10001110110101011101 +10010101000011000001 +00010001111010010100 +00000101010110111001 +10101111001110000101 +10000101001010011001 +00101000010100000001 +00001101101000000101 +01011110110100110111 +01011001000111010111 +10011110100000010110 +01101110010010111100 +01011000100011010001 +00011011010011110110 +00001100011000101111 +10001100111010100011 +00011010001100101011 +11101101100010101110 +01011011110010000000 +00101001000011101101 +00111001100111110110 +10001111000101000111 +00001111010011111101 +00010001110000101101 +00011011000011010010 +00001001011011111110 +01000111000010111111 +00000000011011101110 +00111010011110101000 +00001110001001101000 +00100011100011110110 +00101010010001011100 +10010100101111011110 +01000101111111000001 +00001001110111010010 +00111100111010100011 +10001010110101011100 +10011001100100111111 +00110001010001001010 +10111010001010010100 +00001011111010111111 +00011011110010110101 +00111001010010011111 +00100011100100011110 +00011011101001101000 +10001110010010100101 +00101100101111001111 +00101010110000010111 +01111101101010101110 +10011110101000010111 +00001111000011101111 +11100111101011011110 +00001000111000001011 +00011010011011011011 +00101001100000011010 +00110101010011010100 +00111001010101101010 +00111010101001101000 +10000101000001111001 +00001101111110011001 +00011101111001101001 +00101110111011111111 +10111101011011110000 +00100001101100111000 +10011101000011100001 +00001100000000011010 +00011100110001101101 +00111101000110110101 +00011100111011010100 +00010011000111001100 +00010101010101001110 +00110010010001011100 +00101110111100011101 +00011010110011001011 +11000010000010110000 +00011011011001011001 +00001111010011101101 +00001100011010001001 +01111010000111110111 +00111110100101101011 +01110011110010001001 +01101011111100001001 +00001100100001101110 +01001011110110010111 +01011011101110010110 +00100011100100011001 +00111010110111110111 +00010101101011111101 +00101011011101011111 +10000011100011101111 +00110110001001011110 +00110101111001011111 +01101001011010011001 +00001110111110111111 +00001011010100101111 +10011111101001101010 +00101111010001100101 +00011011100101101010 +01001110011011101010 +01001111100001011110 +00011111111100001111 +01011111000100111111 +00100011110100011110 +01011101001010100011 +00011001000000101010 +00001011110001110010 +00011101111001101111 +00011101110110110111 +00110101110000111110 +01110111001110001010 +00001010100110010000 +00000011011111101111 +00111110000111011110 +00100110000111011011 +00001111110010110101 +01101000000100110111 +01001110111011100001 +00011011010001000111 +10000101111101110000 +00011011101011010001 +10110010011000110011 +00011111110110110110 +01000001110110111001 +00100011110010111100 +00001100011010001000 +10100000111000110000 +00011010101001010111 +00111110100000100100 +10100111110110100011 +00110111110011101111 +00000010010001011100 +00010010100011100111 +00111001110000000110 +00101111010111100101 +00011100000100110011 +01011111111100000110 +01000011010010101001 +00011110110111110101 +00011111101001000110 +00011001110100101011 +11101101110010001111 +00100101010110111011 +01111001010011100110 +01010101010101110101 +11010010101101111010 +01011010000111011111 +00011100111010111010 +01010011101001000000 +00011010110110111101 +00000001110010011011 +00010010011111110110 +00101110111110011101 +00001001111000001001 +00111111001111011101 +10110000100010011111 +00101001011001101100 +00111101010010111011 +11101001011110111100 +00001111111111010001 +10001111110011100101 +11000011100001100011 +10000010100000101011 +00101110110100111011 +00111001100111011101 +00000010100011101111 +00111001111101101111 +00101110010010011110 +01111110100110101010 +10001011110001011110 +01011010000110101010 +01011001100011100001 +10011001100101010001 +00001111000101000110 +01011011101110010001 +10101011110010000111 +00101010011101100001 +01011000111000110000 +10100000110001110111 +00001110001010001000 +10001001010110111111 +00100000111000110000 +11110101010110001111 +00111010001001101000 +00011011101001101101 +00001010011010101011 +00000100100011001101 +01100010011100101000 +01111011110010111101 +01001111010110111101 +00100110100011101111 +00011000111100000110 +00100011100011101111 +00010101001111110110 +00010010010111100110 +00000111011101011101 +00010101101100101000 +00010101011001100001 +00101001100111100111 +00001010000001101111 +00001011100011011100 +00110100011000111001 +10001101110000011110 +00110110000111001101 +00011010111011011110 +00001011010000011101 +00010111000000101010 +00011001000001110000 +01101100001010001101 +10001101111111001000 +00011010011111001101 +10011010011011011111 +00101011111100001001 +01100000001101111101 +01111110011100100001 +00000100000011111011 +00000100010110010100 +00010101011001000111 +00011101011000101111 +00010000010000011001 +00111000010111110110 +00010011011011101011 +11000011100000111001 +00111001000101110110 +00100011000010010011 +10100011100000100011 +10000011011100100000 +00001010111001111010 +00011000101000110101 +01110101110110110101 +00001110101111011111 +00011100110001000111 +00001111110110011110 +10011001110111101111 +00000011001011100100 +01101000111110011001 +00101011011111001100 +11001001000011010100 +00101001010101101010 +01001001010010000111 +00000101011001111011 +00111111001111111001 +00011110010110110010 +00011111000010110111 +00111001000101101010 +00011010111010101101 +10000001011101001101 +01111100111110011110 +00011011100101010001 +10100010100111101000 +01101001100010001101 +00101110110101011101 +00000101010110001111 +01101001111100101111 +00111110000111011001 +00111010100100111000 +10111001110100101101 +00111010001111010000 +00001000000110011010 +00110101110101000110 +00011110000100001101 +00011011010001011100 +00001010101001110000 +00111011111101101111 +00101000101110001001 +01101010100101011010 +00111100110111001110 +00010101000111010111 +00000111011101111011 +00010010010001011100 +00010110000110101011 +01001011100101010001 +00111101100010101111 +00111110010110110110 +00000100010110001111 +00011101010101101010 +00110010011010111110 +00101110110101011101 +00101101101000000110 +01010101110000110001 +10111100110000001001 +01011010111000111011 +00011010101100111001 +00011110111110101000 +00010001001011111001 +00000011001000110000 +01100101111011111000 +10100000111000110000 +01111011110010111101 +00001101111111111001 +00001100110011110101 +00011000000101010110 +01000101110101110001 +00010010010001111001 +00011011110000011101 +11011010100010111110 +00001110110110111111 +00000001100011111011 +00001001100110010101 +00101110111110011100 +00011001000110100011 +00111101110000110010 +00001011110001001110 +00001100101000010110 +00000100010000011010 +00001000111000001110 +00010000001110111101 +00100010001111001100 +00000001110010011101 +00101000011011111011 +00000001100011101011 +00101011111101001011 +00111001110000001001 +00101000100101111011 +11010110000100001101 +10011110101000000110 +01011010000111011111 diff --git a/ga-logs/generation-272.txt b/ga-logs/generation-272.txt new file mode 100644 index 0000000..9866299 --- /dev/null +++ b/ga-logs/generation-272.txt @@ -0,0 +1,400 @@ +00000001001010000001 +01011010101010000011 +01100110011110100111 +00011000000110000011 +00000100111100010010 +00000001101110111111 +10000110110000101101 +00000001010010001100 +01101100000110000000 +00001001100010100010 +00000100000111101101 +00001011110100011001 +01000011001110000000 +00000101011011010111 +00011000000110110001 +00000000010110011111 +00100010100100110011 +00000111000111100000 +00000000001000011100 +00100000010011100100 +00101000110010000110 +00110010001110100001 +11000100010010110110 +00000011011010100000 +01111000000010101111 +00000010101010000011 +00010100100111100001 +11100000011110010001 +00000000100000011101 +00000000001110010011 +01001100111110010000 +01111000001110101010 +00000001001010010100 +10100000001110011101 +00000001011100010110 +00110000000100011111 +10100000010011100010 +00010000011001100010 +00000011011110010110 +10000101011011010101 +00000000000110010111 +00100000111011000010 +00100000000110000100 +00111000100010000110 +00100001000110010011 +00100011000111111001 +00000101010011010101 +00010000000001111111 +00101000000010100010 +00100000010111111101 +00000110010100011111 +00101001001100010111 +10000000010100011000 +10001110101010101101 +00010100001110100011 +00011000100010011011 +00010000000100011111 +00010110011010011110 +00000000110000000110 +00001000001110010011 +01001010000001101010 +01110000101010001100 +00010000000111010011 +00001100110110110010 +00100000010111010101 +00000001000110000001 +00000001011000000100 +00000000100101010011 +01010000110110111110 +00000000101110110011 +01001001010011101111 +10010000001010100000 +00000000000110010010 +00000000101010010001 +00000000000101011101 +00000110000010100111 +00000010000000000011 +01101000000100001001 +10000000000110000111 +00000000100101011001 +01100001000000110100 +01100010000110101011 +00100000101010100100 +00000100011010110011 +10000010110010100100 +01000000100010000001 +00000000010000101000 +00001000000010110100 +01010011001010110011 +11001000000110100010 +10000000001110001111 +00001000010000011001 +01100001101010000001 +01001000000100000011 +01000000010001000001 +00000000000111000100 +00000010011110000100 +00000010000001101101 +00011000101111010011 +00010100101110011001 +00011001100101110011 +00000100001010111111 +11000001000101010000 +00010100000001000001 +00000101110101110011 +10000000000110101001 +00000101000110010110 +10000000001010100100 +11000001001010000001 +00100000110011010000 +00001000001010011111 +00000001000010010111 +10000000001000001111 +10000001101010000100 +00000000100110110001 +00000000000110100111 +01000101111100011000 +00101010001011000110 +00000000100010111011 +00001110111100001011 +00011000100010000101 +00000000000111100011 +00010100000100100111 +00000000000001010110 +00000000001110101010 +01001000001110110101 +00000001010111110100 +00110110000101011101 +00100000010010011010 +00100101000011100110 +00000000010000010100 +00100000010000101101 +00000101010010010010 +01010000101110110011 +00011000000000000001 +01100000100110001111 +10000000000000011001 +00000001000110100001 +10000000000010100101 +01001001001101110101 +00000001000100011101 +01000000010110001110 +00000100000010110000 +00100010001010000101 +10000000000110000011 +00110000001100100011 +00000001001110110110 +00100101101110000011 +01110000010010011101 +00001001000010001111 +10100101010000010010 +00000001010000101101 +00000010101101111011 +00000001010110001000 +00000000000110110000 +01010100100111100001 +00000010000010000011 +00010000000010100100 +00011000010000111110 +00000001000110100001 +00000000001110010000 +00100001100111011001 +00100100100101100011 +11110101111000011000 +00100011011010100100 +01100000001100010110 +00001100011000101100 +00100001010011110010 +01000101111000011000 +00000110010000111000 +00000111010000110010 +00000100000111011010 +00000100001110110011 +00000110000011011010 +01100110000010011100 +01010110101111010101 +00010000000110010111 +00000101010011111000 +01100011010110010111 +00000010010000000001 +01101100010110000100 +00000000010110100111 +01000010010010101110 +00000001011000010010 +00000110010010110100 +11001000100110111110 +00000001001111010011 +00000010001100011011 +00101000101100011011 +00001000001011000110 +00000000000000101100 +00000000000111000011 +00000000011110010011 +00000000001110001000 +00000001100111001111 +00010001001011011001 +00000000000010101111 +00011000100111010110 +00000000100000000010 +01001111101010100100 +00000010010000010100 +00000110000000101100 +00011000011000100001 +11100001100011111000 +00000000000010111010 +00001100101110010001 +01101000000101010110 +11000011010100000111 +00000011010010010010 +00000001001100110000 +00010000100001101110 +00000100110001110010 +00000000001110101010 +01000000011110000000 +00000101001110110000 +00001001100010001101 +00000101011110111001 +10000011010000011101 +00000001010110010111 +00011000000111010000 +00000010110010001111 +00101000000010110011 +00001001011010011111 +00000000000000010010 +00000001010110111101 +01100000000101101010 +01011010000011101000 +00001000001010101011 +01100010001111101011 +10001001100000100010 +00001010110110110011 +00001000011010000010 +00010001000010100101 +11101000100001011011 +00000110100001101110 +00000100000110111011 +00000000100101011000 +11000000000110000001 +01111000000111010001 +00000011101010000010 +00000010010010100110 +00001011011110100100 +00001001001110000001 +00000000100100100111 +00000001001010000100 +00000000110010111111 +00000000000110010010 +00000110100010001111 +00000001000111100001 +00000101001110110000 +00000001001110010000 +00000000111111111101 +00000101001110010011 +11000110100110111000 +10000010001010110001 +00000010010110010001 +00000000010011000100 +00000000110000010110 +00001101001110010110 +00000001010000111101 +10000001001011011001 +00000001110111110011 +01101000001011000100 +10000000000010100110 +00011000011001100010 +00000010011110100110 +00000110011010100000 +00000001000110010000 +00100001010111110110 +00000000000001101101 +00000001001000011110 +01000000000010000011 +00110000000100010011 +10000000010010001111 +00000000001010111011 +00000000000010110110 +00000000010010101111 +00000000100010011111 +00000000001111010100 +00100000010001001010 +11000000010100000000 +00000000010010010111 +00000110010111110110 +00001000010000111100 +00101000110011100011 +01110111100110010001 +00000100000110001101 +00000100001010010111 +00000000000111111110 +01001000000110010001 +00001100001110100110 +00000000000010100010 +10000110101010100110 +00000100000110010110 +00001001000010100111 +00000000010111011111 +00000000000011111000 +00000010100010100101 +01100000010111001000 +11000101001000100111 +00001000001010110010 +00001000110110110010 +00100001010010100111 +00000110000110101001 +01101001001011000110 +00011000001101000011 +10000011000001100011 +00001011010110011010 +00100000000101110010 +00000000000101101111 +10000010000001101010 +01111100000010110110 +00001001001101000111 +00110000000111010000 +01000001010110010011 +00000100001010110000 +01000001101110100000 +00000101010010000111 +00000000000110010110 +01110010111000011101 +00101000001110000000 +00000010110010010110 +00101000000011100010 +00010000110001001110 +00000000001110011101 +01000010101010010010 +00000000010000010100 +00001110111100011011 +01000101000001001100 +01101000110010000110 +01010100100111100000 +00100000000111010101 +00000000000010011011 +00000000000110010011 +00000001011000011011 +00000110010010110100 +10001000000010101011 +00000110101010001100 +00011000000110000000 +00000000001110010111 +00100110001110010011 +01001001011011010111 +00000001000110010111 +00000000001110010101 +00000000000010011111 +10000001000110000011 +00011000001001011100 +10000000000101110010 +00000110111010100110 +00000000000000101010 +00000000000010000001 +00000010000110110110 +00000000001111100111 +01100001010110111101 +00000010000110000010 +00000000001010000011 +00000001001110000001 +01000000100000011101 +00000010110010000111 +01000001100110101111 +00000000000011111101 +10000000000010100110 +00000100000001001001 +00000000000110010000 +00001010111101011011 +00001111010110011111 +00001001001010111111 +01000001010110100010 +00100000000011111011 +00000000000110000100 +00100010000010011011 +00000000010010000001 +01110010100010000000 +10000001000111100011 +00001000000011011011 +00000001010010011101 +00001000100010011011 +00000000001101011110 +01100010010111101101 +01000000000000011001 +00000000010010010000 +00000010100100000001 +00000000100010001001 +01000000001010010010 +00010111010010100101 +10000110101010010000 +00000001001110111000 +10000001111000010111 +10000000110110101111 +00000000100110111100 +00000110111101011100 +00000101001111000101 +00000100011001101001 +01000000001110111101 +00100001010011100011 +00000001110111100100 +00000010100000101000 +00000001010010100000 +00001000000110110011 +10001000110000100110 diff --git a/ga-logs/generation-479.txt b/ga-logs/generation-479.txt new file mode 100644 index 0000000..3745c5d --- /dev/null +++ b/ga-logs/generation-479.txt @@ -0,0 +1,400 @@ +00010011110011100010 +00000000001011110100 +00101001100000000010 +00000010001000110111 +10100100111001011011 +00010001001011110110 +01000000000010101111 +00111000101000010110 +00010100100010111111 +00011010000000001111 +00000000001101011101 +01000000101010100111 +01011001011010001101 +01000010111011100110 +01100101010110110111 +00000000001010011111 +10000000000010100111 +00000000000010001000 +00000000000010000001 +00101101001010001011 +00100001101010110110 +00111000100010010100 +11001101101110010010 +01100000000010000011 +00000010000110110101 +01110000000000001110 +10011000010000110101 +00000011000010101011 +10011110001010000011 +00110100111011000011 +00010000001011000001 +11000001001010110100 +00000001010011110101 +11101100100000001011 +00000000000011011111 +10100101111110101110 +00000000100010010111 +00010000001000100001 +01100000000010100111 +00101101101110110110 +00001000101100010010 +01011001100010000100 +00000000001110000101 +00001000001011100111 +00100100010100100111 +10101000001010110110 +01100100000100000100 +00000000010000011110 +10010000000011001110 +00101100011010000011 +00111001000010000001 +10000000000010010000 +00100000001110000111 +01100000000010001111 +10000000000110010110 +00000000000110110100 +00001000000110000101 +10000110000000101111 +10100000101010000100 +00111011100101100111 +00011110100011110101 +00000000100011101101 +00000001000010000111 +00000100001010000111 +10010001000110000011 +00001000000111110011 +00111010000110000010 +11010000001011001000 +00000000101100000011 +01000000000010001110 +10110001011111011111 +10101100010111010101 +00000011100001011111 +01101010011111101010 +10000000000011010110 +00000000001110001110 +00000110010100011100 +00000000001110011100 +00000001000110000011 +00000000101010110010 +00000001000010100011 +00000100001001100101 +00111011000010000110 +00000000001001010011 +01010001010010110111 +00000100001010111001 +00000000000010001101 +01111100100011010110 +00100000101010011110 +00100001100010000100 +00010110000010011100 +00101000001111110100 +00100100000110011100 +00000000000010101100 +00101101000001010001 +00000001010111001011 +00000001000011010100 +01000000000010000001 +00110000110010110010 +01101110100010010100 +01011001000010010111 +01000000011110001111 +10100000011010001111 +00000000001010001110 +00111010001001010011 +00001100000001000011 +00000000010011110011 +00100100011110101100 +01000000000001110111 +00100001000110010100 +00011000010111000110 +01100100110011110001 +00000000010000110000 +00000100011111001111 +10110000110110110110 +00000110000010000110 +00000011000010110101 +00001100100011000111 +00100110001000001000 +10010101000010111111 +00110100100110111011 +00000000000111001100 +00000001010110010100 +00011000110001111001 +00111000001010010101 +00000000000110100101 +00000000001010110101 +00010000000000000101 +00100110101001001101 +00000010010001011110 +10100101011010001111 +10000010100110010011 +00000000000010001011 +10011001100110101111 +01100100110011111001 +00000000000001110110 +00000001010000001001 +00011101010111101111 +00101001000001001111 +00100110000010010010 +00000000000010111111 +00000000100010000011 +00111100100100001100 +00000001010101010101 +00011001000011110111 +01000001010111100010 +00000000000010000011 +11000010010001011110 +01011000001111110110 +00000011101101100111 +11101101100011100101 +00010000011011000101 +01000000101010010101 +00100001100100011101 +00000100001110010101 +00001000100000000101 +00000100001000010001 +10101000100000101001 +01101110101010011100 +00000000101011100000 +00100100000110010001 +11101110011100001100 +01000110000000000101 +00000100000010101111 +00000001000010000011 +00000100000010110100 +00000101100010111111 +00011001100001111011 +00100101000011001100 +00110100110111101011 +01000100000000001111 +10100100011100101100 +00000000000011101001 +00100000000010001001 +00010110001000011100 +00000100100101101101 +00010100100011111111 +00100011000010101011 +01000000010011011111 +00101101100100101110 +00000000000011101011 +01101000000110011111 +01000001001111111110 +11000011001110110100 +01000000000001100111 +00000110000100010110 +00000000000011110110 +00100000000011000111 +00000000000011110101 +00011001000000000011 +01000001001011101111 +01100100110111110001 +00100101000110111111 +11000000110001000111 +00100100000111100001 +10000101001000011001 +00000100110011010001 +01100100100000011111 +00100001001010010111 +01100011100001100111 +10100100100010111110 +00000000000010110111 +00000001001010100101 +00001000000010010110 +00000000000010001010 +00000000000010100011 +00100011001010000001 +10000000100011110101 +00000000001110110100 +00011000000000100100 +00010000000000000011 +00000001000000000011 +01000000001110100011 +00000000000110000100 +00010001010011101101 +00100000000000000001 +00000000001010111011 +00000000000110000010 +00000000000011101101 +11000000001100101101 +00000000000000110100 +00100000000101000011 +01000100011010010101 +00100001000001100110 +10000100100010010110 +01101110011100000001 +11000011010010000100 +00010000101101110011 +00000000000011011111 +00101010011000111101 +00000100000110000100 +00100010010110000111 +00000001001010010111 +10000000111000011101 +00100100101101011111 +10100101100101001011 +10010110110011100100 +01001000101000000000 +10000001000010000111 +00000000100010000011 +00100000011000001111 +00000000001010010111 +00000000000010110100 +00000000100010111110 +00010000000010110111 +01100100110011110000 +00000000010110100110 +10110000000010110111 +00000110010010010011 +10110100100110101110 +00000001001000011101 +00010010010010000100 +00100100010110000101 +00000000100010110111 +00100110011010010110 +00000010000110111110 +11001100001010100111 +00000000101101111100 +00000000001000011001 +01111110110010110110 +00100110000110010111 +00000110001010010101 +00001010101011000011 +01001001101000001111 +10101000001000100000 +00000010000000011111 +01000010000110010100 +00000000000000000001 +01101100001011001110 +00000101011101011010 +01000000010011010100 +10101000001010100111 +00000001000011110101 +01000000111010011101 +00000000000000000011 +10000000000011100100 +10000000000011111101 +00110100010001111111 +10000000000000000001 +00000000000010110111 +00000001001010010010 +01101101100011111010 +11000001001010000111 +00100000010011110101 +00100000010010001000 +01000001101011100110 +00000100001111000011 +00000000000010001011 +00001000011100000011 +01100000011010001111 +00000000000010010110 +00001000000110011110 +00100100010010011110 +00010000000000011110 +00000000000010100110 +00000010000010101100 +00001000010110011010 +01100000000110000011 +00000000000011100011 +10010000010000011100 +00000000010010011100 +00010000001000010110 +00000010000010110110 +00011001010111000111 +01100000000111011110 +00000010000010000110 +11010001100010000011 +00000000110111101000 +00000111000100000111 +00100000001010100110 +10000100000000000010 +10100000100000000100 +00000000011011001000 +00010000000000000011 +00001000110011101101 +00101010011001011111 +00001000110011101101 +00000000011010010001 +10000000001000001100 +00001111000000010010 +00000001000110100111 +01000001101101100110 +00000100000110000111 +00000100000000000100 +00000000101011100000 +00111101101100010010 +00001000000110010110 +00011001001011110101 +00001000001110000111 +00100000010010000001 +00000000011010011101 +01010000000010000110 +00100100010100000111 +00010000001010110111 +00000000001011001111 +00111100010010100110 +01110000000000001010 +00000000000001110101 +01000000000111100011 +00000000001010000110 +00000000000010100100 +00001001010111111100 +00100110001000011111 +00100100010110010111 +10110100100010001110 +00001010100011110101 +00101101100100101110 +00111010001001010011 +01000100010110010110 +00000101000110010111 +00000000110100000011 +00000100000110010110 +00000100000010110110 +00100000011000000111 +00100000000110110100 +00001000010010100110 +10000010000000101111 +00100000001010011110 +00101101110011111001 +01100101100101001011 +00000000001010111010 +00011111001011001111 +00000000000010001111 +00000010001110001100 +01111000000011001111 +00100010001011001000 +00100100001010010101 +00000000000010011111 +00000000001110110110 +00000000001000110100 +10111010001010000110 +00000110010010110011 +00000000011101001100 +00000101000010110110 +00101000011010110110 +00100001101001001111 +00000100010110110110 +00010000000001110000 +01101110011100110101 +00000010010011000011 +00000100100010011110 +00000010001010011110 +00100000000010000011 +00000000001010111111 +01001101100101001011 +00100000111010011101 +01101110100000010011 +00001001001110011000 +01001011000011001010 +00011101101111110111 +01001100010001011011 +00010001110011001100 +00011001001010011100 +00001001000111100110 +00000000100011100110 +00010000100111101011 +00000000001011111111 +10000101110110001011 +00000000011000000011 +00000001101010010001 diff --git a/ga-logs/generation-640.txt b/ga-logs/generation-640.txt new file mode 100644 index 0000000..72d566e --- /dev/null +++ b/ga-logs/generation-640.txt @@ -0,0 +1,400 @@ +00000000001011111010 +00110001011111110110 +00000010011000010111 +00000101101101011000 +10010000000111110001 +00000000001010000110 +00010100010010101100 +00000000011011010111 +00000000000011011100 +00000001110111111100 +00000000000010010110 +00011110100110011111 +00000000100010011110 +01010000001110111110 +11110010100011010011 +01001110000110110101 +00001001101010000001 +00010000010001000100 +00000000100111010011 +00100111000111110000 +00010100001010100111 +00000110101001101010 +00000000001111101111 +00000001010001010110 +00010001110111111100 +01111110010001111111 +10100010111111011100 +00001101100111000100 +00000000010011011111 +00011101000011111110 +00101000011010011010 +01110000100011100011 +10001001011011111110 +00101011111001000100 +00001001110011000011 +00000000110111101100 +01101111011001110101 +10010110001110100011 +00000000011110000011 +00100011001110100101 +00000000011011000101 +00000000111011011010 +00011111011010011000 +00001100110011010101 +00011100011010011010 +01001000010010011111 +00000000000001000100 +00000111101011000110 +00000010110111001000 +10001011101010011110 +00010001110011111100 +00001100100110011011 +01011001000100110011 +00000110001111001011 +00000000001010110111 +00010101100010010100 +00101110011010011010 +00000010000001000100 +00000001000010100011 +00000001011110110010 +00000100001110000100 +00000000101111000010 +01110001111010110011 +00010100000110000100 +10100010000010101101 +00000000001100011101 +10000011001110111010 +10001001001111110110 +00010010001011101100 +01011000111110110111 +00011110000111100010 +00000010001110000001 +00000000101111110001 +00000001110100111110 +10101101110011010010 +00000000101111010001 +10010010000010101101 +00010000011111001110 +00010100100110011000 +10011100001101111111 +01010001111111111010 +10000010101010010011 +00100001011001111011 +00000011000010010011 +00011101111011000011 +01001001110011010011 +00000000010001000100 +00010010100010000011 +00001101100001010001 +00100000011010000111 +00000000100011111110 +00000100000010000011 +01110000101010110011 +00000000100111010111 +00000010001111101111 +00000000000010010101 +00001000101010000001 +00000000010001000010 +10011000010010000001 +10101011101111001010 +01000100001010011110 +00000010110111011000 +01000011101001011000 +00000000100011000101 +00000110010001111001 +00000011101110100011 +00001001010110100011 +01001000011010011010 +01001000011001000001 +01000101001010110100 +11010100001011111000 +00000000010011010001 +00000010000011110001 +01011000110110110010 +00000110001010111101 +00000101000001011010 +00001001000101101001 +00001101100110011011 +00000000000010111101 +00001010101110100001 +00100001011010111100 +10101011000010000011 +10011010010100000111 +00000110011111001001 +00101101111010001010 +00001000100111010010 +11001000100101010010 +00001000001010000000 +00110000101010110111 +01010001000011110100 +00001000001110000010 +00000000100111101011 +00010001110100111110 +01000100011010111000 +01010000000100100011 +00000010010011010101 +00000010011010011010 +00000000100110011111 +00011010100010000011 +00100100000001110100 +00101100101110000001 +10011001100011100000 +00010010010010110100 +10101101100111100101 +01000001001011000110 +00000000001111111010 +00010101000010100101 +00100001000110100110 +00010011000010101000 +00001011100011001110 +00000010010101010111 +01000100010010010111 +00000000110111101101 +00010010001011110101 +10001011101110011010 +00000000001010000011 +00000000000111010001 +00100100111011000111 +00001110000110101110 +00001110001011110110 +00000000111110101111 +00011000010010001001 +00000011000011110100 +10010110001110111110 +00001001110001101100 +00101100000011110000 +00010000000010000011 +00001101011011110110 +00010001110100111110 +10000000010011010111 +00000000001111101010 +00000001111001101010 +00000000010110000001 +00000000000100100111 +00010110001110000001 +00000010000011111100 +00100100001110000100 +00000101011010001001 +00000011001110010110 +00111111011100111111 +10000000001011101101 +00010000110111111110 +00000000000100000110 +00000001111010000111 +00000001100010010110 +01010111000011010101 +00000010011011100101 +00000101001111010110 +00100101101010001001 +00101111100111100100 +00010100001100110101 +10100010001101010111 +10111100011000100110 +10101011000011111010 +00010101011111001110 +00010000110011100000 +00000100110111100111 +00100000100010011101 +10000000000010001110 +01111011111100010110 +00001101100111110100 +10001100011011110110 +01000000000011111100 +00001000010001010100 +00000010101110100010 +10100101010011101001 +00000100100110011100 +10001011011111110001 +00000000000011111110 +00101000000010010101 +00000110011111111010 +00000000000011011101 +01000110010101010111 +00000000000011111110 +00101010100110110110 +00000111011000110011 +10100101011011101001 +00101100010011101010 +00000000000011110110 +00000010101110101001 +01110000110010011010 +00001011010010000010 +00110001010010010101 +00000000001010111000 +00100111000111110110 +00001000010001010000 +11001000000010110101 +00010010011111101101 +00000001101010010110 +01101100000001111100 +00100110001010111101 +00000100000001011111 +00000000010100001101 +00001000101111011010 +01011100010001111111 +00111101100111010101 +00111100010101111110 +00011000111111010111 +11010100001110101011 +10001000011011011100 +00111101111011010010 +10100111100010111000 +01010111010011010100 +00010100010010100111 +00111100010001111111 +00010100110111010011 +01100001101000110100 +01010100111111110101 +00001001001011010010 +00000000011011101000 +00010100011011010100 +00011100000110001100 +00000110011100111010 +00000000000010010110 +00101011001111001100 +00100100111111010101 +10010000101101110010 +10000100001111001101 +01000001010101010110 +00001110000010011110 +01001100011010110101 +00101010110110110011 +01110000101010110100 +00000001001011110111 +00000110001010111000 +00010000010001000101 +00000001000010100010 +00001100101010000111 +00001100111111010110 +10001001001111111101 +00000000000000110111 +10011010011100000001 +00000110001010111101 +00000000110111011111 +10010000111111000100 +00010001110100111110 +01000000111111010011 +00000100111111010101 +10100111000110111011 +00010101010111101010 +01111100010001111111 +00011111010010011011 +00100111001111110000 +10001000011001100010 +01000000011111011010 +00010100000011110100 +00000010100111111110 +00001100001110111100 +00110011111110011100 +00101100000011110110 +00000001000110001001 +10111011011001100110 +00000010001011100000 +00100000001111101010 +01010000101111010011 +00001101001011110110 +10000011001110111000 +00000001011010100001 +01100010010111000111 +01010100011010100111 +00000000000011101111 +00001000001110010101 +00001110001011010011 +00110011111110011110 +00000001110110010010 +10110111001110111100 +00000010010110111001 +00000010000010111100 +00111001101001010110 +00000011001111010110 +10010000011100110000 +00101001111111010110 +00010001011110100101 +01000110001010111101 +00010010000010000011 +00000000001011100111 +00000000100100100110 +00101110000111000100 +00000001100011110101 +00000010001111010110 +00001100010011010001 +00010000000011110010 +00000010000011110110 +00001100001111100000 +00000001001010000111 +00111110010011110101 +10000010100110111001 +00000010000011010100 +00011111010010011011 +01000000000010011101 +00010000000010010010 +00000001110101010110 +01011000000001110110 +00001010000010011001 +00000000000110011011 +00001000011010010000 +00000011010110000001 +00000000001010001110 +00010000000010010101 +01000111101110101100 +00111110010001111111 +10000000000010000111 +00000100110101110101 +00000011000010101000 +00000011000111011001 +00000100001111101000 +01111001000111110100 +00000100111110101000 +11101010110010000000 +00100101110000001101 +00000000111111011111 +00101111100110000111 +00101000100110110011 +00001001010001010110 +01010101110111011100 +00001000111110111011 +00000010000010111001 +01000011101000110101 +00000010000111100000 +00011010001011000111 +00000111010110000110 +00111011111001101000 +00000000111111011111 +00100001011000110111 +00010100110011100011 +01000100000010000000 +00100000000001111111 +01111110010010010101 +00000000000110010101 +00000000001010000110 +00001101011011101100 +00011000111110100110 +00100100001010010001 +00000001101011110111 +00001001110111011100 +00000010100010011110 +00011011100011000100 +00000000000010000111 +00010001110011100100 +00011111011001010110 +00010000000001010110 +00001001010010111101 +10000011000110000111 +00000000000111001011 +00000000011010000101 +00000100001111000111 +00101111000110100000 +00010001011000011000 +11110010010110011010 +00001010011011101100 +10101001001111111111 +00001011011110011010 +00000000110010010101 +00000000000011000111 +10000000000110100010 +10001010111111101100 +00000000010010010101 +00000000100110000010 +00001001100010000011 +00001000010111000101 diff --git a/ga-logs/generation-884.txt b/ga-logs/generation-884.txt new file mode 100644 index 0000000..414db7b --- /dev/null +++ b/ga-logs/generation-884.txt @@ -0,0 +1,400 @@ +00100010100010001001 +00001101000011111001 +00010111000010100001 +01011000001011110001 +00101101000111100000 +10000000010010110000 +00000111110011100101 +00000000100010011010 +01000010100000100100 +01010000100001110110 +00000100011010111001 +00000111001100011100 +00001000010011100111 +10000000000011100111 +10010000010100100110 +00000000111111110010 +00001000100010001101 +00000010010010110110 +00000001100010100001 +00100011011001001001 +00000000000001100101 +00000000000010110110 +01011000000000101101 +00011000010011100000 +00000001101010110011 +00001001011010010110 +00000000011110011100 +00000000010100001001 +00000100100010010011 +00000011000110100110 +00000001100010100001 +00000000000000110011 +11001011010011001001 +00000100010101101101 +01000000000110110110 +00000001011000111001 +00000011010111011000 +00000000000010001101 +00000100011110011110 +00111000100100001001 +00000000000010101100 +00010000000010010110 +00000100000011100000 +00000010010010000010 +10000010011110100011 +01000000100010100001 +10000000000110110101 +00000001000100110000 +00001000000010100010 +00000111000010000001 +00000000100011100011 +01000011000011100010 +00001000010110011100 +00000010011111100001 +00000111010010010110 +01000000110101000110 +00010000000110000011 +00000100110011001011 +10001010010110010111 +01100000001011010011 +00010101111111101011 +00001001000010010011 +00010001010101100010 +00100010000010001101 +00000000010011110110 +00010000100111010100 +00001011001011110100 +00000000000011100111 +00000000000010001101 +00100011000111000000 +10010001000010111011 +11100010000101100101 +00000000001010111000 +00000001001001001011 +00010010011010111001 +00011100000000001001 +00000011000111100101 +00000000000011001000 +00000000100011011000 +00010010110011110011 +00100100011111001110 +01000000010110010000 +00010101100010010001 +00000011001110101010 +00000010011101111010 +00010000000101011111 +00000000000010000001 +00100100000001101110 +00110000100010000100 +00100000100010111001 +01001010110001111111 +01010010000000010110 +00000111110011101101 +10011100100011010011 +00110000100010000110 +00000010000001011101 +01000010000110101011 +00000001000011011010 +11000100010000100110 +01000000000010100110 +00000000000001100011 +00010011000011101100 +00000101100011110010 +00000101111011110010 +00000000010101000011 +00101100010011000100 +00100000100010001101 +00100000011111001100 +00010000000100100110 +00110101010011100011 +00010001010111100110 +00100000011010110011 +00000000000010110110 +00000100100011000110 +00000001000100001001 +00000000010001001011 +00011010001010111000 +01000000100111000100 +00010100010100100010 +00001010000110010111 +00000000000001111110 +00000101000001110000 +00010010011010000101 +10101000001011111001 +00100000011110010100 +00100000000010111010 +10000000001110000110 +00000101010110110001 +00000110000110110101 +00000000000010111000 +00000000010011110000 +00001000011010011011 +10011100010111001011 +00000000000011000110 +01001001000010000001 +10000000000010001111 +00000000000110011100 +00001001011000110001 +00010010011101111010 +01000010001011010011 +00000000100011110000 +01000000000010011001 +00000000000011111101 +00010000101101100001 +10000001001001111000 +00000110000011001100 +01000000000111101010 +00010011100001100011 +00000011011011110110 +00000000000010001010 +00000110000101001011 +00100000110101101100 +00000000011010111000 +10100000101010101001 +10000011110010110011 +00010000001011010010 +00000001011000110001 +00100000100010010110 +00001000011000110010 +00000100010111111010 +00000000100011111110 +00001100111100000100 +00000100000000111101 +00000011011011110110 +00000000100101100101 +11100011110011000011 +00000000010100100110 +00000101000110100011 +00110100110001000111 +00000011000100110110 +01110111000001000010 +00000101111110101000 +00000000100110000011 +00101101000100000110 +00100100110101101011 +01000101011000101110 +01111001110000110010 +00100001000101001000 +00001000010110011100 +00000000000011010111 +00100010000000110010 +00000000000110011110 +00000000001110101110 +01000110000110000110 +00110001001010000001 +00000000010000010001 +01000001000011010000 +00000000000010110010 +00001000000111110101 +00000000101010110100 +00001000000110011100 +11100000001101100101 +00000000000011101001 +00000010010010001101 +00000111010011000010 +00111101010111001101 +00100100000010000001 +00110100000101001011 +00000001000100110100 +00000000010110000001 +00000110110110010111 +00100011101110001101 +00010001010101001110 +00000100000101100011 +00001000011100100000 +00000101110111011100 +00000100000110111010 +01100000101011110101 +00000011010100010110 +00000000100001000001 +01000011110010100101 +00000000100001000001 +00000000010011110011 +00100100010011010111 +00000000100001010001 +00010011000110000000 +00000001000111110100 +01000000000011100111 +00100011011000001111 +01000101001011101001 +00000001100010111001 +01100010110110010111 +00001100011110001111 +00000101000101111100 +00000001000100001101 +00011001100010100000 +00000111100011000100 +00000000000110000011 +00110001110010110010 +00000001010010110111 +01000001000011100100 +00000010001011010011 +01100011000010101010 +00000000011011101001 +00000001000010110100 +10111110000011101011 +00001010101011111110 +01001010110100011010 +10010011011110001101 +00100010000110101010 +00000000111100000101 +10010100000011010000 +00010011101011010110 +00000001001011010010 +10000000000010010010 +10000001000011011101 +11011011100111011000 +10000000110110100010 +00000011000111000010 +10000001000111000111 +00001000100010101101 +00000001100000100001 +00101000001110110010 +10000000000010110010 +00010001000010010101 +00001110100010000011 +11010010110010010110 +01100010001010010011 +00011100000000101010 +00100101000101111001 +00000101011011110110 +00011010111111101011 +10000000010111110011 +00000000111101110010 +01010010011100010110 +00100000011011011010 +10000101010011110101 +10000100011010101010 +00000101100110000010 +00000001010011010011 +00000000100110100101 +01000011100010110110 +00000000000110110010 +00101010011010101011 +01001000000001010010 +01111011011110011100 +00100000000101000110 +00000010101000100010 +11010000101111110011 +00000000100011010000 +10000000000011110110 +00100001000010101001 +00101000100010000000 +00000000000001101001 +00010111110010101101 +00100100000010110111 +00000000010010000001 +00000001000101101101 +01000000000011111101 +00011110000000100111 +00100000011110001101 +01000001000011111100 +00100000000100110101 +01000000001010111000 +00010001000010101011 +11000010001011101100 +00000000000010110011 +01000000001010110111 +00000100010011110011 +00100000001011010000 +00000000000011101111 +00110000000110110011 +10000101011011110101 +11100000000101100101 +00000111001011011011 +11010010110001101100 +00100100000011100110 +00000000100111010111 +00010010011010000110 +00000000000011101001 +00000011000011111000 +00000000000011001100 +00000000000010100011 +10000101110010000011 +00000110100010110000 +10101100010010001110 +00000011000110010101 +00100010001001001100 +10111101011100011101 +01001000010101011000 +00100001100101010101 +00111110000110011100 +00000010000110101100 +00100100110110101110 +00000000000110011100 +00000011000110000111 +00000101100110011001 +00100100011100000000 +00100100000101001001 +10000001100010111011 +00010000010110100110 +00001000000011011101 +10000000000000000110 +00010001000001100101 +00000010010110011111 +00000011011010110010 +00010011010010110000 +00010011000111101111 +00010010011101111011 +00000010001111010111 +01010000100011001101 +00100001000110111011 +01000000011001101010 +00001100011110110000 +00001000111111000111 +11101000001011011011 +01100000011010010001 +11000000101111110110 +00010011000111010010 +00001000000010100001 +00000000001010101011 +01100001000011010001 +10000000100010000010 +00000010110010111100 +00000000000111010000 +01100000000010000010 +00100000000010011101 +00000000000011100110 +00000000100010001110 +00001011101001110101 +00000010011100101010 +00000011010011010011 +00100100000101001011 +01000101011010101111 +00000100000011111110 +00000000000010110110 +01000110100110101110 +10010100110011110101 +00000010011011011110 +00000010000000001110 +00011011001000000001 +01000011110011110111 +00000000001010110010 +00000011010010010101 +01000001111010111000 +00000000000111101011 +01001111110111001001 +00100000000010100110 +00000001001101001010 +00000010010010111010 +01011001011010001001 +10101110000010101101 +00000100010010111101 +00000000100111001111 +00100101010111001001 +00100011011011010010 +10010010000010110110 +01000001010111010110 +00000000001101101101 +00101101000011100011 +00000000111111110110 +00001100001010111010 +00101010010010101011 +10000001010111000110 +00000000001100110111 +00000100010111110010 +10000001100010110110 +00001010011111100001 +00001001100010001000 +10100000001011100101 diff --git a/ga-logs/generation-943.txt b/ga-logs/generation-943.txt new file mode 100644 index 0000000..54651d6 --- /dev/null +++ b/ga-logs/generation-943.txt @@ -0,0 +1,400 @@ +00000001001011100100 +10010001110011111110 +00000000000010100011 +00100001000011000001 +00001000000010100101 +00000000000010110101 +00100000000110100010 +00010000000010000010 +00111000000000100000 +10001010000011010001 +00000001010001110110 +00001000000011011000 +00010000001010110111 +00100001000000000110 +00000000000010110110 +01000000000011111000 +00001110010101101001 +00001000001110001001 +00000000010010010000 +00000110010010010101 +00000100000110100011 +00001000001110111010 +00010001000000010011 +00100001000010110111 +00001010000101110111 +00000000000000110110 +00000000010100100001 +00000010000100100111 +00000000000010011011 +00000000000010100101 +00100000001000011001 +11100011100101100011 +00000001000000100011 +00000000000001101010 +00000000000010010010 +00001101001010110011 +00100100000110100001 +00000000000011100001 +11000000010110010111 +00011111100101010011 +00100100000100010101 +00000001000011010010 +01000000000000011111 +00000001011010110101 +10010010000010010110 +00000000000010000111 +00000000100010100101 +01000000000111010000 +00010101100001101001 +10100000000010100110 +00000010100010100111 +00000001000001100011 +00010000000011000101 +00000000001011101100 +00000001001011110100 +00000000000010011101 +00000010010010100001 +11101101100110001110 +00001001000011000010 +11101101110100001110 +01000101111010111111 +00000011010101100010 +00001000000010110011 +00001000000010000011 +00000010001110011111 +00000001000000010000 +00000000000010101001 +00000000001010100111 +00000000000010001100 +00011110000010101010 +00000000010100111100 +00011000000010011011 +01000000001100011011 +01000000000010100101 +00000000110000110101 +00001001101110100010 +00000001000001000111 +01000000000011010000 +00000000000001000111 +01000010000010111111 +00000000000000100000 +00000000000010111010 +00000001001010011101 +01000000000001100011 +00101000000010110001 +00000100000010000111 +00001000010110110110 +00000000000110100001 +00001101000010100001 +00010000000000001011 +00010000001110100011 +00000000010001110101 +00010000000011000100 +00000100000010000010 +00000000100011110111 +10010001100000111011 +00000000010010000010 +00111010000110110001 +00110101100011110111 +00000000000010111000 +00000000000011000101 +00000000001000110110 +00000010101111011011 +00000000000010010011 +00000001100110000011 +00000001001010110110 +00000000100010011110 +00000000000011100010 +00000000010100111100 +00011100000010000100 +01000000010001110000 +00000000100011000100 +00000000001000110010 +00000000001011101100 +01100000001110100010 +00100001010110101001 +00100000101011001101 +10000000000000101010 +00001101100011000011 +00010000001110010111 +01100010001111000010 +00000000000100010011 +00000000000010011011 +00000000000010010010 +00000000000110001001 +00000010000010100100 +10011000000011100101 +00100000001010110111 +00000000010111010000 +00000000000010100001 +00100000000000000110 +00010000100010100011 +00000001000010000011 +00010000001110010111 +10001110001100101000 +00010000010001100001 +00000001000001010101 +00000000000010110010 +00000000000011110101 +00010111001110010001 +00000010000010000010 +00000000000010100101 +10010010000001110011 +10000010100010010110 +00000000000010100101 +00000000000010000101 +10000000001110000010 +00010000001110000010 +10000000000010011000 +00000101010010100001 +00100001001010011100 +01000000001110100011 +01000000001000110011 +00010000001110000010 +00111000101010110110 +00000100000111110111 +00000000000011101011 +00010010000110010001 +00101000001010010010 +00010110001011011111 +00000000000011011001 +00000000000000010100 +00000110000000110101 +00010100100010011111 +00000000000100101001 +01000001011010011110 +00000001010110001011 +00011000110000110001 +01000000110100000001 +00011001000010001101 +00010110100010011101 +00000011000111010110 +00000000000010001110 +00000100010111010000 +00000000000010101000 +00001000010010000010 +00000000000010000100 +00001000000011010101 +00000000001110100010 +00000010000100100101 +01101010000010011001 +01000000010010110110 +00100000001010011010 +00000000000110111000 +00000010010100100011 +00000000001111010101 +01000110000011110010 +00000000000001010111 +00110000001101010001 +01001100100011110010 +01000000000101100101 +00101010110110001001 +00000000100010101001 +00000000000010100001 +00100001000110000101 +00000000000010100010 +11000000010001000111 +00000001001111011111 +00110011111000110011 +00000100000011110100 +00000010110000110111 +00000000000110011001 +00000000000010100011 +00000000000010110010 +00000000000010110010 +01001000010010110011 +00000000000010110001 +10000110000010110101 +00100010000100100011 +00000101000111100110 +00000000000000010100 +00000000010110011010 +00010000001011110100 +00010000011000000111 +00000000000010001110 +00000001010011000010 +00000000000011011111 +00000000010010100001 +00000011000010100010 +00000000000101100011 +00000101001011111100 +10000010000010100111 +10000000000001111110 +00000000000011000010 +01000010010011100001 +00001000000001110110 +00000000001000001100 +10000001001111110111 +10000100000000111001 +00000001000110010001 +00110101100010111000 +00000000000010000100 +00000001000011000110 +00000000101010111101 +00001001001010100001 +01010000100000100010 +00000000000010000110 +00000001001010001001 +00000000001110000010 +00000101000100010011 +00000011011010111101 +00000001000000110111 +00000011000111110110 +00110101000111101101 +01001101001011101001 +01010000010001000010 +00010100000010110011 +10000000001101110000 +00000001000010000111 +00000000000110010100 +00000000010010100001 +00010100001001110110 +00000101111010110110 +10100000010100100000 +10000001110011100101 +00100000000000000101 +01000000011000101000 +10000000001010110011 +00000000000010100101 +00100101111010110111 +00010010010101101001 +01001100100110101001 +00000010100100100101 +00000000000011110101 +00101000000001001001 +00000000000010100101 +00000000001111110001 +00001000000010011011 +11000000000110100011 +00100000000010011000 +00010000000001100011 +00000010100010101100 +00000000001110000010 +01000001000000101100 +01100000001110010101 +00001100100011010001 +00000000000000100011 +00010001010110100011 +00000001000001100100 +00010110000011111111 +00000000000010101011 +00000000000110000011 +00000100000010110001 +01000000110000110101 +00100101111010110111 +00000001000010110110 +00010000000010011101 +00101000001110100110 +00010000000010111010 +01000000001101001101 +00000010000111000011 +00000001110010110111 +00111010100110110010 +00001010001010001100 +00000000000001000101 +00000000101011110001 +00000100000110100001 +00000000000010100001 +00000000000010000101 +00000000000000100011 +01000000000010000101 +00001000000110010111 +00000101000110110001 +00000000000011011000 +00010000101111110001 +01001011101011110110 +00000111001010100001 +01001000001010001010 +00000010010010100101 +00000010000101000011 +00000000101011010000 +00000000000010110011 +00000000000010000011 +00001000000010100111 +00000000000010111010 +00011100000100110111 +01001100100011011001 +00000100010101010011 +00000000000011110101 +00000000000000100011 +01000001000010110001 +00011000010011101101 +00000000001010001010 +00000111001110011100 +00000001101110010101 +00100001000111010010 +00000000000010100001 +00010000000100000010 +00000000001010010101 +00000000000010010011 +00000000110010101101 +10010000100110010110 +10000000100110110110 +00000000000000010001 +00000000000010000100 +00000000000010111101 +00000001000111010011 +00000000000010100111 +00000000110001011101 +00000101000011100011 +00000001001001011101 +00010000110011110100 +00000000000010011001 +01101010001010000010 +00000000000010100101 +00000000000010100001 +00010000000011110011 +00010001011011010010 +00010000000011000111 +10000000000001010110 +00000001000001110110 +00000000010110101001 +00000000000010000101 +00000000011000010100 +00000001001111100010 +00001001110011010011 +00000000000011110111 +00000000000010101000 +00000111000000110110 +01000101101110010001 +10000000000110110110 +10010100000010011110 +00000000001100001101 +00000000010111010000 +00000001001110101110 +01000001010011001101 +00000111001110101011 +00000100000010100110 +01000001101100001011 +00000000000001100011 +11010001000000000100 +00000000001011110111 +00000111001010100000 +00010000001010111100 +00000000000010000100 +00010010010010111100 +00100000001111111101 +01000000001101000010 +00110001110010110111 +00001000010001101001 +00010001001110011011 +00101000000101000101 +00000000000010100111 +00000000110001101000 +00000001101010001001 +10000001100011101001 +10011011101011111111 +00000000000010110101 +00000000000010011011 +00000000000111110010 +10100010100111001001 +01000100100001101001 +00000000110011110111 +01000001000011110101 +00001000000110010010 +00000100000110010010 +00011010000100100001 +10110101100010111101 +00000001000011010010 +00010000000000100111 diff --git a/ga-logs/run-ga-log.tgz b/ga-logs/run-ga-log.tgz new file mode 100644 index 0000000..fb62068 Binary files /dev/null and b/ga-logs/run-ga-log.tgz differ diff --git a/ga-trace.log b/ga-trace.log new file mode 100644 index 0000000..f5fd061 --- /dev/null +++ b/ga-trace.log @@ -0,0 +1,3298 @@ +Generation number 1 +00000001011100001100 +00000010011110101110 +00000101101001100110 +00001000100001100001 +00001000110111011111 +00001010011010001111 +00001011011101101101 +00001100000011111101 +00001100101101000001 +00001101001111111000 +00001110000011000001 +00001111000011101111 +00010000100111111110 +00010001000100000000 +00010001100010011010 +00010011100101011110 +00010101011000110110 +00010101110001000010 +00010110001011101101 +00010110111001110000 +00010111100001010011 +00010111110010001010 +00011001111111011010 +00011100100110000111 +00011110110011100101 +00100000101100001100 +00100000111110101100 +00100010011111000101 +00100100000100110000 +00100110101110010011 +00100111101000010010 +00101000101001111110 +00101010110101011000 +00101100101001000011 +00101100110011011000 +00101110000010100100 +00101110001010111000 +00101111001000011110 +00101111010000111100 +00101111101000001111 +00110010111100011000 +00110011100001110001 +00110011101001100100 +00110011111011100110 +00110100001010100010 +00110101110001010000 +00111000010100111011 +00111001110100010100 +00111010001011011011 +00111100101010110110 +00111100101111011001 +00111101110011000101 +00111111110100110100 +01000001000001010100 +01000001001111111101 +01000001110101011010 +01000010010111101001 +01000010111000001110 +01000101001001100101 +01000101100111111011 +01000110101001001110 +01000110110011011011 +01000111001100101111 +01000111010001001110 +01001101001011100101 +01001101001110000111 +01001110101001010111 +01001111111110000101 +01010000001011011111 +01010010100001101111 +01010100101110011110 +01010101000010110001 +01010101010110010010 +01010101101111010101 +01010110001101010000 +01010111001111100000 +01010111011101100011 +01011001110110110100 +01011100001010110001 +01011100110100000101 +01011101010010010010 +01011110111001010010 +01011111011000000001 +01100000001110100011 +01100000110001111110 +01100001101000100111 +01100010010011101111 +01100010010111000111 +01100010110110101011 +01100100110000100010 +01100101000000101100 +01100101110000000001 +01101010010001001100 +01101010101110101001 +01101011011011001100 +01101100010110000011 +01101101010001111111 +01101101011111110011 +01101111110010110001 +01110001110010101111 +01110001111110111110 +01110010111110000010 +01110100111011110000 +01110101010000010000 +01110111010001011010 +01111000110010000111 +01111001000001000100 +01111001000100010001 +01111001010011010010 +01111011101111110101 +01111111001111110110 +10000010111110000100 +10000101100010100100 +10000110111110100010 +10000111010010110011 +10001010101111001110 +10001100101011000010 +10001101001010001110 +10001111010010001011 +10010001011101011011 +10010010100000100110 +10010010110000010101 +10010100110100101111 +10010110101111110111 +10010110110001001011 +10010111111100011110 +10011000000100011111 +10011010011100010111 +10011100011111000100 +10011110101010100011 +10011110111011100001 +10011111010001000100 +10100000000100001111 +10100000001100101000 +10100010110111001010 +10100011001111111111 +10100100010100110101 +10100110100011010000 +10101001110111000100 +10101010010010100110 +10101100000001111101 +10101101111101101000 +10101110110001011000 +10110000111100111000 +10110010100110110010 +10110011011111011101 +10110011011111100000 +10110101001100010111 +10110101110001111100 +10110111011001010100 +10111000100001111100 +10111100010010111011 +10111100111000100010 +10111101000001100111 +10111101110000101010 +10111101111000111011 +10111111000110001011 +11000001001000101111 +11000010011100111101 +11000010110010110101 +11000011001111011011 +11000100111111011110 +11000101011011110010 +11001000011010000110 +11001000100110011110 +11001001011110011101 +11001010100011011100 +11001011011111110101 +11001011101010110010 +11001111110110010011 +11010000001110101110 +11010000010111110000 +11010000111010101010 +11010001000000101110 +11010001100000010110 +11010001110111100001 +11010010101000000100 +11010011010000100101 +11010011100100111111 +11010101010001100110 +11010110011000001110 +11011001011100110101 +11011010000010010010 +11011101111110110010 +11100011101001110001 +11100100000110011001 +11100101011001010000 +11100111000101011010 +11101011010000101101 +11101101111010111100 +11110000000011001100 +11110100001010011010 +11110101111000001001 +11110110001010000101 +11110110011100111011 +11110110110100101111 +11110111001001111111 +11111010001101011101 +11111011101011111011 +11111111011111000000 +Started at Fri Apr 25 22:39:39 +0100 2008 +Took 1598.862926 seconds +Generation number 2 +00000100101001100110 +00000101100010101100 +00000101101001101100 +00000101111001010100 +00001000101001110110 +00001010001010001111 +00001010011001000011 +00001010011110001111 +00001011011101101101 +00001100000011110110 +00001100010110000010 +00001100101000001111 +00001100101101111000 +00001111001111111111 +00010000110010000101 +00010001000000000000 +00010001001100010000 +00010001010100000100 +00010001100101011110 +00010001110110011010 +00010010100000100111 +00010010110111111001 +00010011100001110001 +00010100100010001010 +00010100111001001100 +00010101010110101111 +00010110111000001010 +00100000111110101100 +00100001110100010100 +00100010111110000000 +00100010111110000100 +00100100000100110000 +00100100000100110000 +00100100000100110101 +00100100110100100010 +00100110111110100010 +00101010110101111000 +00101100110001110100 +00101100110011011000 +00101100110011011001 +00101101110011010101 +00101110000101010000 +00101110001000111010 +00101110001010011001 +00101110001010110110 +00101110010001001100 +00101110101010010010 +00101111001000011110 +00101111001010111110 +00110011101111010101 +00110100001010011011 +00110100100011101100 +00110110001101011101 +00110111101110110010 +00110111110011110001 +00110111110100110100 +00111000010100111011 +00111000010110000011 +00111000100001111100 +00111000101100001100 +00111001110100000010 +00111010001011011011 +00111100001011100111 +00111100101011000011 +00111101100100011110 +00111101101010100001 +00111110110011010011 +00111110111111100001 +00111111110100110100 +01000001011000110110 +01000010101011011101 +01000010111000010101 +01000010111000011110 +01000101110110010010 +01000110001001001010 +01000111010001100001 +01000111100001000011 +01001000100001101010 +01001000110100000100 +01001100001110000111 +01001100101111011000 +01010000000001101111 +01010001000010011010 +01010010110101011100 +01010100001111011111 +01010101110001100101 +01010101111000001001 +01010111011010110001 +01010111011101100011 +01010111011111000000 +01010111100101011111 +01010111110001000100 +01010111111100000001 +01011011011000000110 +01011100100011110010 +01011100110100010101 +01011110111001010010 +01011111001111100100 +01011111011001000011 +01100000010001111110 +01100000110000100010 +01100000110110101011 +01100001000000110110 +01100001101100101111 +01100010001110100011 +01100010011011000010 +01100100000101100000 +01101000000100101011 +01101010101110101001 +01101011101111110101 +01101101010011111111 +01110000100111111010 +01110001110010101111 +01110001111111011110 +01110100111110000110 +01110111010001011010 +01111000100111111110 +01111010011011000111 +01111100101010111110 +01111111001111111101 +01111111010110001010 +10000010110111001010 +10000101100010100110 +10000110101011001100 +10001010101111000010 +10001010111010100001 +10001011101010110010 +10001100001000110001 +10001101010010001011 +10001110000011000001 +10001111010100100101 +10001111010100111100 +10010001001000010110 +10010001100010100100 +10010010110001110101 +10010010110100010001 +10010110110001001011 +10010110111110010011 +10011101110011000001 +10011110111010100011 +10011110111011001110 +10011110111011100000 +10011110111011100000 +10011110111011100001 +10011111010001110100 +10100000001100101000 +10100000001100101010 +10100100010100110111 +10100110011000000110 +10100110100011010000 +10101001110101000000 +10101001110111000101 +10101110001010111000 +10101111010000111100 +10110000111100111000 +10110001011111111000 +10110010111100011000 +10110011011111110001 +10110011111011000110 +10110110101110010011 +10111000011000001110 +10111001110110011100 +10111011010111010011 +10111111110100101010 +11000001011111110000 +11000001101000101111 +11000010010111111001 +11000100111111011111 +11000101011010110010 +11000101111011111011 +11000111010010110011 +11001001011110010111 +11001001011110011101 +11001111110110010010 +11001111110110010011 +11010001100000010110 +11010001100000010110 +11010010110001011100 +11010011100100111011 +11010111110011110101 +11011010000001000011 +11011101111110110010 +11100011001001100001 +11100100000110011001 +11100111000101011000 +11100111000101011010 +11100111101000110010 +11101010010010100110 +11101011010001101101 +11110000000011000000 +11110000000111001100 +11110001110001010000 +11110101111010101001 +11110110001000000001 +11110110001101010001 +11110110011100111011 +11110111001001111111 +11111000001110011111 +11111000010100111011 +11111000101001011110 +Started at Fri Apr 25 23:06:18 +0100 2008 +Took 1684.749211 seconds +Generation number 3 +00000001101000101111 +00000010011100001010 +00000011010001100001 +00000100101000001111 +00000100110100000000 +00000100111111011111 +00000101001001100001 +00000101111001000110 +00000101111001110001 +00001000101010100010 +00001010011001000011 +00001011111011111011 +00001100000110100111 +00001100001000110011 +00001100001010010110 +00001100100000010110 +00001100101000111011 +00001110001010011001 +00010000001011100110 +00010001010110011010 +00010010010111111001 +00010011011111110001 +00010011100001110001 +00010011100001110001 +00010011100001110001 +00010011110001010100 +00010100010100011100 +00010100011101010001 +00010100100010001010 +00010100100110010111 +00010101010110000110 +00010101010110101100 +00010101010110101111 +00010111011001000011 +00011001110001010000 +00011100101000101111 +00011101011100101011 +00011110110001000011 +00100000001101010000 +00100000111110101000 +00100010111000010101 +00100010111110110010 +00100100110100100011 +00100100110100100111 +00100100110100101000 +00100100110101110110 +00101000010001110110 +00101010001010011001 +00101010011110001100 +00101010110101110010 +00101100110011010001 +00101101110011010101 +00101101110011010101 +00101110000110010111 +00101110000111010000 +00101110001000101010 +00101110001010111100 +00101110001101011000 +00110011101111010101 +00110011110001011100 +00110011110100110101 +00110100001010011010 +00110100001011011010 +00110100111110000110 +00110110000100000100 +00110110001101011101 +00110111101110110010 +00111000010100111011 +00111000100001011100 +00111000100001111100 +00111000100100010001 +00111000111111011111 +00111001100110100000 +00111001110100000010 +00111001110100100010 +00111010010111010001 +00111100101011011111 +00111101001010101001 +00111110001010110110 +00111110010000111100 +00111110101011011101 +00111110111101100001 +00111111010100101100 +00111111110100110100 +00111111110100110100 +01000000000001101111 +01000001101010101001 +01000010110011110110 +01000010111000000101 +01000100001111010001 +01000100010100110000 +01000101100010101100 +01000110011001001010 +01001000100000101011 +01001000101001011010 +01001000101110011111 +01001000110100000100 +01001010001010011110 +01001010111000011111 +01001100111101011101 +01010000000001101111 +01010010110100010010 +01010011011101101011 +01010101111000001001 +01011000110100000100 +01011011011000000110 +01011100111001001100 +01011101010000001011 +01011110001111100100 +01011111011011100000 +01011111011101100111 +01011111110001100111 +01100000100011101010 +01100001101100101111 +01100010111110000000 +01100011000000110110 +01100100001111100110 +01100101011010111111 +01101011111000011000 +01101100000101110001 +01110000100111111010 +01110000110001010000 +01110000110111101000 +01110110010001011010 +01110110111110110101 +01111010101011011101 +01111111001111011100 +01111111001111111101 +01111111010110001010 +10000010011001011000 +10000010110111001010 +10001001011110011101 +10001100001000100001 +10001101010100111100 +10001101100000010010 +10001110111111101110 +10001111010110100100 +10001111101001101100 +10010000010110000011 +10010000111000111000 +10010000111100110100 +10010001110010101111 +10010010110001111100 +10010010110100010011 +10010101010110101111 +10011111010001101000 +10100000001100101010 +10100100010100110111 +10100110001010011001 +10100110100011010000 +10101001110101000000 +10101111010101110001 +10110000010100111011 +10110001001000010110 +10110010111100011000 +10110110001100001000 +10110110101110000011 +10110110101110110010 +10111001110110011100 +10111011110001011010 +10111011110111011111 +10111101110100101010 +10111110110011010010 +10111110111111100001 +10111111110100101111 +11000001011111110000 +11000001100101011110 +11000100010100111011 +11000100011110001111 +11000100100011100011 +11000101111011001111 +11000111010010110010 +11001001011010001010 +11001011011000000110 +11001101011111010000 +11001110111001010010 +11001111010110000010 +11010011010100100100 +11010101110011110101 +11010111110011110101 +11011001110101111000 +11011101111110000100 +11011110110011010011 +11100100010100110111 +11100101010000110110 +11100101110100011100 +11100111000000111010 +11100111000110100001 +11101111001010111110 +11110000010001101010 +11110011011111110001 +11110100101111011000 +11110110000111101111 +11110110001000001100 +11110110010110101111 +11110111001001110111 +11110111001101111111 +11111000100111111110 +11111111010001100001 +11111111110100110101 +Started at Fri Apr 25 23:34:23 +0100 2008 +Took 1771.991079 seconds +Generation number 4 +00000000110100000000 +00000001101000101100 +00000001111001000111 +00000010011100101111 +00000011010001100001 +00000100011111010010 +00000100100001001111 +00000101010110101111 +00000101100010101100 +00000101111001110001 +00000101111010000110 +00000101111101000011 +00001000001000110010 +00001010011001000000 +00001010101000111011 +00001100000110100111 +00001100000110111110 +00001100001011011010 +00001100101010111101 +00001110010111111001 +00010000001011100110 +00010000010110000011 +00010010110001000011 +00010011100001110001 +00010100011100000001 +00010100011101010010 +00010101010000010010 +00010101010110101100 +00010101011001001000 +00010101111111011111 +00010110000110101001 +00010111010110000110 +00010111011001000011 +00011000110100000100 +00011001100010100000 +00011100100001010111 +00011100101010100110 +00011101011100101011 +00011101011100101011 +00011110110001000011 +00100010010100111011 +00100010111000000101 +00100010111011110010 +00100010111110110000 +00100011101101010101 +00100100001011111010 +00100100110100101000 +00100100110101110110 +00100100110111110110 +00100100111111011111 +00100101110101010101 +00100110110100100011 +00100111001000001101 +00101000110100000100 +00101001110000010110 +00101010011011001100 +00101010011110001000 +00101100110011011110 +00101100111110000110 +00101101110011010001 +00101101110011110110 +00110001010010101111 +00110001110100000010 +00110010001010011001 +00110010011000011101 +00110011101111010101 +00110100001010010110 +00110100111101100110 +00110110000100111011 +00110110001100001000 +00110110001101011101 +00110110001101011101 +00110110011101100011 +00110111101100010000 +00110111111000001001 +00111000100100100000 +00111000110100010101 +00111001100100000010 +00111001100100110100 +00111001100110010001 +00111001100111110001 +00111001110100000010 +00111001111100101000 +00111001111111101110 +00111010010111010001 +00111010010111010101 +00111100100001010100 +00111100100100010001 +00111100101011011111 +00111100101110011000 +00111101001000000100 +00111101101010101001 +00111101110011010101 +00111110001000101010 +00111110010010111101 +00111110011111110001 +01000001111010101101 +01000011010010110010 +01000100010100111011 +01000100100010101100 +01000100101111010001 +01000101100010101100 +01000110010110101110 +01000110011100001010 +01001000010001110110 +01001000101010011111 +01001010001010010101 +01001110101000010110 +01001111001111000010 +01010010110100011000 +01010011001100000100 +01010011011101010001 +01010101010110000110 +01010101111011001111 +01011100111000101100 +01100000000001101111 +01100011000000110100 +01100100000101110001 +01100100001111100110 +01100101001111100110 +01101011111010110010 +01101100000101101011 +01110000100111111010 +01110000100111111010 +01110000110001010000 +01110000110011010100 +01110000110110001000 +01110110000111101111 +01110111010011100001 +01111000100111111011 +01111001110100000010 +01111010101011000101 +01111100001010111100 +01111101001010101001 +01111111110100101111 +10000010011100011010 +10001101100100010000 +10001111011011001111 +10010000010110000011 +10010000111100100000 +10010111010010111111 +10010111100001011100 +10011001011110010001 +10011110110101000000 +10101001000011101000 +10101101101110101111 +10101110011111011000 +10101111010100100001 +10110000010100000100 +10110000010100111011 +10110001001000010110 +10110001001000010110 +10110010111100011000 +10110100111110000110 +10110110000111100000 +10110110010111001010 +10110110101110000011 +10110110101110110010 +10110110101110110010 +10111011110011011010 +10111100101011011111 +10111101001011101011 +11000000000001101010 +11000001100101011110 +11000010101100001100 +11000011010001000001 +11000100001000111000 +11000100010100111011 +11000100011111001111 +11000100111110101000 +11000101111001101100 +11001000101010011111 +11001001110101011000 +11001100011111000000 +11001100100100110110 +11001101011010001011 +11001101011111010100 +11001110111011010001 +11001111010110000010 +11001111010110000010 +11001111100001001111 +11010000110110110000 +11010010110100010000 +11010100101110001100 +11011001110101110010 +11011001111110000100 +11011011011000000110 +11011101101110001100 +11100100001111000110 +11101101110011110101 +11101111001010111110 +11110010001111110000 +11110011010000111100 +11110100101111011000 +11110110010100101110 +11110110101110110010 +11110111000101111111 +11110111101101111111 +11111000100110111110 +11111000100111010110 +Started at Sat Apr 26 00:03:55 +0100 2008 +Took 1879.650283 seconds +Generation number 5 +00000000100111111111 +00000000110100000110 +00000000110100010010 +00000001111000110001 +00000001111110101110 +00000010011100100010 +00000100001011100110 +00000100100100100011 +00000101001010101100 +00000101010100101100 +00000101111010000110 +00001000101010010111 +00001100001011000011 +00001100011011001000 +00001100101010000100 +00001101110011110110 +00001110001010001101 +00010011100101110001 +00010100011011111010 +00010100011100000010 +00010100011101010111 +00010100011101011000 +00010101000110111110 +00010101011001000000 +00010101011001001011 +00010101100001111001 +00010101110111011111 +00010110000110101001 +00010111010110000100 +00010111010110000110 +00010111011001010011 +00011000100100100000 +00011000110100010101 +00011001110010100000 +00011101010100110110 +00011101011100100000 +00011101101010100111 +00011110110001000010 +00011110111111000000 +00100000111110110000 +00100010001010010101 +00100010110100110110 +00100010111011110111 +00100010111111011111 +00100011101111100101 +00100100001101011101 +00100100100100101110 +00100100110101011110 +00100100111110110000 +00100101011010000110 +00100110110100100011 +00100111001001011011 +00101000111010000110 +00101001110000000101 +00101010011110001001 +00101010011110100000 +00101011011101010001 +00101100011111110001 +00101100101010101101 +00101101110011010110 +00110000001100010001 +00110000011111010010 +00110001111100101000 +00110001111110101101 +00110010001010000011 +00110010001010011111 +00110010001100111001 +00110010011010010001 +00110011101111100000 +00110101100100010000 +00110110001110101011 +00110110111000000101 +00110111011010000110 +00110111100001011000 +00110111101100010000 +00110111101100010000 +00111000110000010000 +00111001011100101000 +00111001100100000101 +00111001100110110100 +00111001100111111100 +00111001110100000011 +00111010000011111111 +00111010010111000011 +00111010010111010110 +00111010011100101111 +00111011100101010010 +00111100001010111100 +00111101001000000110 +00111101001010101111 +00111101111110010000 +00111110010010101111 +00111110011111110110 +00111110100001001010 +00111111010011101001 +01000000010100111011 +01000000100001101010 +01000001101101011110 +01000001110101010000 +01000100010101111011 +01000100011101000011 +01000100101010010010 +01000100101111010001 +01000101001111100110 +01000101111101010110 +01000110010110111100 +01000110011100001010 +01000110011100001010 +01000111010110101111 +01001000010001110110 +01001000010001111000 +01001000101010011010 +01001010010001111110 +01001010111000010101 +01001110111110000101 +01001111001111001010 +01001111010000000111 +01001111110100101111 +01010011001100010100 +01010011001100100110 +01010011011101010001 +01010011011110111101 +01010100100011011111 +01010101010110101011 +01010101111011001111 +01010111010101111001 +01011010101000111011 +01011100000101101011 +01100000100111111110 +01100011110000000010 +01100100100010101100 +01100110000111101011 +01101000100111111011 +01101111110100111101 +01110000100101101000 +01110000100111111010 +01110111000111101110 +01111000110100000010 +01111100001010101100 +01111101001000101001 +01111101011010100001 +01111111110100101110 +10000001110011110101 +10000010011001000000 +10000101010100000100 +10000101111001000011 +10001010011100010010 +10001101100100011010 +10001101100101011101 +10001110000101001101 +10001111010110000110 +10010000010101111101 +10010001010010101111 +10010100111100111011 +10101100011111010010 +10101101101110100111 +10101101101110101111 +10101101111100001000 +10110001001100011111 +10110010111100011000 +10110100010100001100 +10110100111110000110 +10110110000111010101 +10110110010111010100 +10110110101110100010 +10110110101111011010 +10111001001000010110 +10111100101111011100 +11000000100101011110 +11000010101001100100 +11000011010001100001 +11000100001000110110 +11000100110010000000 +11000101010110100111 +11000101100010001100 +11001000101000011000 +11001000101010011001 +11001001110101011000 +11001100010001000001 +11001101011111010101 +11001101110101110010 +11001110101110101011 +11001111101001001111 +11010000010110110000 +11010110100100111011 +11011001101000010110 +11011001110101110010 +11011011011110000010 +11100100001111000100 +11100100001111000110 +11101101111001000111 +11101110101100110110 +11101110110010001100 +11101111001010100110 +11110000110001010001 +11110010001111100000 +11110100101111011000 +11110110010100100110 +11111000100111010001 +11111101001011101011 +Started at Sat Apr 26 00:35:15 +0100 2008 +Took 1834.799951 seconds +Generation number 6 +00000000100111111100 +00000000110100000110 +00000000110101111011 +00000001110100100111 +00000010011100100010 +00000010011100100011 +00000100001011100001 +00000100010101111011 +00000101010100001100 +00000101111010000110 +00000101111010001110 +00000110011100001000 +00001000101010100000 +00001011011001010011 +00001100001011000011 +00001100001011001010 +00001100101001100101 +00001100101010000101 +00001110001110001100 +00010000011101010111 +00010011001100010100 +00010100001101111001 +00010100011011111011 +00010101000110000110 +00010101000110111001 +00010101010100100100 +00010110000011101011 +00010110001110101001 +00010110010001010011 +00010111010110111110 +00010111110111111111 +00011000001100010111 +00011000110100010110 +00011001100111111100 +00011001110110100100 +00011010100100011001 +00011100001111000100 +00011100101010111100 +00011101101010100100 +00011110111111000000 +00100010111000000010 +00100010111010111100 +00100011101111100101 +00100100000100110110 +00100100001101001101 +00100100110101011110 +00100101011010000110 +00100101101010000100 +00100110000100110110 +00101000110001110110 +00101000111110110000 +00101001010000000110 +00101010011110000101 +00101010011110001001 +00101011011101010001 +00101100011011000011 +00101100011111110110 +00101100101011011001 +00110001010110111100 +00110001111100101000 +00110001111100101000 +00110001111110100110 +00110010011010010101 +00110011001100001100 +00110100100101100000 +00110101000110101011 +00110101100100010010 +00110101101100010011 +00110110010101101011 +00110111001100010000 +00110111011010010110 +00110111011011000001 +00110111101110110000 +00110111111110010010 +00111001011100101000 +00111001100100000010 +00111001100111111100 +00111001101010010110 +00111010010111010110 +00111100001010111100 +00111100010101111011 +00111100011101011000 +00111101001011110111 +00111101011010000100 +00111110000001001000 +00111110000010101011 +00111110001110110111 +00111110010010101110 +00111110011111110100 +00111111100011001010 +00111111101100010001 +00111111101111111000 +01000000100001101010 +01000001101101011100 +01000001110101010000 +01000001110101011000 +01000001110101111010 +01000010000011111111 +01000100011100000011 +01000100011100001010 +01000100100101011110 +01000100100111111110 +01000100111101001000 +01000101001111100110 +01000101100100010000 +01000110010000011010 +01000110111100101000 +01000111010110101111 +01000111011110001111 +01001000001010011010 +01001000010001000000 +01001000010001111000 +01001010010001000011 +01001010111000010100 +01001100001001111110 +01001101011100100000 +01001101011111010101 +01001101011111110101 +01001110000101001101 +01001110111010000101 +01001110111110000101 +01001111110100110101 +01010000101010101101 +01010011001100010101 +01010011101111101011 +01010101010010101001 +01010101110011011111 +01010101111011001011 +01010101111011011110 +01010110001010011111 +01010111010101111001 +01011010101000111011 +01011111011011001001 +01100001110000100010 +01100010111101011101 +01100011001101101111 +01100101011100100000 +01101000010001111001 +01101111001010100111 +01110000100111111000 +01110010100101101000 +01110010101110111011 +01111000110111110111 +01111100000010101110 +01111100001010101110 +01111100101111011011 +01111101011010110001 +10000100010101111011 +10000100111100000100 +10000101000100101100 +10000101010110000111 +10001010011100010010 +10001010011100101000 +10001011001111001010 +10001111100010000100 +10010000010101111101 +10010001010010101101 +10010100010101111111 +10010110111100000110 +10010111011110000001 +10100110011110010010 +10101100011111010010 +10101101101110010010 +10101111011110111101 +10110000010001111111 +10110010111100011000 +10110100101110101101 +10110100111100111011 +10110110000101010101 +10110110101111011000 +11000000101010011110 +11000001110101011110 +11000010011001000000 +11000010101001100100 +11000100001000110001 +11000101001010001101 +11001000101010011001 +11001001111101011000 +11001100110100000010 +11001101011111010001 +11001101100101011101 +11001110110010111011 +11001111101001001101 +11001111101110101011 +11010000001000110110 +11010011001100000000 +11010101100010001100 +11100100001111000100 +11100100001111010110 +11101010110010000100 +11101111000010100110 +11110000011010000110 +11110100010011101001 +11110100111111011010 +11110111000111000001 +11111000100111010000 +11111000100111010001 +11111000100111010001 +11111001101000011100 +11111010000111000011 +Started at Sat Apr 26 01:05:49 +0100 2008 +Took 1806.325558 seconds +Generation number 7 +00000000100111100000 +00000001110100100111 +00000010011101100011 +00000100000101111010 +00000100100011111110 +00000100110100111100 +00000100110101111001 +00000101010110000111 +00000110001100001000 +00000110010101101000 +00000110011101001000 +00000110110011011111 +00001000011110001000 +00001000100100110110 +00001010011110000101 +00001011011101010011 +00001100001011000011 +00001100011010011010 +00001100100010001100 +00001100100101111110 +00001100101001100101 +00001100101010001000 +00001101101001100101 +00001110001100100100 +00010000011101010110 +00010001100100001010 +00010010001101000000 +00010010101010101101 +00010100011011111011 +00010101010110001100 +00010101011100100100 +00010110010011101011 +00010111010101101000 +00011000010100010110 +00011001110110100100 +00011010100100011001 +00011010101010100111 +00011100101010110100 +00011101101010000100 +00011101101010011000 +00011110111111000000 +00100001011010000110 +00100100001101001101 +00100100101010000101 +00100100101010111011 +00100101111010011010 +00100110000100110111 +00100110001010110000 +00100110111011010110 +00101000111010110000 +00101010011110101101 +00101011011001010011 +00101100011010000010 +00101110111100011000 +00110000001000010110 +00110000010001111001 +00110001010110111010 +00110001101110101011 +00110001111110111001 +00110010011010010101 +00110011001100010101 +00110011001111110001 +00110101000111101011 +00110101010110000111 +00110101100000010010 +00110110010101101011 +00110111001001111011 +00110111011010000110 +00110111101110110000 +00111000001010111100 +00111000010100101100 +00111000010101111011 +00111001000010100110 +00111001010001111001 +00111001101010000100 +00111001101010010110 +00111001101010010110 +00111100010100001100 +00111100010101111011 +00111100011001100100 +00111100011101011000 +00111100011101111001 +00111101101111000100 +00111101101111111000 +00111110000010101011 +00111110011111111100 +00111111100011001010 +00111111101000011101 +00111111101111111001 +01000000100001101010 +01000001101101011100 +01000001110111011000 +01000100100101011101 +01000100100101011110 +01000100101010000101 +01000100110111111110 +01000100111101001000 +01000101111010000110 +01000101111010111100 +01000110011000010011 +01000110101111011011 +01000110111000010100 +01000111011110001111 +01001000001010101010 +01001000111101001010 +01001010111000010100 +01001100101010000101 +01001101010111110101 +01001101011111110111 +01001110000101001101 +01001110011110000100 +01001110111010000101 +01001110111100000001 +01001111001010100111 +01001111110100110101 +01010000010001111111 +01010000101000100101 +01010001010110101101 +01010001110101111010 +01010100000110000110 +01010100100101100000 +01010101010000101110 +01010101010010100010 +01010101010010111010 +01010101110101011000 +01010110011110001101 +01011010000100110110 +01100001110000100011 +01100010111000010000 +01100011101100010101 +01100100000111111110 +01100101001111100011 +01100111001000011111 +01101000010001110000 +01101101000110101011 +01101111000100011001 +01101111001010100111 +01101111001010100111 +01110001100111111100 +01110010101100001000 +01110010101110000001 +01110011001101111111 +01110011101111111011 +01110100110011011111 +01110110111010011101 +01111000000010111011 +01111000010001111001 +01111000010101101000 +01111000110111010010 +01111100001010001110 +01111100100111111110 +01111110001110101011 +01111110101111011011 +10000001010110111100 +10000101000101110011 +10000111100011010000 +10001010011100010001 +10001010011100100100 +10001110111110000101 +10001111010110001111 +10001111100010000100 +10010001010010101101 +10010101111011011110 +10010110010000010001 +10010110111100011101 +10010111011110000000 +10011001110100100111 +10101101101110110110 +10110001010110111100 +10110010001101010101 +10110010010100110000 +10110011001111111000 +10110100101110001001 +10110100101110101101 +10110110000000011100 +10110110111100101100 +10111000101001101101 +10111100001010001100 +11000100010101101011 +11000101001000110101 +11000101010000001100 +11000101010110000111 +11001000101110010110 +11001001111101111000 +11001011011100101000 +11001100100001011110 +11001111101010101110 +11010000001100010110 +11010111011000010110 +11011000010001111000 +11100100000000000010 +11100100001001010110 +11100101011100100000 +11101000100111010000 +11101001101110110000 +11101010110010010110 +11101100001011000010 +11101111100111111100 +11110110111111001010 +11111001101101010101 +Started at Sat Apr 26 01:35:56 +0100 2008 +Took 1893.750235 seconds +Generation number 8 +00000010001101100011 +00000100000110000110 +00000100010110011101 +00000100100011111110 +00000100100101101110 +00000100110000111111 +00000101010110011110 +00000110000010101010 +00000110001100001110 +00000110011001001010 +00000110110011011111 +00001010011010101101 +00001011011101010011 +00001100011101101001 +00001100100001100101 +00001100100101011101 +00001100101000100101 +00001101010110000011 +00001101011111110111 +00001101101001100101 +00001110001000010101 +00001110111010000101 +00001110111010011101 +00001111001010110111 +00010000011101011000 +00010000110101111000 +00010010101010101101 +00010010101011100101 +00010100011101000010 +00010100100001101010 +00010100100110100110 +00010101011100101100 +00010101011100111000 +00010101111011010010 +00010101111011011110 +00010110011100001000 +00010111001000010111 +00010111010000010110 +00011010011100011011 +00011010101100001000 +00011100011111011011 +00011110111101111001 +00011110111111000000 +00011110111111000111 +00011111101111111001 +00100010011111111100 +00100100101001100101 +00100101011101100000 +00100101111010010000 +00100110000100110111 +00100111010101101000 +00101000010001111001 +00101010011110100000 +00101011011001010011 +00101100011010000010 +00101100011010110110 +00101101000110101011 +00101101101000000100 +00110000010010111001 +00110000110001111110 +00110001001111110001 +00110001110010001110 +00110010001001010101 +00110011001100000100 +00110101000111101011 +00110101010110000000 +00110101011010100111 +00110101100000010111 +00110101100001010010 +00110101101000010010 +00110110110011011110 +00110111001001110010 +00110111001001111011 +00110111011010011001 +00111000000010111101 +00111000000110100000 +00111000010100101100 +00111000010101101011 +00111000110111010010 +00111000111000111100 +00111001000010111011 +00111100011101011011 +00111100011111000000 +00111100100101100010 +00111101101111111000 +00111110000011101011 +00111110001101000000 +00111110010010011010 +00111110011010010101 +00111110011111111100 +00111111101010000111 +01000000011011101011 +01000000011101100011 +01000000100001101010 +01000001110000100010 +01000010011101100011 +01000100010101111011 +01000100101010000101 +01000100111010100111 +01000101110110111110 +01000101111010000110 +01000110010101101000 +01001000101011111011 +01001000101101101010 +01001000111101001100 +01001001011111110010 +01001010011000010100 +01001010011110000100 +01001011011100101000 +01001100100101011110 +01001100101010001000 +01001101010100111010 +01001101111010000110 +01001110000101001101 +01001110001010000101 +01001110011010000100 +01001110011110000000 +01001111001111111010 +01001111110100110100 +01010001001110101010 +01010100100101100000 +01010101110001110000 +01010110100101011101 +01010110100101100000 +01011000001100110110 +01011100100111111110 +01011101101000011100 +01011101110110100000 +01011110001010100111 +01100000110111111110 +01100001101111101100 +01100001110001100011 +01100011001100010101 +01100100000010111110 +01100100001010000100 +01100100001101111001 +01100110000100101011 +01100111001010001011 +01101000010001011000 +01101001001010010110 +01101101000100011111 +01101101100110101011 +01101111001010000101 +01101111001010101010 +01110000010100010110 +01110001100101111100 +01110001111111101010 +01110011001001111100 +01110100000111101011 +01110100001000001100 +01110100111010000111 +01110101101110101111 +01110101110011011111 +01110110111010011101 +01111000000001111001 +01111000010001100110 +01111000010001111001 +01111000110111010010 +01111000110111111111 +01111010000101101011 +01111011101010010110 +01111100100111111110 +01111100100111111111 +01111110101101011000 +10000001111110000101 +10000010000011001110 +10001100101010011011 +10001110010110110100 +10010010001100000010 +10010101111011011111 +10010110010000010001 +10010111010111011010 +10010111011110000101 +10011001110100100100 +10110001010110111100 +10110001010110111100 +10110001110110101101 +10110011001010100111 +10110011010110111110 +10110011101111100100 +10110101000111101011 +10110110010101101011 +10111100001010001110 +10111111111100010001 +11000100010100110110 +11000100100111011101 +11000101000010100110 +11001011011100101011 +11001111100011101101 +11010001001100010110 +11010100000101111010 +11010100111011111011 +11010111011000010110 +11101100001011000111 +11101101101110000010 +11110100011000011010 +11110110111110001000 +11111000010001110000 +11111001101101010101 +11111100010101101011 +Started at Sat Apr 26 02:07:30 +0100 2008 +Took 1722.345688 seconds +Generation number 9 +00000100000110000110 +00000100010110000110 +00000100100011101101 +00000100101000100101 +00000101000010111101 +00000101010100000000 +00000101100011111100 +00000110110011011110 +00001000000100111011 +00001010011010111010 +00001011000100101011 +00001011011010011001 +00001011011100000100 +00001100001101101001 +00001100011010000010 +00001100101111011110 +00001101000100000011 +00001101011111111000 +00001101100001100101 +00001110001000010101 +00001110010011011111 +00001110011010111011 +00001110101010000101 +00001110111010000101 +00001111001010110111 +00001111001010111110 +00001111010101010111 +00001111011001111011 +00001111111101111000 +00010000100101100000 +00010001001111110001 +00010001110001100011 +00010010101011000101 +00010010101011100101 +00010010101110101111 +00010100100111001101 +00010100101010011011 +00010100111010000111 +00010101011100101100 +00010101011100111000 +00010101011110101110 +00010111010000010010 +00010111011000010000 +00011010011100011011 +00011100001111011011 +00011100010110100100 +00011110010010001001 +00011110011100000111 +00011110111011000111 +00011110111111000111 +00011110111111011011 +00100011010101101000 +00100100000100000110 +00100101000111101011 +00100101011100100000 +00100101111101100110 +00100111100101111000 +00101000010000111011 +00101000010101111001 +00101000101011111001 +00101001101000010010 +00101100111010011101 +00101101001000111001 +00101101001110101011 +00101111011101010011 +00110000001011110001 +00110000110001111010 +00110001001110110100 +00110001001111110001 +00110001110010001110 +00110011001100000100 +00110100010001110001 +00110100010110011101 +00110100010111000000 +00110100011000011010 +00110101010010111110 +00110101011101111011 +00110110001001010101 +00110110011010001101 +00110110111101010101 +00110111000000001011 +00111000010010111001 +00111000010100101100 +00111000010101101010 +00111000100001100010 +00111000100101011110 +00111000110000111101 +00111000110111010010 +00111001010111011011 +00111010000010101010 +00111011001101010011 +00111100000000010111 +00111100001101011011 +00111100010010111001 +00111100010101111011 +00111100011010010101 +00111100011101011011 +00111100011111000000 +00111100011111111100 +00111101101001100101 +00111110000011101010 +00111110010110110100 +00111110011111011101 +00111110011111111100 +00111110101010011011 +00111111100011101101 +01000000010011101000 +01000000011011101011 +01000001110000100110 +01000010000011001110 +01000010011101100011 +01000010011111111011 +01000011010111011010 +01000100010111011010 +01000100101010010110 +01000101111010000000 +01000110011011111100 +01001000011011101011 +01001010010001100110 +01001010011000010100 +01001010011110000100 +01001011011100101111 +01001100011001101001 +01001100101000001000 +01001100110101011110 +01001101000110101011 +01001110000100101101 +01001111001010000101 +01001111010011011011 +01010101000111101011 +01010110100101101100 +01010111001110000101 +01010111011100010110 +01011000110111010010 +01011110011010000101 +01100010101010101101 +01100011000001111100 +01100011010100101011 +01100100001110110111 +01100100100000010111 +01100111011010000000 +01100111101010001011 +01101001001011000001 +01101101000100011111 +01101101000110010110 +01101101010111010010 +01101101100110101001 +01101101111010000111 +01110000010100010110 +01110000010111011110 +01110011001001111100 +01110011011110000000 +01110100010100110100 +01110100111010001111 +01110101101110101101 +01110101110100111010 +01110111011010011001 +01111000000001111001 +01111000010001111001 +01111000101010101010 +01111000110111111000 +01111000111011101011 +01111000111111010010 +01111011100010010111 +01111011101001010110 +01111100000001111001 +01111100100111110100 +01111110100111111110 +01111111111111000011 +10000001010010100111 +10000101111110000100 +10001001011111110110 +10001100100001100101 +10001100110010011010 +10001101010110000011 +10001110010111110001 +10001111001010010111 +10010011101011100111 +10010100100001001000 +10010111011110000110 +10011001111111011011 +10101101000110111101 +10101110000100110111 +10110101000101101010 +10111000010001100110 +10111011101111100100 +11000100101010000101 +11001000000001111001 +11001000010001101001 +11001011011100101011 +11001110000011101011 +11001111110011101101 +11001111110100110100 +11010100000100010101 +11011100010101101010 +11011101001100101011 +11100110101100010101 +11110101010110000000 +11110101101000010010 +11111001100011001111 +Started at Sat Apr 26 02:36:12 +0100 2008 +Took 1926.564649 seconds +Generation number 10 +00000001101010101100 +00000100000011101101 +00000100000110011101 +00000100100011101100 +00000101000010111101 +00000101010100000000 +00000101101100010111 +00001000000000111011 +00001000000111111100 +00001000011011101011 +00001011001100000100 +00001011011111100011 +00001011101010110111 +00001100010011011111 +00001100010110100100 +00001100011010000000 +00001100100101100000 +00001101000110000010 +00001101011111011000 +00001110001011111001 +00001110001111101001 +00001110010011011001 +00001110010011011111 +00001111000100101011 +00001111001010011010 +00001111001010111100 +00001111010100101011 +00001111011001111110 +00001111110100110100 +00001111111101110100 +00001111111101111000 +00010001001001111011 +00010100000000111100 +00010100100011100110 +00010101010000100100 +00010101010110100011 +00010101111010000100 +00010110010010001101 +00010111011000010010 +00011000010110111110 +00011000010111011110 +00011001101111001011 +00011010011100010011 +00011100001101101001 +00011100010110100100 +00011100011010010101 +00011110010001111010 +00011110111100010110 +00011110111111011011 +00100000001100000110 +00100000010101111010 +00100100000100010101 +00100100001110110111 +00100100011100001011 +00100101011100100000 +00101000010001100110 +00101000010100110111 +00101000011000010010 +00101000011011010101 +00101000110100111011 +00101000110101010010 +00101001101000011010 +00101011101111100100 +00101100001111011011 +00101100011010111011 +00101100111010011101 +00101101001000011001 +00101101001110001011 +00101101001111111000 +00110000010111011110 +00110000110001111011 +00110000110010001110 +00110000111000011010 +00110001001110100100 +00110001111100001111 +00110010000011101010 +00110010101011100101 +00110011001101111001 +00110100000100010101 +00110100010000111011 +00110100010011111010 +00110100011000010010 +00110100011000011010 +00110100011000011010 +00110101010010111011 +00110101110010101110 +00110110001001010101 +00110110001001010101 +00110111000000001011 +00110111000011101101 +00111000010101101001 +00111000010101101010 +00111000011101100010 +00111000100101011110 +00111000110000111101 +00111000111110000111 +00111010010010111001 +00111010010110110100 +00111011001100000101 +00111011110001111010 +00111100001001011011 +00111100001011000101 +00111100010100111001 +00111100011010010101 +00111100011010011101 +00111100011100111011 +00111101010111110010 +00111101101001100101 +00111101111101101010 +00111110000100110111 +00111110011101011101 +00111110011111010101 +00111110111100000111 +00111111001010111110 +01000000011011101011 +01000000011011101011 +01000100010111111000 +01000100010111111110 +01000100101110010110 +01000101100000111011 +01000110000011001101 +01001000100111111110 +01001010000000101101 +01001010010110010100 +01001010101010000101 +01001111010011011011 +01010000100101110000 +01010101000111101011 +01010101001110111111 +01010111000111101011 +01011001010111011011 +01011010110111010010 +01011100000011110011 +01100001000111011011 +01100011010111011010 +01100100000100000110 +01100100000111101011 +01100100011110110111 +01101000111010111011 +01101001001011101011 +01101011101001011011 +01101100010111000000 +01101101010100111010 +01101101010111000110 +01101101111010000011 +01101101111111010010 +01110000010111111101 +01110010011101100011 +01110101000100011111 +01110101101110101101 +01110101110100111010 +01110101110111010010 +01110110000011000111 +01111000010100101110 +01111000101001111011 +01111000111010011010 +01111000111011000001 +01111000111110101010 +01111010101011000101 +01111011100011101101 +01111100000000010111 +01111100001101000000 +01111101000100011111 +01111110011001111011 +01111110100111111111 +01111111011010001001 +10000101010000000001 +10000101010100000000 +10001001010010010010 +10001011110010010111 +10001100010110011010 +10001100100001100101 +10001100100001100110 +10001100100011101101 +10001100110011011010 +10001111011111001101 +10010000111111010010 +10010010110101101100 +10010011110111101000 +10011001111111011001 +10011010011100011011 +10011010110111010010 +10011100100111000001 +10011101010110001110 +10110101111101100110 +10110110011010001100 +11000101010010111110 +11000101011111110110 +11001000000000000100 +11001001010001001110 +11001001010001101001 +11001001111010000000 +11010100000100010101 +11010101011100100000 +11011100001011100111 +11100110101100010101 +11100111101110101011 +11101011100011001111 +11111000100101011110 +11111000101010101010 +Started at Sat Apr 26 03:08:19 +0100 2008 +Took 2014.162627 seconds +Generation number 11 +00000010110101101000 +00000100000001101101 +00000100000011101101 +00000100011100110111 +00000100110110111010 +00000101011000010011 +00001000001101011011 +00001000010100101110 +00001000010111011100 +00001000011011101011 +00001000100001011111 +00001001011011101111 +00001001111010000010 +00001011001100000010 +00001011011111000011 +00001011101110100100 +00001100000100000110 +00001100010011011110 +00001100010011011111 +00001101010010011111 +00001101100101000000 +00001110010011011001 +00001110010011011010 +00001110010011011110 +00001111000011101101 +00001111010011011010 +00001111010100101011 +00010001000110101011 +00010100000000111100 +00010100100011100110 +00010100100100010011 +00010101010000100100 +00010101010110000110 +00010101111100010110 +00010110111110000111 +00010111111100000010 +00011000000011001010 +00011000101001100101 +00011000101010101010 +00011001010110111111 +00011010011011100110 +00011010011100010011 +00011010100111010010 +00011101110101101010 +00011110100000111011 +00011110111111011011 +00011111111111011011 +00011111111111011011 +00100000010101111000 +00100000011000011010 +00100010000001010101 +00100100011100001011 +00100101111111110010 +00100111001110111101 +00101000000011001101 +00101000010100110111 +00101000011000010010 +00101000011011000111 +00101000110100101011 +00101000110100110110 +00101000110101010110 +00101000111010111011 +00101000111110101010 +00101001101000011110 +00101010010011100011 +00101100011010111101 +00101100111010011101 +00101100111011011100 +00101101001110001011 +00101101001111000111 +00101101010110110101 +00101101010111011001 +00101101011010111011 +00101110001011111001 +00110000111000101111 +00110000111001011010 +00110001111110001111 +00110010000011101010 +00110010010010111110 +00110010111111010101 +00110100010011111010 +00110100010111111011 +00110100011000010010 +00110100011000010100 +00110100011011011010 +00110101101111001011 +00110101110010011011 +00110110010110010100 +00110111000000001011 +00110111000100101111 +00111000000010001101 +00111000110001001110 +00111000111110000111 +00111001010100111010 +00111001011100000001 +00111010011111011001 +00111011001100011001 +00111100000011001111 +00111100010101100110 +00111100010110111001 +00111100011001011011 +00111100011111101011 +00111100100111000001 +00111101101001000111 +00111110001100000101 +00111110111100010110 +00111111001110111110 +00111111010110010100 +00111111101001100101 +01000000011011010101 +01000000011011101011 +01000000011101101001 +01000100000111111100 +01000100010111111111 +01000100101110010110 +01000101100000111011 +01000110010111111110 +01000111111110101001 +01001000011011101011 +01001010010110010101 +01001010111011000000 +01001100100011101101 +01001111001010111101 +01010000011110101011 +01010101000111101011 +01010101010010110110 +01010111000111101011 +01010111000111101011 +01011001001110000100 +01011001010111011011 +01011001111010011011 +01011011010000001011 +01011110000011110011 +01011110101111111011 +01100100000010000100 +01100100000101100000 +01100100000110101011 +01100100000111101011 +01100100010111111000 +01100100100011101110 +01100111101110101011 +01101000010100110111 +01101000011000010010 +01101000111010101011 +01101011110011001111 +01101101001110001011 +01101101010010111010 +01101101010110000110 +01101101010111000110 +01101111010100101011 +01110000101011000001 +01110011010111011010 +01110011011101100001 +01110101110110111110 +01110101110111011110 +01110101111110100100 +01110110000011010101 +01111000010011101011 +01111000111110111001 +01111010011111000101 +01111010101011000101 +01111011100011101011 +01111100001101100010 +01111101000110111111 +01111101010100010101 +01111110011010011101 +01111110101000011010 +01111111011001111110 +10000101000000001111 +10001000001001000000 +10001001010000111101 +10001011110011010011 +10001100010100011010 +10001100010110011010 +10001100010110011010 +10001100110011011010 +10001111110100110100 +10010010110101101100 +10010100000110011101 +10010101011000010010 +10011001110110110100 +10011110010001111010 +10011110011010001100 +10100111101110101011 +10101011100011011111 +10110101000100010101 +10111001000111011001 +11000101011110111111 +11001001010000111001 +11001100100111111100 +11011011010111110010 +11011110111100010110 +11100100011100001011 +11100100011110110111 +11100101011110011011 +11101011101011101011 +11101011111011000101 +11101100010110000100 +11110101001111111011 +11110101111010000100 +Started at Sat Apr 26 03:41:53 +0100 2008 +Took 2051.893687 seconds +Generation number 12 +00000001011000010011 +00000010010100111010 +00000100000110101011 +00000100010111111011 +00000100011100110101 +00000100011100110111 +00000100100110111010 +00000100110110111010 +00000101001110011011 +00001000011000010010 +00001000011011000111 +00001000011011110100 +00001000111111111011 +00001001010001101011 +00001001011011101101 +00001001111010001010 +00001010000001010101 +00001010001101011111 +00001011010100101011 +00001011011111000001 +00001011101110100101 +00001100010011011011 +00001110010010001011 +00001110010010101111 +00001110010011011001 +00001110010011111010 +00001110101000011010 +00010001000110101011 +00010001000110101011 +00010001010000100100 +00010010100111000010 +00010011010111110010 +00010100010100010101 +00010100100011100110 +00010100110100010011 +00011000101001100101 +00011001010110111111 +00011001110111001011 +00011010011100010011 +00011011101110110110 +00011011110001001111 +00011100011000011010 +00011110010011011001 +00011110010110111010 +00011110111111111011 +00011111010100100110 +00011111010110010100 +00011111111111001011 +00100000000101111000 +00100000011011101011 +00100000111000101101 +00100001011000011010 +00100010000001010100 +00100010110101101100 +00100100000100111100 +00100100010011101011 +00100100011100011010 +00100101011010110100 +00100111101000011110 +00101000001011011010 +00101000011011001011 +00101000011011101011 +00101000111010111011 +00101000111110110110 +00101100000011001101 +00101100011001010110 +00101100111011011110 +00101101001111000111 +00101101010011011011 +00101101011000011111 +00101111010100101011 +00110000111010011010 +00110000111111011111 +00110001101110001111 +00110001111110001111 +00110011011000010011 +00110100000111101011 +00110100010111111011 +00110100011000010111 +00110100011011010010 +00110100111110101010 +00110101101111001001 +00110110001000011100 +00110111000100101010 +00111000000000111111 +00111000010101100111 +00111000011111000111 +00111000100001001110 +00111000110011011110 +00111000111010100001 +00111001000000001100 +00111001001000100001 +00111001011100000001 +00111001110001101000 +00111010001111011010 +00111100010101100110 +00111100010101101011 +00111100010101111011 +00111100011011001011 +00111100011111101111 +00111101000010011111 +00111101010010110110 +00111101010010110111 +00111101010111011001 +00111101110010011011 +00111110001110111110 +00111110011010011101 +00111110011111011010 +00111111101001111011 +01000000010101100110 +01000000011011010101 +01000000011011101111 +01000100000101100001 +01000100011010110100 +01000101100010001101 +01000110010101111011 +01000110010111111110 +01001000011011101011 +01001111001010101111 +01010000011000000010 +01010001111100001111 +01010100100011100110 +01010100111001011011 +01010111000111100011 +01011001010110111101 +01011100010110011010 +01011110011100011010 +01011110101110101010 +01011110101111111110 +01100100000110101011 +01100100100011101110 +01100100101110010110 +01100101000110000110 +01100101101111001011 +01100101111110011011 +01101000011000001011 +01101000011000010010 +01101000011101100001 +01101000101000011010 +01101000111010101010 +01101001010100110111 +01101001111011000101 +01101010010011011010 +01101011100011001011 +01101101010000111000 +01101101010110000110 +01101101010110000110 +01101111101110101011 +01110000010011101011 +01110000101011010000 +01110010111110111001 +01110100011000010010 +01110100110111011110 +01110101110110011111 +01110101110110111110 +01110110000011010101 +01110110000011110100 +01110110000110011010 +01110110010110000100 +01110111001110011111 +01111000010001000101 +01111000110011101011 +01111001110110000111 +01111010011110000111 +01111010101011101111 +01111101010010011111 +01111101010011111010 +01111101010100010101 +01111110011010011101 +01111110101101111011 +01111110101111001110 +01111110111010101010 +10000100000011100111 +10000101000000000001 +10001100010011011100 +10001100010111010101 +10001100100111111100 +10001111110111010101 +10010001000110011001 +10010001110110101011 +10011010001010100110 +10011110001111111011 +10101000011000010011 +10101000011100001011 +10101011011100100011 +10110011000000000101 +10111000101111111100 +10111011010100001110 +11001001010000111001 +11001010011100001011 +11001100110011011010 +11010101011110001011 +11011010111111010111 +11100100100011101110 +11100101010010110000 +11100101010011110110 +11100101010111011110 +11101011101011101011 +11101100100111111100 +11111101000110111101 +Started at Sat Apr 26 04:16:05 +0100 2008 +Took 2131.171748 seconds +Generation number 13 +00000000000110101011 +00000000010111010110 +00000000011011101001 +00000001011000010011 +00000010010110111110 +00000100010111111011 +00000100100011100110 +00000100100111101110 +00000100111000001011 +00000101011100110001 +00000101101110011011 +00000110010110111110 +00001000011000010011 +00001000111001001111 +00001001010001100011 +00001001010001101011 +00001001010110111111 +00001001011011101100 +00001001101010001011 +00001001110010001010 +00001001110110000101 +00001010000001010100 +00001010010111111110 +00001010011111000001 +00001011011110111110 +00001011101110100101 +00001011111101100101 +00001100000011011011 +00001100100011101110 +00001101010011011011 +00001110010010000011 +00001110010111111011 +00001111011010111111 +00010000000110101101 +00010001010000100101 +00010001110000100100 +00010011010000100101 +00010100110100010101 +00010100110110111010 +00010110101111001110 +00011000111111111011 +00011001011011100110 +00011011100101100110 +00011011101010110110 +00011011101110110110 +00011011101110111110 +00011011110001001101 +00011011110110001010 +00011110001110101011 +00011110010110111010 +00011110010110111011 +00011110110011101011 +00011111010110010100 +00011111011100011010 +00100000111000011010 +00100001011000010011 +00100011011000000111 +00100011101010011110 +00100100011000111011 +00100100011010010100 +00100100101111111110 +00100111101100011111 +00101000011011101011 +00101000111110110100 +00101001011001011010 +00101001011011001011 +00101010101011101111 +00101011010100001100 +00101011111100001011 +00101100000111111011 +00101101001111011010 +00101101011001010111 +00101101011111001011 +00101110001000011100 +00110000001011101101 +00110001000111101001 +00110001111111111011 +00110010111010011010 +00110011000100001010 +00110011001001011011 +00110110001000011100 +00110110001010011110 +00110110011100001011 +00110111000100100111 +00111000001011011010 +00111000010000111111 +00111000011010110110 +00111000011101000001 +00111000011111000111 +00111000110111010101 +00111000111010100011 +00111000111110001111 +00111001001001110111 +00111001010111011111 +00111001011100000001 +00111010011010100001 +00111100010101011011 +00111100010111000111 +00111100011000010111 +00111100011011001011 +00111100110010011010 +00111100111110101010 +00111101000010011110 +00111101010010100001 +00111101110010011011 +00111110011110101111 +00111110101011101011 +00111110110010110000 +00111111010011110110 +00111111101101111011 +01000010010000111000 +01000101010001101111 +01000101100010001101 +01001000111111111011 +01001001111011000101 +01001010001101011111 +01001011010100101011 +01010001000111101011 +01010110000011110100 +01011000111000100011 +01011010011110000101 +01011010101111111110 +01011100010110011011 +01011100101111000001 +01011110010011001011 +01100000011111100001 +01100100101110001110 +01100101010111110110 +01100101011110001011 +01100101111110010011 +01100110000011110110 +01101000011100110101 +01101001010111000100 +01101001011111001011 +01101001101000011010 +01101011101110100011 +01101011111011000101 +01101100000011111011 +01101101010000111110 +01101101010100110101 +01101101010110011101 +01101101010111010110 +01101111111011000101 +01110000010001101011 +01110000011011101011 +01110100010101100110 +01110100011011010001 +01110100110111011101 +01110101010011111110 +01110101110110011011 +01110110000110111010 +01110110110110000101 +01111000010011001101 +01111000011111101011 +01111000111111111011 +01111001101110111111 +01111010011110001010 +01111100010100010101 +01111100101111100010 +01111101000101001011 +01111101010010011101 +01111101010100010101 +01111110101101111011 +01111110101111001010 +01111110111010101010 +01111110111011000110 +10000001011000011010 +10000101011000010011 +10001001111011001011 +10001100000101000001 +10001100010011010101 +10001100010111010101 +10001100010111011100 +10001100011011110000 +10010001110110101010 +10011000101001000001 +10011001010001010110 +10011110111010100001 +10011111111110010101 +10101011001001100101 +10101100101110100101 +10101101011110000110 +10110011000000000111 +10111100010001100110 +10111101010010110110 +11000000010101100000 +11001000011011000010 +11001000011100001111 +11001001010000111000 +11001010011100001010 +11010100011000001011 +11010110000110111010 +11100100101010011101 +11100100110011011001 +11100101010010110000 +11100101011010110001 +11100111010011011110 +11101000011000001111 +11110101010111011110 +11111101000110111111 +Started at Sat Apr 26 04:51:36 +0100 2008 +Took 2193.372392 seconds +Generation number 14 +00000000010111010110 +00000000011010101000 +00000001011011011001 +00000010000110111010 +00000010010110110110 +00000011010000100101 +00000100100110101110 +00000100111000001011 +00000101011100110001 +00000101101100011011 +00000101111100110011 +00000110010110111100 +00000110010110111110 +00000110011010101011 +00001000010001101011 +00001000111001001110 +00001001010001010110 +00001001010001100010 +00001001010001101011 +00001001010001111110 +00001001010010011011 +00001001010010110110 +00001001010101001010 +00001001010110111110 +00001001011011101100 +00001011010110111111 +00001011011101001101 +00001011011111000010 +00001011100101100110 +00001011101110100101 +00001011101110100101 +00001011101110110000 +00001011110110000101 +00001011111100000011 +00001011111100001011 +00001100000011011011 +00001100000110101011 +00001100000111111011 +00001100010111101001 +00001101010011011011 +00001110000011011011 +00001110010111111101 +00001110101010011100 +00001110101111001110 +00001110111011000110 +00001111011010111010 +00010000101010101010 +00010001000111101011 +00010001010000001011 +00010001010000100101 +00010100000011011011 +00010100011111100110 +00010100100011000110 +00010100110111000111 +00011000011100010011 +00011000111010100011 +00011001010011100110 +00011001110100010101 +00011001110110101111 +00011011100101101010 +00011011101101100110 +00011011101110000101 +00011011101110111111 +00011100010111111011 +00011100110011101011 +00011101011100110101 +00011110001100011010 +00011110001110101010 +00011110011100011010 +00011110111010110001 +00011111111110010101 +00100100011011011111 +00100110011101001011 +00101000110000001011 +00101000111111111011 +00101001010001111010 +00101001011001011010 +00101010011010100001 +00101101011001010111 +00101110001000011100 +00110000011000011011 +00110001011011001011 +00110010111010011010 +00110100101110001110 +00110100110110111010 +00110110011000010011 +00110111000100100111 +00111000010010001010 +00111000110110100001 +00111000110111010101 +00111000110111010101 +00111001010111010110 +00111001011100010111 +00111010011110000101 +00111011100011101111 +00111011100101100110 +00111100010110110010 +00111100010111010101 +00111100011000000101 +00111100011011001001 +00111100011011001011 +00111100110000011011 +00111100111011001011 +00111100111110101010 +00111100111110101011 +00111101010010011101 +00111101010011010101 +00111101100101001011 +00111110010111101111 +00111110011000001011 +00111110011110101111 +00111110101010101111 +00111110110000110011 +00111110110010110000 +00111110111111101011 +00111111010011110110 +00111111110010100101 +01000001100010001101 +01000101010010000011 +01001000011110111110 +01001000111110110100 +01001001011111000111 +01001010001101010100 +01001010010111010110 +01001011010100101011 +01001101110110000101 +01011010011110111110 +01011011110000110100 +01011100010011100101 +01011100101111000001 +01011110010011011110 +01100000010001101011 +01100101010111111110 +01100101011111110110 +01100110110110000101 +01101001111111001111 +01101100000011111011 +01101101000100110101 +01101101010000111110 +01101101010010011101 +01101110000110101011 +01101111010011101011 +01101111111011000101 +01110000011110110100 +01110100010101100111 +01110100011011010001 +01110101010111101011 +01110101111011101011 +01111000010011001101 +01111000011011101011 +01111000011111101011 +01111000011111101011 +01111001001110111110 +01111001101110111111 +01111011010100001100 +01111100101111100011 +01111100111101100010 +01111101000110111111 +01111101010011110110 +01111110100110010001 +01111110101111001110 +01111111111010101010 +01111111111010101101 +01111111111101100101 +10000001001010010011 +10000001101110111110 +10000101101110011000 +10001001011100000001 +10001010111100001010 +10001101001101111011 +10001101010010110001 +10011001010001010100 +10011001010001100001 +10011011000001101101 +10011111110110010100 +10101000010110011011 +10101011010100001100 +10101100111101000000 +10110001000111110111 +10110011000100001000 +10110110010110111100 +10111000111111001011 +10111101010010111110 +10111101010011110110 +11000100101010011101 +11000101010001101111 +11001000011100001111 +11001010011100001010 +11001010011110111110 +11001011010101100110 +11010100011000001011 +11011000010000111110 +11011110000110111010 +11100100101010011010 +11100100110000010011 +11100100110011011001 +11101100000011111011 +11101100011100110101 +11110100110111011101 +11111101000110111110 +Started at Sat Apr 26 05:28:09 +0100 2008 +Took 2335.23266 seconds +Generation number 15 +00000000010011011011 +00000000011000101000 +00000001010000001011 +00000001011011000101 +00000001011011011001 +00000011010000100101 +00000011010000111001 +00000100101101100101 +00000101111101100111 +00000111110010100101 +00001000010011010101 +00001000010100100011 +00001000010101101011 +00001000010110110110 +00001000100110101001 +00001000111001001110 +00001001001001010110 +00001001010000001011 +00001001010000010110 +00001001010001010110 +00001001010001010111 +00001001010010110110 +00001001010010110110 +00001001011011101100 +00001001110111000110 +00001010111011101011 +00001011011110001011 +00001011100101100101 +00001011101010010101 +00001011101011110001 +00001011101110100110 +00001011110110000101 +00001011111010001011 +00001011111100001011 +00001011111110100101 +00001100000011011011 +00001100000011111011 +00001100000110101011 +00001100110010111010 +00001100111011101011 +00001101010010110001 +00001110000011011011 +00001110000011111011 +00001110001000011100 +00001110010010110000 +00001110010111100111 +00001110010111111001 +00001110110111010101 +00001111000011011011 +00001111001010111110 +00001111011110111010 +00010011101110100000 +00010100011110100110 +00010100101110111111 +00010100110111000111 +00010101000011111011 +00011000011100011111 +00011001101110110110 +00011001110100010101 +00011001110110100010 +00011001111100010011 +00011010011100011110 +00011011101001101110 +00011011101101100110 +00011011101110111111 +00011100000011011011 +00011100010111100101 +00011100101100100101 +00011100111110101011 +00011101010000010011 +00011101011011001000 +00011101110110101111 +00011110001100000101 +00011110001100011011 +00011110001100011011 +00011110001111001101 +00011110011100011010 +00011110111101100110 +00011111110110010100 +00011111110110010111 +00100000010001101011 +00100010010001101011 +00101000111001001110 +00101001010010011010 +00101001010101001000 +00101001010111000010 +00101001011010101000 +00101001110111010111 +00101100001011001011 +00101100010111100110 +00101101010000100010 +00101101010011010101 +00101111011110011010 +00110011010110111111 +00110100011001011010 +00110100011100000101 +00110100011111100110 +00110100100110100110 +00110100110110111010 +00110100110110111110 +00110100110111111010 +00110100110111111010 +00110110001100000010 +00110110010111101110 +00111000100110101110 +00111000110011010101 +00111000110110111110 +00111001010110111111 +00111001011100010001 +00111001011100100111 +00111001110011101111 +00111010011110000101 +00111010011110011010 +00111011010111010000 +00111100011000001010 +00111100110111011010 +00111100111110100010 +00111101010001100010 +00111101111000110101 +00111110010100000111 +00111110010111010110 +00111110011101101111 +00111110011110101111 +00111110110010111000 +00111110111100011010 +01000000010010011011 +01000001100010001101 +01000100101011000110 +01001000111110110100 +01001001011011101000 +01001010001101010100 +01001011010001111011 +01001011010100101011 +01001011010100110100 +01001011110110000101 +01001011111110110100 +01001100010111100001 +01001101110110000101 +01001101110110000101 +01010101111000001011 +01011010011110111010 +01011011010000110100 +01011110000110111011 +01100000010001101011 +01100000010101101011 +01100100110111011001 +01100101011111110110 +01100110110010001011 +01100110110100000110 +01101000010101000110 +01101001011111000111 +01101011111111001111 +01101100000011111011 +01101110101010011100 +01101110111101000000 +01101111111011000100 +01110000011110101001 +01110000011110110100 +01110010011001101011 +01110011010000001100 +01111000010010100010 +01111000110011010101 +01111001011011100010 +01111010101110101110 +01111100111101101101 +01111100111101110010 +01111101000110010011 +01111101010011110111 +01111101110011110010 +01111110101110001111 +01111111011101100101 +01111111110110101010 +10000100010110111100 +10000101101110011001 +10000101111110110011 +10001100000111101011 +10001101001101111010 +10011000010001101110 +10011100110011100101 +10011101001101110011 +10011110010011100010 +10011111110111111101 +10100000011000010011 +10101100110101010000 +10101111010000111110 +10110010110110111100 +10110101010001011011 +10111110101111001110 +11000100100101100110 +11001001010010011011 +11001010011001011011 +11001010011110111010 +11011000000000111101 +11011000010000010101 +11011110000110110101 +11100100101010011110 +11100100101010011110 +11100100110000010101 +11101100000011011011 +11111101000110111110 +Started at Sat Apr 26 06:07:05 +0100 2008 +Took 2289.021254 seconds +Generation number 16 +00000000010011011011 +00000001010000010111 +00000010111011110111 +00000011000000111001 +00000011110110000010 +00000100100101100110 +00000100101011000110 +00000100110000010101 +00000101000110111110 +00000101111011001101 +00000111011011001000 +00000111100010100100 +00000111100010100101 +00000111110010001011 +00001000010010110000 +00001000010100100110 +00001000110001001110 +00001000110100010101 +00001000110110100101 +00001001000110100111 +00001001010000010110 +00001001010001011011 +00001001010101100111 +00001001010110111111 +00001001011011101100 +00001001111110010011 +00001010000001001011 +00001010111101100110 +00001011010010011110 +00001011101011110010 +00001011101011110100 +00001011101110100100 +00001011111100001001 +00001011111100011011 +00001011111110110100 +00001100010010111000 +00001100011001101011 +00001101010001001010 +00001101010010110001 +00001101110110101010 +00001101111011011001 +00001110000011011011 +00001110000111101011 +00001110010000001011 +00001110010010110000 +00001110010011100111 +00001110100110100110 +00001111001010111110 +00001111001010111110 +00001111001010111110 +00001111100101100101 +00001111110110000100 +00010000011000101000 +00010011101110101111 +00010100011001011011 +00010100011110100010 +00010101000011110101 +00011000011100011111 +00011000110110111110 +00011001010001010101 +00011001110100010101 +00011001110100101110 +00011010010000011011 +00011011010100110100 +00011011101011101011 +00011011101101101110 +00011011101111011101 +00011100000011111110 +00011100001100001011 +00011100010100001111 +00011100101100100101 +00011100101101000101 +00011101000000111111 +00011101110010101011 +00011101110110101010 +00011110001100000101 +00011110111101100110 +00011111000010010000 +00011111011100011110 +00011111110110010101 +00011111111100001010 +00100000010001100010 +00100010010001101111 +00100010010011000010 +00100011010001101011 +00100011010010100101 +00100101010010100001 +00101001010010011010 +00101001010110000101 +00101001110111010111 +00101010111011000011 +00101011111100100101 +00101100001011001011 +00101100001011010100 +00101100010001011001 +00101101010111001011 +00101101110111010000 +00101110111101000000 +00110000010110101010 +00110000110000001010 +00110011010010110110 +00110011011110110111 +00110011110110100000 +00110100010110111110 +00110100011011101100 +00110100011100000101 +00110100110110111010 +00110110001100010010 +00110110110111101010 +00111000100110101110 +00111000101110101010 +00111001000011011011 +00111001010010011010 +00111001011100110110 +00111010001110000101 +00111010010111100111 +00111010011110000101 +00111011010000110100 +00111011010011010000 +00111011010111100110 +00111100011110111010 +00111100110111011000 +00111100111110000010 +00111101110111111010 +00111110010100000110 +00111110011011111010 +00111110011101101111 +00111110011110000101 +01000100101010000110 +01000100101011000110 +01001001010001110111 +01001001110111111010 +01001010011100101011 +01001011011110111010 +01001011100110010101 +01001100101011000110 +01001110101110101011 +01001110110110101111 +01010001011001101011 +01011000001010111010 +01011000011100011111 +01011000110011010101 +01011000110011110101 +01011011100011110001 +01011011110101000000 +01011100001001011110 +01011111110110000101 +01100000010100100011 +01100100110001100110 +01100100110111111001 +01100110110010011011 +01101000010000001011 +01101101010000100011 +01110001011110101001 +01110011010110011110 +01111000010010100010 +01111000100011010101 +01111000100110101100 +01111000110011110101 +01111010111110101110 +01111100111101101101 +01111101100011111111 +01111111011011001100 +01111111110110101111 +10000000001000100101 +10000100010110111100 +10001000110100101011 +10001001011011101100 +10001001110111000110 +10001011011110001011 +10001110000111101011 +10001111010110111111 +10010101110110101111 +10011000010001010101 +10011010010011100010 +10011010011110011010 +10011101101100100101 +10011101110101010111 +10011110000010100101 +10101001011000101000 +10101111010011111011 +10110101010001010110 +10111001111001001110 +11000001011011000101 +11000100101011000110 +11001001010010011011 +11001010011001011010 +11001011010010100101 +11001101001101011010 +11001101010010110001 +11010000010000010101 +11011000000000111001 +11011000010000010100 +11011000010001001111 +11011000010010010101 +11011001010011011011 +11100000010001101011 +11100100101010011011 +11111000111101101101 +11111001100010001111 +Started at Sat Apr 26 06:45:14 +0100 2008 +Took 2222.522446 seconds +Generation number 17 +00000000000000010010 +00000000001010101000 +00000000010000101011 +00000010000000111001 +00000010011011100011 +00000011000000000101 +00000011000000111001 +00000011101110110100 +00000011110110000010 +00000100100000010101 +00000100101101111010 +00000100110000010101 +00000101000110111110 +00000101110100010101 +00000101111011001101 +00000110001001011010 +00000111010001110111 +00000111011011001001 +00000111110010100100 +00001000010010110100 +00001000010100100111 +00001000110110100101 +00001000110110100101 +00001001010000010110 +00001001010001001010 +00001001010011011111 +00001001010110101001 +00001001011011101100 +00001001100010100101 +00001001110011011011 +00001001111100000001 +00001001111110010011 +00001010000001001011 +00001010111100011011 +00001010111101100011 +00001011001110100100 +00001011010110111111 +00001011101011110001 +00001011101011110011 +00001011110110101010 +00001011111100001001 +00001100010011110001 +00001100101111100110 +00001100110001101110 +00001101001101011010 +00001101010001101010 +00001101010111100110 +00001101010111101011 +00001 \ No newline at end of file diff --git a/lib/.svn/all-wcprops b/lib/.svn/all-wcprops new file mode 100644 index 0000000..8034615 --- /dev/null +++ b/lib/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 41 +/svn/njae/!svn/ver/6/TrapTheCap/trunk/lib +END diff --git a/lib/.svn/entries b/lib/.svn/entries new file mode 100644 index 0000000..691e062 --- /dev/null +++ b/lib/.svn/entries @@ -0,0 +1,100 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/lib +http://scripts.njae.me.uk/svn/njae + + + +2008-04-25T21:36:06.714616Z +6 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +libttc.rb +file +69 + + + + + + + + + + + + + + + + + + + +deleted + +libpplayer.rb +file +69 + + + + + + + + + + + + + + + + + + + +deleted + +libgenetics.rb +file +69 + + + + + + + + + + + + + + + + + + + +deleted + diff --git a/lib/.svn/format b/lib/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/lib/.svn/format @@ -0,0 +1 @@ +8 diff --git a/lib/.svn/text-base/libpplayer.rb.netbeans-base b/lib/.svn/text-base/libpplayer.rb.netbeans-base new file mode 100644 index 0000000..cf80ee5 --- /dev/null +++ b/lib/.svn/text-base/libpplayer.rb.netbeans-base @@ -0,0 +1,106 @@ +# == Synopsis +# +# Library to support a Trap the Cap player that uses potentials to select the +# best move +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +require 'lib/libttc' +require 'lib/libgenetics' + + +# Play Trap the Cap by using potential fields. For each possible move, +# calculate the field strength and pick the move with the lowest potential +class Potential_player + + attr_reader :friend_pull, :enemy_pull, :base_pull, + :safe_bonus, :capture_bonus + + def initialize(args, verbose = false) + @friend_pull = args[:friend_pull] || 1 + @enemy_pull = args[:enemy_pull] || 0.5 + @base_pull = args[:base_pull] || 2 + @safe_bonus = args[:safe_bonus] || 8 + @capture_bonus = args[:capture_bonus] || 10 + + @verbose = verbose + end + + # Find the best move of the possible ones + def best_move(game, die_result) + me = game.current_player + possible_moves = game.possible_moves(die_result, me) + scored_moves = possible_moves.collect do |m| + begin + game.apply_move! m + score = score_position(game, me) +# game.undo_move! + rescue GameWonNotice + score = 10000 + ensure + game.undo_move! + end + puts "#{m} scores #{score}" if @verbose + [m, score] + end + best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0] + end + + # Calculate the potential score of a position for a given player + def score_position(game, player) + score = 0 + game.pieces.each_value do |piece| + here = piece.position + if piece.colour == player + game.pieces.each_value do |other_piece| + if other_piece.colour == player + score += game.board.distance_between[here.place][other_piece.position.place] * @friend_pull + else + score += game.board.distance_between[here.place][other_piece.position.place] * @enemy_pull + end + end + score += piece.contains.length * @capture_bonus + score += game.board.distance_between[here.place][game.board.positions[player].place] * + piece.contains.length * @base_pull + elsif here == game.board.positions[player] + score += @safe_bonus + end + end + score + end + + + # Convert a player to a bitstring + def to_bitstring + (@friend_pull * 4).to_i.to_bitstring(4).gray_encode + + (@enemy_pull * 4).to_i.to_bitstring(4).gray_encode + + (@base_pull * 4).to_i.to_bitstring(4).gray_encode + + @safe_bonus.to_bitstring(4).gray_encode + + @capture_bonus.to_bitstring(4).gray_encode + end + + # Convert a player to a genome + def to_genome + Genome.new(self.to_bitstring) + end +end + + +class Genome + + # Create a potential player from a genome + def to_potential_player + friend_pull = @genome[0, 4].gray_decode.to_decimal.to_f / 4 + enemy_pull = @genome[4, 4].gray_decode.to_decimal.to_f / 4 + base_pull = @genome[8, 4].gray_decode.to_decimal.to_f / 4 + safe_bonus = @genome[12, 4].gray_decode.to_decimal + capture_bonus = @genome[16, 4].gray_decode.to_decimal + Potential_player.new({:friend_pull => friend_pull, + :enemy_pull => enemy_pull, :base_pull => base_pull, + :safe_bonus => safe_bonus, :capture_bonus => capture_bonus}) + end +end diff --git a/lib/.svn/text-base/libttc.rb.netbeans-base b/lib/.svn/text-base/libttc.rb.netbeans-base new file mode 100644 index 0000000..97845c7 --- /dev/null +++ b/lib/.svn/text-base/libttc.rb.netbeans-base @@ -0,0 +1,615 @@ +# == Synopsis +# +# Library to support Trap the Cap play +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# == Change history +# Version 1.1:: 07 Sep 2007 +# * Changed format for showing moves via bases. +# * Raise error when moving via base without captured pieces +# * Raise error when moving onto a safe space with 3 or more +# pieces already there +# Version 1.2:: 10 Sep 2007 +# * Incorporated changes in move legality above into +# Game#possible_moves +# Version 1.3:: 25 Mar 2008 +# * Fixed bug to detect a winner, and also eliminate players +# that have no uncaptured pieces. + +# Errors for a game + +# Pieces can only capture pieces that they're on. +class InvalidCaptureError < StandardError +end + +# Moves can only be [1..6] spaces +class InvalidMoveError < StandardError +end + +# Game is won when only one player has uncaptured pieces +class GameWonNotice < StandardError +end + + +# Each possible position for a piece is an object +# Each neighbour is another position object +class Position + attr_reader :place # the name of this place + attr_accessor :contains # the pieces it contains + attr_accessor :neighbours # the positions that neighbour it + + def initialize(place, safety, base) + @place = place + @safe = safety + @base = base + @neighbours = Array.new + end + + # is this position a safety one (i.e. no captures allowed)? + def safe? + @safe + end + + # Is this position a base? + def base? + @base + end + + def to_s + @place + end + + def to_str + to_s + end + +end + + +# The game board +class Board + + attr_reader :positions + attr_reader :valid_moves + attr_reader :distance_between + attr_reader :centre + + + # A laborious procedure to create all the positions and tie them all together + def initialize(spokes, spoke_length, arc_length) + # A hash of all positions, indexed by position names + @positions = Hash.new + @centre = Position.new('ac' + spoke_length.to_s, false, false) + @positions['ac' + spoke_length.to_s] = centre + a1_corner = nil + end_of_previous_arc = nil + + # Do each arc-spoke-base set + (?a...(?a + spokes)).each do |arc_code| + arc = arc_code.chr + base = Position.new(arc, false, true) + this_arc = Array.new + + # build the arc + (1..arc_length).each do |arc_position| + position_name = arc + arc_position.to_s + arc_place = Position.new(position_name, arc_position == 4, false) + arc_place.neighbours = [] + @positions[position_name] = arc_place + this_arc << arc_place + a1_corner = a1_corner || arc_place + end + (0...arc_length).each do |arc_position| + if arc_position > 0 + this_arc[arc_position].neighbours << this_arc[arc_position - 1] + end + if arc_position < (arc_length - 1) + this_arc[arc_position].neighbours << this_arc[arc_position + 1] + end + end + + # build the spoke + this_spoke = Array.new + (1..(spoke_length - 1)).each do |spoke_position| + position_name = arc + "c" + spoke_position.to_s + spoke_place = Position.new(position_name, spoke_position == 3, false) + spoke_place.neighbours = [] + @positions[position_name] = spoke_place + this_spoke << spoke_place + end + (0...(spoke_length - 1)).each do |spoke_position| + if spoke_position > 0 + this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1] + end + if spoke_position < spoke_length - 2 + this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1] + end + end + + # tie the spoke and arc together, + this_arc[0].neighbours << this_spoke[0] + this_spoke[0].neighbours << this_arc[0] + + # tie the spoke to the centre, and + this_spoke[-1].neighbours << @centre + @centre.neighbours << this_spoke[-1] + + # tie the base to the arc + base = Position.new(arc, false, true) + @positions[arc] = base + base.neighbours << this_arc[0] + this_arc[0].neighbours << base + + # record the ends of the arc for tying to adjacent arcs + if end_of_previous_arc + end_of_previous_arc.neighbours << this_arc[0] + this_arc[0].neighbours << end_of_previous_arc + end + end_of_previous_arc = this_arc[-1] + + end # arc + + # tie both ends of the rim together + a1_corner.neighbours << end_of_previous_arc + end_of_previous_arc.neighbours << a1_corner + + cache_valid_moves + + end # def + + def to_s + layout + end + + def to_str + to_s + end + + + # For each position, show its name and what it touches + def layout + out_string = "" + @positions.keys.sort.each do |position| + out_string << sprintf("%s touches ", @positions[position]) + @positions[position].neighbours.each do |neighbour| + out_string << sprintf("%s, ", neighbour) + end + out_string << sprintf("\n") + end + out_string + end + + + # Precompute the valid moves for this board, and the distances between each + # pair of positions + def cache_valid_moves + # A hash of arrays. The has key is the name of a positions. The array + # element [i] stores the positions that are i spaces from here + @valid_moves = Hash.new + # A hash of hashes. Given two names, return the shortest distance between + # the two locations + @distance_between = Hash.new + @positions.each do |place, position| + @valid_moves[place] = Array.new + @distance_between[place] = Hash.new + @valid_moves[place][0] = [@positions[place]] + @distance_between[place][place] = 0 + # Find the shortest routes by Dijkstra's algorithm + agenda = [position] + closed_list = [position] + i = 1 + while not agenda.empty? + @valid_moves[place][i] = [] + new_agenda = [] + agenda.each do |pos| + valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) } + @valid_moves[place][i] += valid_extensions + valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i } + closed_list += valid_extensions + new_agenda += valid_extensions + end + agenda = new_agenda + i += 1 + end + end + end + +end + + +# Each piece on the board is an object +class Piece + attr_reader :colour + attr_accessor :position, :contains, :captured + + def initialize(number, position, colour) + @number = number + @position = position + @colour = colour + @captured = false + @contains = [] + end + + def name + @colour + @number.to_s + end + + def to_s + self.name + end + + def to_str + to_s + end + + def move_to(new_position) + @position = new_position + @contains.each {|c| c.move_to(new_position)} + end + + # Caputre another piece + def capture(other_piece) + if @position = other_piece.position + @contains << other_piece + @contains += other_piece.contains + other_piece.contains = [] + other_piece.captured = true + else + raise(InvalidCaptureError, + "Piece #{self.name} cannot capture #{other_piece.name}: different locations") + end + end + +end + + +# A move in a game +class Move + attr_reader :piece, :destination + + def initialize(piece, destination, via_base = false) + @piece = piece + @destination = destination + @via_base = via_base + end + + def via_base? + @via_base + end + + # Write a move to a string + # Note the inverse, String#to_move, is defined below + def to_s + if @via_base + if @destination.base? + @piece.to_s + " " + @destination.to_s + else + @piece.to_s + " " + piece.colour + " " + @destination.to_s + end + else + @piece.to_s + " " + @destination.to_s + end + end + + def to_str + to_s + end + +end + + + +# A class to record each of the states previously found in a game. +# Note that this is a deep copy of the pieces and what they've captured, so +# you'll need to convert back +class GameState + attr_accessor :move, :player, :pieces_after_move + + def initialize(move, player, pieces) + @move = move + @player = player + @pieces_after_move = Hash.new + pieces.each {|k, p| @pieces_after_move[k] = p.dup} + @pieces_after_move.each_value {|p| p.contains = []} + # and now to make the captured pieces point to the copies + pieces.each do |k, p| + p.contains.each do |captured_piece| + @pieces_after_move[k].capture(@pieces_after_move[captured_piece.name]) + end + end + end + + def ==(other) + @move.to_s == other.move.to_s and + @player == other.player and + @piece_after_move == other.pieces_after_move + end + +end + + +# A game of Trap the Cap. It keeps a history of all previous states. +class Game + + attr_reader :history + attr_reader :current_player, :players + attr_reader :board + attr_reader :pieces + + # Create a new game + def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, + pieces_each = 6) + @board = Board.new(spokes, spoke_length, arc_length) + @history = [] + @pieces = Hash.new + @players = case + when players == 2 ; ['a', 'd'] + when players == 3 ; ['a', 'c', 'e'] + when players == 4 ; ['a', 'b', 'd', 'e'] + when players == 5 ; ['a', 'b', 'c', 'd', 'e'] + when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f'] + end + @current_player = 'a' + @players.each do |player| + players_base = @board.positions[player] + (1..pieces_each).each do |count| + piece = Piece.new(count, players_base, player) + @pieces[player + count.to_s] = piece + end + end + end + + + # Apply a single move to a game. + def apply_move!(move, player = @current_player) + # Check the move is a valid one + raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name) + raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player + raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured + raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty? + if move.destination.safe? + if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3 + raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there") + end + end + if move.via_base? + moved_distance = board.distance_between[move.piece.position.place][player] + + board.distance_between[player][move.destination.place] + else + moved_distance = board.distance_between[move.piece.position.place][move.destination.place] + end + raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places (from #{move.piece.position} to #{move.destination})") if moved_distance < 1 or moved_distance > 6 + + # Apply this move + move.piece.move_to(move.destination) + + # Capture anything already there (unless it's a safe place or a base, + # or our own colour, or already captured) + unless move.destination.safe? or move.destination.base? + @pieces.each do |name, target_piece| + if target_piece.position == move.destination and + target_piece != move.piece and + not move.piece.contains.member?(target_piece) and + target_piece.colour != player and + not target_piece.captured + move.piece.capture(target_piece) + end + end + end + + # If the move was via our base, drop all captured pieces + if move.via_base? + capturers_base = board.positions[move.piece.colour] + move.piece.contains.each do |captured_piece| + captured_piece.move_to capturers_base + captured_piece.captured = false if captured_piece.colour == move.piece.colour + end + move.piece.contains = [] + end + + # Record the new stae + this_game_state = GameState.new(move, player, @pieces) + @history << this_game_state + + # Retain only players that have uncaptured pieces. + # If there's only one player with uncaptured pieces, declare a win. + potential_players = [] + @players.each do |p| + if (@pieces.values.select {|piece| piece.colour == p}).any? {|piece| not piece.captured} + potential_players << p + end + # potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured} + end + if potential_players.length <= 1 + raise(GameWonNotice, "Game won by #{potential_players[0]}") + end + @players = potential_players.sort + end + + # Undo a move + def undo_move! + if @history.length > 1 + # general case + state_to_restore = @history[-2] + @current_player = @history[-1].player + @pieces.each do |name, piece| + copy_piece = state_to_restore.pieces_after_move[name] + piece.position = copy_piece.position + piece.captured = copy_piece.captured + piece.contains = [] + copy_piece.contains.each do |p| +# piece.capture(@pieces[p.name]) + piece.contains << @pieces[p.name] + end + end + @history.pop + elsif @history.length == 1 + # reset to start + @current_player = 'a' + @pieces.each do |name, piece| + piece.position = @board.positions[piece.colour] + piece.captured = false + piece.contains = [] + end + @history.pop + end + end + + # Apply a list of moves in order + def apply_moves!(moves) + moves.each do |move| + if move.via_base? + moved_distance = board.distance_between[move.piece.position.place][@current_player] + + board.distance_between[@current_player][move.destination.place] + else + moved_distance = board.distance_between[move.piece.position.place][move.destination.place] + end + self.apply_move!(move, @current_player) + next_player! unless moved_distance == 6 + end + end + + + # Set the current player to be the next player + def next_player! + original_player = @current_player + begin + if @current_player == @players[-1] + @current_player = @players[0] + else + @current_player = @players[@players.index(@current_player) + 1] + end + end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player + @current_player + end + + + # Return an array of all possible moves from this state, given the die roll + # and the active player + def possible_moves(die_result, player = @current_player) + moves = [] + @pieces.each do |key, piece| + # only move current player's pieces, and only if they're not captured + if piece.colour == player and (not piece.captured) + (@board.valid_moves[piece.position.place][die_result]).each do |destination| + if destination.safe? + if (@pieces.find_all {|k, p| p.position == destination}).length < 3 + moves << Move.new(piece, destination, false) + end + else + moves << Move.new(piece, destination, false) unless destination.base? + end + end + # if we can move to our base (but not already on it), add moves via that... + if @board.distance_between[piece.position.place][player] <= die_result and + not piece.position.place == player and + not piece.contains.empty? + distance_after_base = die_result - @board.distance_between[piece.position.place][player] + (@board.valid_moves[player][distance_after_base]).each do |destination| + if destination.safe? + if (@pieces.find_all {|k, p| p.position == destination}).length < 3 + moves << Move.new(piece, destination, true) + end + else + moves << Move.new(piece, destination, true) + end + end + end + end + end + moves + end + + + def build_state_string + outstr = "Current player = #{@current_player}\n" + @pieces.keys.sort.each do |piece_name| + if @pieces[piece_name].captured + outstr << "Piece #{piece_name} captured, at #{@pieces[piece_name].position}\n" + else + outstr << "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}\n" + end + end + outstr + end + + # Show the state of the board + def show_state + puts build_state_string +# @pieces.keys.sort.each do |piece_name| +# if @pieces[piece_name].captured +# puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}" +# else +# puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}" +# end +# end + end + + def to_s + show_state + end + + def to_str + to_s + end + + + # Given a set of lines from an input file, turn them into a Game object and + # a set of Move objects. + # Note the multiple return values. + # Class method + def Game.read_game(gamelines) + gamelines.each {|l| l.chomp!} + game = Game.new(gamelines[0].to_i, 6, 6, 6, 6) + moves = [] + gamelines[1..-2].each {|m| moves << m.to_move(game)} + return game, moves, gamelines[-1].to_i + end + + +end + + +# Extension to String class to convert a move-description string into a Move object. +# This is the inverse of the Move#to_s method +class String + def to_move(game) + move_elements = self.downcase.split + piece_name = move_elements[0] + destination_name = move_elements[-1] + if destination_name.length > 2 and + destination_name[-2,2] == game.board.centre.place[-2,2] + destination_name = game.board.centre.place + end + raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name) + raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name) + # Deal with the synonyms for the centre position + via_base = (destination_name.length == 1 or move_elements.length > 2) + Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base) + end +end + + +# Read a game description file and convert it into a Game object and set of Move objects. +# Note that Game.read_game method returns multiple values, so this one does too. +class IO + def IO.read_game(filename) + gamelines = IO.readlines(filename) + return Game.read_game(gamelines) + end +end diff --git a/lib/libpplayer.rb~ b/lib/libpplayer.rb~ new file mode 100644 index 0000000..9dc6bd4 --- /dev/null +++ b/lib/libpplayer.rb~ @@ -0,0 +1,106 @@ +# == Synopsis +# +# Library to support a Trap the Cap player that uses potentials to select the +# best move +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +require 'libttc' +require 'libgenetics' + + +# Play Trap the Cap by using potential fields. For each possible move, +# calculate the field strength and pick the move with the lowest potential +class Potential_player + + attr_reader :friend_pull, :enemy_pull, :base_pull, + :safe_bonus, :capture_bonus + + def initialize(args, verbose = false) + @friend_pull = args[:friend_pull] || 1 + @enemy_pull = args[:enemy_pull] || 0.5 + @base_pull = args[:base_pull] || 2 + @safe_bonus = args[:safe_bonus] || 8 + @capture_bonus = args[:capture_bonus] || 10 + + @verbose = verbose + end + + # Find the best move of the possible ones + def best_move(game, die_result) + me = game.current_player + possible_moves = game.possible_moves(die_result, me) + scored_moves = possible_moves.collect do |m| + begin + game.apply_move! m + score = score_position(game, me) +# game.undo_move! + rescue GameWonNotice + score = 10000 + ensure + game.undo_move! + end + puts "#{m} scores #{score}" if @verbose + [m, score] + end + best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0] + end + + # Calculate the potential score of a position for a given player + def score_position(game, player) + score = 0 + game.pieces.each_value do |piece| + here = piece.position + if piece.colour == player + game.pieces.each_value do |other_piece| + if other_piece.colour == player + score += game.board.distance_between[here.place][other_piece.position.place] * @friend_pull + else + score += game.board.distance_between[here.place][other_piece.position.place] * @enemy_pull + end + end + score += piece.contains.length * @capture_bonus + score += game.board.distance_between[here.place][game.board.positions[player].place] * + piece.contains.length * @base_pull + elsif here == game.board.positions[player] + score += @safe_bonus + end + end + score + end + + + # Convert a player to a bitstring + def to_bitstring + (@friend_pull * 4).to_i.to_bitstring(4).gray_encode + + (@enemy_pull * 4).to_i.to_bitstring(4).gray_encode + + (@base_pull * 4).to_i.to_bitstring(4).gray_encode + + @safe_bonus.to_bitstring(4).gray_encode + + @capture_bonus.to_bitstring(4).gray_encode + end + + # Convert a player to a genome + def to_genome + Genome.new(self.to_bitstring) + end +end + + +class Genome + + # Create a potential player from a genome + def to_potential_player + friend_pull = @genome[0, 4].gray_decode.to_decimal.to_f / 4 + enemy_pull = @genome[4, 4].gray_decode.to_decimal.to_f / 4 + base_pull = @genome[8, 4].gray_decode.to_decimal.to_f / 4 + safe_bonus = @genome[12, 4].gray_decode.to_decimal + capture_bonus = @genome[16, 4].gray_decode.to_decimal + Potential_player.new({:friend_pull => friend_pull, + :enemy_pull => enemy_pull, :base_pull => base_pull, + :safe_bonus => safe_bonus, :capture_bonus => capture_bonus}) + end +end diff --git a/main.rb b/main.rb new file mode 100755 index 0000000..ee03648 --- /dev/null +++ b/main.rb @@ -0,0 +1,13 @@ +#!/usr/bin/ruby -w + +require 'src/play' +require 'src/selection' + +pop1 = Population.new(100, 20) + +start = Time.now +puts "Started at #{start}" +pop1.tournament_select_population(0.8, 1000, true) +finish = Time.now +puts "Took #{finish - start}" + diff --git a/nbproject/.svn/all-wcprops b/nbproject/.svn/all-wcprops new file mode 100644 index 0000000..350b449 --- /dev/null +++ b/nbproject/.svn/all-wcprops @@ -0,0 +1,17 @@ +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/nbproject +END +project.properties +K 25 +svn:wc:ra_dav:version-url +V 67 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/nbproject/project.properties +END +project.xml +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/nbproject/project.xml +END diff --git a/nbproject/.svn/dir-prop-base b/nbproject/.svn/dir-prop-base new file mode 100644 index 0000000..a7ce626 --- /dev/null +++ b/nbproject/.svn/dir-prop-base @@ -0,0 +1,6 @@ +K 10 +svn:ignore +V 8 +private + +END diff --git a/nbproject/.svn/entries b/nbproject/.svn/entries new file mode 100644 index 0000000..a07ba75 --- /dev/null +++ b/nbproject/.svn/entries @@ -0,0 +1,52 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/nbproject +http://scripts.njae.me.uk/svn/njae + + + +2008-03-28T15:47:09.723420Z +24 +neil +has-props + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +project.properties +file + + + + +2008-03-25T11:44:50.000000Z +4903a98656892131addae4aea0a77d22 +2008-03-25T12:46:59.166018Z +23 +neil + +project.xml +file + + + + +2008-03-25T11:44:50.000000Z +9ff3dc942c9d9890138a20443f2eda06 +2008-03-25T12:46:59.166018Z +23 +neil + diff --git a/nbproject/.svn/format b/nbproject/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/nbproject/.svn/format @@ -0,0 +1 @@ +8 diff --git a/nbproject/.svn/text-base/project.properties.svn-base b/nbproject/.svn/text-base/project.properties.svn-base new file mode 100644 index 0000000..3b52a29 --- /dev/null +++ b/nbproject/.svn/text-base/project.properties.svn-base @@ -0,0 +1,7 @@ +javac.classpath= +main.file=ttc.rb +ruby.includejava=false +source.encoding=UTF-8 +src.dir=lib +src.src.dir=src +test.src.dir=test diff --git a/nbproject/.svn/text-base/project.xml.svn-base b/nbproject/.svn/text-base/project.xml.svn-base new file mode 100644 index 0000000..8e31144 --- /dev/null +++ b/nbproject/.svn/text-base/project.xml.svn-base @@ -0,0 +1,16 @@ + + + org.netbeans.modules.ruby.rubyproject + + + TrapTheCap + + + + + + + + + + diff --git a/nbproject/private/config.properties b/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..e69de29 diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..ee04c96 --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,15 @@ + + + + + file:/home/neil/programming/ruby/TrapTheCap/src/clockwise-cloud.rb + file:/home/neil/programming/ruby/TrapTheCap/src/gen1006.rb + file:/home/neil/programming/ruby/TrapTheCap/src/html-files/interface.html + file:/home/neil/programming/ruby/TrapTheCap/src/html-files/simple.html + file:/home/neil/programming/ruby/TrapTheCap/src/libttc-pplayer.rb + file:/home/neil/programming/ruby/TrapTheCap/src/libttc.rb + file:/home/neil/programming/ruby/TrapTheCap/src/sample-game.txt + file:/home/neil/programming/ruby/TrapTheCap/src/selection.rb + file:/home/neil/programming/ruby/TrapTheCap/src/ttc-ga-clustering.rb + + diff --git a/nbproject/private/rake-d.txt b/nbproject/private/rake-d.txt new file mode 100644 index 0000000..e69de29 diff --git a/nbproject/private/rake-t.txt b/nbproject/private/rake-t.txt new file mode 100644 index 0000000..f686624 --- /dev/null +++ b/nbproject/private/rake-t.txt @@ -0,0 +1 @@ +(in /home/neil/programming/ruby/TrapTheCap) diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..3b52a29 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +javac.classpath= +main.file=ttc.rb +ruby.includejava=false +source.encoding=UTF-8 +src.dir=lib +src.src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..8e31144 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,16 @@ + + + org.netbeans.modules.ruby.rubyproject + + + TrapTheCap + + + + + + + + + + diff --git a/play-one-game.rb b/play-one-game.rb new file mode 100644 index 0000000..f92e1e1 --- /dev/null +++ b/play-one-game.rb @@ -0,0 +1,29 @@ +#!/usr/bin/ruby -w + +require 'src/play' +require 'src/selection' + +winner_success_chance = 0.8 + +player_bitstrings = readlines.collect {|l| l.chomp.split(//).collect {|x| x.to_i}} + +# File.open('player.log', 'a') do |f| +# player_bitstrings.each {|b| f.puts "Process #{Process.pid}: Received #{b}"} +# end + +players = player_bitstrings.collect {|b| Genome.new(b).to_potential_player} + +handler = GameHandler.new(players, 1000) +winner, moves = handler.play + +if winner == :draw or rand > winner_success_chance + successful_player = players[rand(players.length)] +else + successful_player = winner +end + +# File.open('player.log', 'a') do |f| +# f.puts "Process #{Process.pid}: winner is #{successful_player.to_bitstring}" +# end + +puts "#{successful_player.to_bitstring}" \ No newline at end of file diff --git a/run-ga.rb b/run-ga.rb new file mode 100644 index 0000000..abd27c6 --- /dev/null +++ b/run-ga.rb @@ -0,0 +1,59 @@ +#!/usr/bin/ruby -w + +require 'src/play' +require 'src/selection' +# require 'systemu' + +pop = Population.new(5, 20) +generation_count = 1 +max_generations = 3 + +if File.file? 'player.log' + File.delete 'player.log' +end + +puts "Generation number #{generation_count}" +pop.individuals.sort {|x, y| x.genome <=> y.genome}.each {|i| puts "#{i.genome}"} + +while generation_count <= max_generations + start = Time.now + puts "Started at #{start}" + + new_population = [] + threads = [] + 1.upto(pop.individuals.length) do |i| + threads << Thread.new do + puts "Starting thread #{i}" + sleep 2 + player_count = rand(5) + 2 + pool_size = pop.individuals.length + players = [] + 1.upto(player_count) { players << pop.individuals[rand(pool_size)] } + IO.popen('ruby play-one-game.rb', 'r+') do |pipe| + players.each {|p| pipe << "#{p.genome}\n" ; puts "Game #{i}: putting player #{p.genome}"} +# players.each {|p| pipe << "#{p.genome}\n"} + pipe.close_write + new_population << Genome.new(pipe.readline.chomp.split(//).collect {|x| x.to_i}) + puts "Got result #{new_population[-1].genome}" + end +# game_input = (players.collect {|p| p.genome.to_s}).join("\n") +# game_result = '' +# puts "Calling game #{i} with input #{game_input}" +# status, game_result, stderr = systemu 'ruby play-one-game.rb', 'stdin' => game_input +# puts "Game #{i} returned #{game_result}" +# new_population << Genome.new(game_result.chomp.split(//).collect {|x| x.to_i}) + end + threads.each {|t| t.join} + end + + pop.individuals = new_population + + finish = Time.now + puts "Took #{finish - start} seconds" + pop1 = pop.crossover(0.7) + pop = pop1.mutation(0.05) + generation_count += 1 + puts "Generation number #{generation_count}" + pop.individuals.sort {|x, y| x.genome <=> y.genome}.each {|i| puts "#{i.genome}"} + $stdout.flush +end \ No newline at end of file diff --git a/src/.svn/all-wcprops b/src/.svn/all-wcprops new file mode 100644 index 0000000..e343057 --- /dev/null +++ b/src/.svn/all-wcprops @@ -0,0 +1,83 @@ +K 25 +svn:wc:ra_dav:version-url +V 42 +/svn/njae/!svn/ver/68/TrapTheCap/trunk/src +END +gen1006-clusters.txt +K 25 +svn:wc:ra_dav:version-url +V 63 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/gen1006-clusters.txt +END +gen1006.rb +K 25 +svn:wc:ra_dav:version-url +V 53 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/gen1006.rb +END +clockwise-p1.rb +K 25 +svn:wc:ra_dav:version-url +V 58 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/src/clockwise-p1.rb +END +libttc.rb +K 25 +svn:wc:ra_dav:version-url +V 52 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/libttc.rb +END +sample-game.txt +K 25 +svn:wc:ra_dav:version-url +V 58 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/sample-game.txt +END +play.rb +K 25 +svn:wc:ra_dav:version-url +V 50 +/svn/njae/!svn/ver/27/TrapTheCap/trunk/src/play.rb +END +selection.rb +K 25 +svn:wc:ra_dav:version-url +V 55 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/selection.rb +END +clockwise-cloud.rb +K 25 +svn:wc:ra_dav:version-url +V 61 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/src/clockwise-cloud.rb +END +libgenetics.rb +K 25 +svn:wc:ra_dav:version-url +V 57 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/libgenetics.rb +END +ttc.rb +K 25 +svn:wc:ra_dav:version-url +V 49 +/svn/njae/!svn/ver/23/TrapTheCap/trunk/src/ttc.rb +END +gen1006-clusters-old.txt +K 25 +svn:wc:ra_dav:version-url +V 67 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/gen1006-clusters-old.txt +END +libttc-pplayer.rb +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/libttc-pplayer.rb +END +ttc-ga-clustering.rb +K 25 +svn:wc:ra_dav:version-url +V 63 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/ttc-ga-clustering.rb +END diff --git a/src/.svn/entries b/src/.svn/entries new file mode 100644 index 0000000..100f0b1 --- /dev/null +++ b/src/.svn/entries @@ -0,0 +1,184 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/src +http://scripts.njae.me.uk/svn/njae + + + +2009-02-19T08:59:38.293071Z +68 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +gen1006.rb +file +69 + + + +2009-02-23T13:32:58.000000Z +597c993fb86e5502356a806a91127c5e +2009-02-23T14:02:44.812274Z +69 + +has-props + +libttc.rb +file +69 + + + +2009-02-23T13:25:21.000000Z +7a2bf3e4c83b3d2b06850a96bca4c4bc +2009-02-23T14:02:44.812274Z +69 + +selection.rb +file +69 + + + +2009-02-23T13:26:05.000000Z +a2a08d4d875fb316d0bd647564006a25 +2009-02-23T14:02:44.812274Z +69 +neil + +clockwise-cloud.rb +file + + + + +2007-08-31T19:04:34.000000Z +b53aaefb7e9da9aaf2ac304930c98504 +2008-03-25T12:46:59.166018Z +23 +neil + +libgenetics.rb +file +69 + + + +2009-02-23T13:25:19.000000Z +9eeccabbfc44763ad8898e77c2b65358 +2009-02-23T14:02:44.812274Z +69 + +ttc.rb +file + + + + +2008-03-25T11:46:58.000000Z +5609521da79d911a6144fded55f32d3f +2008-03-25T12:46:59.166018Z +23 +neil + +libttc-pplayer.rb +file +69 + + + +2009-02-23T13:25:20.000000Z +8c24369e159246ae762ba26115879019 +2009-02-23T14:02:44.812274Z +69 + +ttc-ga-clustering.rb +file +69 + + + +2009-02-23T13:24:21.000000Z +26b1e7b75853a57bf4af2854c3920b55 +2009-02-23T14:02:44.812274Z +69 + +gen1006-clusters.txt +file +69 + + + +2009-02-20T16:29:20.000000Z +8b954bea91eb9fb38495c3989a835a3e +2009-02-23T14:02:44.812274Z +69 + +cgi-files +dir + +clockwise-p1.rb +file + + + + +2007-08-31T11:19:53.000000Z +7af8c3a0bb94e558fedf57c8b2cb035d +2008-03-25T12:46:59.166018Z +23 +neil + +html-files +dir + +sample-game.txt +file +69 + + + +2009-02-23T13:53:03.000000Z +4a8276396b008060afd58562390d28d9 +2009-02-23T14:02:44.812274Z +69 + +play.rb +file + + + + +2008-04-23T19:32:54.000000Z +8f509d131f0ad009f369c4cd7a46fbcc +2008-04-23T19:36:22.892674Z +27 +neil + +gen1006-clusters-old.txt +file +69 + + + +2009-02-20T16:26:52.000000Z +e06ee3749f74806beeb62c62b0a2557f +2009-02-23T14:02:44.812274Z +69 + diff --git a/src/.svn/format b/src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/src/.svn/prop-base/gen1006.rb.svn-base b/src/.svn/prop-base/gen1006.rb.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/.svn/prop-base/gen1006.rb.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/.svn/text-base/clockwise-cloud.rb.svn-base b/src/.svn/text-base/clockwise-cloud.rb.svn-base new file mode 100644 index 0000000..3df362f --- /dev/null +++ b/src/.svn/text-base/clockwise-cloud.rb.svn-base @@ -0,0 +1,77 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +require 'libttc' + +def more_clockwise(this, other) + here = this.place + there = other.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves moves + + +# The piece to move is the least clockwise of my uncaptured pieces +# Always move pieces on the base first +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort {|x, y| more_clockwise x.position, y.position})[0] + +# Find the most clockwise move for this piece +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x.destination, y.destination} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/.svn/text-base/clockwise-p1.rb.netbeans-base b/src/.svn/text-base/clockwise-p1.rb.netbeans-base new file mode 100644 index 0000000..fd8e726 --- /dev/null +++ b/src/.svn/text-base/clockwise-p1.rb.netbeans-base @@ -0,0 +1,63 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith + + +require 'libttc' +require 'rdoc/usage' + +def more_clockwise(this, other) + here = this.destination.place + there = other.destination.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves moves + +# The piece to move is the uncaptured one of mine with the lowest number +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort_by {|p| p.name})[0] + +# find the most clockwise move +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x, y} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/.svn/text-base/clockwise-p1.rb.svn-base b/src/.svn/text-base/clockwise-p1.rb.svn-base new file mode 100644 index 0000000..fd8e726 --- /dev/null +++ b/src/.svn/text-base/clockwise-p1.rb.svn-base @@ -0,0 +1,63 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith + + +require 'libttc' +require 'rdoc/usage' + +def more_clockwise(this, other) + here = this.destination.place + there = other.destination.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves moves + +# The piece to move is the uncaptured one of mine with the lowest number +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort_by {|p| p.name})[0] + +# find the most clockwise move +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x, y} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/.svn/text-base/gen1006-clusters-old.txt.svn-base b/src/.svn/text-base/gen1006-clusters-old.txt.svn-base new file mode 100644 index 0000000..3f15863 --- /dev/null +++ b/src/.svn/text-base/gen1006-clusters-old.txt.svn-base @@ -0,0 +1,156 @@ +[[0,0,0,0,0,1,0,0,1,1,1,0,1,1,1,1,0,0,1,1], 16] +[[0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,1], 17] +[[0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1], 19] +[[0,0,0,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,0,1], 20] +[[0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1], 22] +[[0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,1,0], 27] +[[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,1,1,0], 31] +[[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,1], 43] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0], 65] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 140] +-- +[[0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,1,1], 19] +[[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0], 26] +[[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0], 29] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0], 29] +[[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,1,1,1,1], 29] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0], 29] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0], 45] +[[0,0,0,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,0,1], 48] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1], 65] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 81] +-- +[[0,1,0,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1], 10] +[[0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,1,1,0,1,0], 17] +[[0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0], 20] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1], 31] +[[0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,0], 34] +[[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 38] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1], 40] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0], 56] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1], 73] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0], 81] +-- +[[0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0], 17] +[[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,1,1,1], 23] +[[0,1,0,1,0,1,1,0,1,0,0,1,1,0,0,0,1,0,1,0], 26] +[[0,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0], 29] +[[0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0], 29] +[[0,0,0,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1,1,0], 35] +[[0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 49] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 51] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1], 67] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1], 74] +-- +[[0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,1,0,1,1], 12] +[[0,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1], 15] +[[0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1], 23] +[[0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1], 26] +[[0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 33] +[[0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0,0], 39] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 45] +[[0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1], 54] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,1,1], 58] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0], 95] +-- +[[0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1,1,0,1,1], 16] +[[0,1,0,1,0,1,0,0,0,0,1,1,1,0,1,0,0,0,1,1], 20] +[[0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0], 23] +[[0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1], 26] +[[0,0,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0], 39] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0], 46] +[[0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1], 48] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0], 49] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1], 64] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1], 69] +-- +[[1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,1], 8] +[[0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1], 16] +[[0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1], 22] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1], 27] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0], 29] +[[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0], 40] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,1,0], 48] +[[0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1], 51] +[[0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0], 58] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 101] +-- +[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1], 20] +[[0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0], 25] +[[0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 26] +[[0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0], 28] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1], 35] +[[0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0], 38] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 48] +[[0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,0], 55] +[[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 57] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1], 68] +-- +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 0] +[[0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1], 13] +[[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,0,1,0], 22] +[[0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,0,0], 26] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1], 33] +[[0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,1,0,0], 33] +[[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,1,1], 58] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 64] +[[0,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1], 75] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 76] +-- +[[0,0,1,0,0,0,1,0,1,0,0,0,0,1,1,1,1,1,1,1], 12] +[[0,0,0,0,1,0,1,0,1,0,1,0,0,1,1,1,1,0,1,1], 15] +[[0,0,0,1,1,0,0,1,0,1,1,1,1,0,0,1,0,0,1,1], 16] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 21] +[[0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0], 26] +[[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0], 27] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1], 47] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0], 55] +[[0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 61] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 120] +-- +[[0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,0,0,0], 11] +[[0,0,0,0,1,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0], 14] +[[0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,1,1,0,1,1], 21] +[[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1], 21] +[[0,0,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,1,0], 28] +[[0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1], 28] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 40] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 65] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,1,1], 84] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1], 88] +-- +[[0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0], 18] +[[0,0,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 21] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 28] +[[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1], 36] +[[0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1], 37] +[[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1], 39] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1], 42] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 54] +[[0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1], 56] +[[0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1,0], 69] +-- +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0], 10] +[[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1,1], 28] +[[0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 29] +[[0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1], 31] +[[0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,1,0,1,0], 31] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0], 36] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1], 36] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0], 42] +[[0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1,0], 58] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 99] +-- +[[0,0,0,0,0,1,0,0,1,1,1,0,1,1,1,1,0,0,1,1], 16] [[0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,1], 17] [[0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1], 19] [[0,0,0,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,0,1], 20] [[0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1], 22] [[0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,1,0], 27] [[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,1,1,0], 31] [[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,1], 43] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0], 65] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 140] +[[0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,1,1], 19] [[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0], 26] [[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0], 29] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0], 29] [[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,1,1,1,1], 29] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0], 29] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0], 45] [[0,0,0,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,0,1], 48] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1], 65] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 81] +[[0,1,0,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1], 10] [[0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,1,1,0,1,0], 17] [[0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0], 20] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1], 31] [[0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,0], 34] [[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 38] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1], 40] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0], 56] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1], 73] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0], 81] +[[0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0], 17] [[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,1,1,1], 23] [[0,1,0,1,0,1,1,0,1,0,0,1,1,0,0,0,1,0,1,0], 26] [[0,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0], 29] [[0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0], 29] [[0,0,0,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1,1,0], 35] [[0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 49] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 51] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1], 67] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1], 74] +[[0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,1,0,1,1], 12] [[0,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1], 15] [[0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1], 23] [[0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1], 26] [[0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 33] [[0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0,0], 39] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 45] [[0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1], 54] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,1,1], 58] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0], 95] +[[0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1,1,0,1,1], 16] [[0,1,0,1,0,1,0,0,0,0,1,1,1,0,1,0,0,0,1,1], 20] [[0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0], 23] [[0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1], 26] [[0,0,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0], 39] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0], 46] [[0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1], 48] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0], 49] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1], 64] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1], 69] +[[1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,1], 8] [[0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1], 16] [[0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1], 22] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1], 27] [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0], 29] [[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0], 40] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,1,0], 48] [[0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1], 51] [[0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0], 58] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 101] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1], 20] [[0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0], 25] [[0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 26] [[0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0], 28] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1], 35] [[0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0], 38] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 48] [[0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,0], 55] [[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 57] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1], 68] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 0] [[0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1], 13] [[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,0,1,0], 22] [[0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,0,0], 26] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1], 33] [[0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,1,0,0], 33] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,1,1], 58] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 64] [[0,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1], 75] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 76] +[[0,0,1,0,0,0,1,0,1,0,0,0,0,1,1,1,1,1,1,1], 12] [[0,0,0,0,1,0,1,0,1,0,1,0,0,1,1,1,1,0,1,1], 15] [[0,0,0,1,1,0,0,1,0,1,1,1,1,0,0,1,0,0,1,1], 16] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 21] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0], 26] [[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0], 27] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1], 47] [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0], 55] [[0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 61] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 120] +[[0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,0,0,0], 11] [[0,0,0,0,1,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0], 14] [[0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,1,1,0,1,1], 21] [[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1], 21] [[0,0,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,1,0], 28] [[0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1], 28] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 40] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 65] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,1,1], 84] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1], 88] +[[0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0], 18] [[0,0,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 21] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 28] [[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1], 36] [[0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1], 37] [[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1], 39] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1], 42] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 54] [[0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1], 56] [[0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1,0], 69] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0], 10] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1,1], 28] [[0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 29] [[0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1], 31] [[0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,1,0,1,0], 31] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0], 36] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1], 36] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0], 42] [[0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1,0], 58] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 99] diff --git a/src/.svn/text-base/gen1006-clusters.txt.svn-base b/src/.svn/text-base/gen1006-clusters.txt.svn-base new file mode 100644 index 0000000..60fe934 --- /dev/null +++ b/src/.svn/text-base/gen1006-clusters.txt.svn-base @@ -0,0 +1,13 @@ +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 140] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0], 65] [[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,1], 43] [[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,1,1,0], 31] [[0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,1,0], 27] [[0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1], 22] [[0,0,0,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,0,1], 20] [[0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1], 19] [[0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,1], 17] [[0,0,0,0,0,1,0,0,1,1,1,0,1,1,1,1,0,0,1,1], 16] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 81] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1], 65] [[0,0,0,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,0,1], 48] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0], 45] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0], 29] [[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,1,1,1,1], 29] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0], 29] [[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0], 29] [[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0], 26] [[0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,1,1], 19] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0], 81] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1], 73] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0], 56] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1], 40] [[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 38] [[0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,0], 34] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1], 31] [[0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0], 20] [[0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,1,1,0,1,0], 17] [[0,1,0,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1], 10] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1], 74] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1], 67] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 51] [[0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 49] [[0,0,0,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1,1,0], 35] [[0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0], 29] [[0,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0], 29] [[0,1,0,1,0,1,1,0,1,0,0,1,1,0,0,0,1,0,1,0], 26] [[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,1,1,1], 23] [[0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0], 17] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0], 95] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,1,1], 58] [[0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1], 54] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 45] [[0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0,0], 39] [[0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 33] [[0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1], 26] [[0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1], 23] [[0,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1], 15] [[0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,1,0,1,1], 12] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1], 69] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1], 64] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0], 49] [[0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1], 48] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0], 46] [[0,0,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0], 39] [[0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1], 26] [[0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0], 23] [[0,1,0,1,0,1,0,0,0,0,1,1,1,0,1,0,0,0,1,1], 20] [[0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1,1,0,1,1], 16] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 101] [[0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0], 58] [[0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1], 51] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,1,0], 48] [[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0], 40] [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0], 29] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1], 27] [[0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1], 22] [[0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1], 16] [[1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,1], 8] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1], 68] [[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 57] [[0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,0], 55] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 48] [[0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0], 38] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1], 35] [[0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0], 28] [[0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 26] [[0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0], 25] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1], 20] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 76] [[0,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1], 75] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 64] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,1,1], 58] [[0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,1,0,0], 33] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1], 33] [[0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,0,0], 26] [[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,0,1,0], 22] [[0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1], 13] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 0] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 120] [[0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 61] [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0], 55] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1], 47] [[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0], 27] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0], 26] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 21] [[0,0,0,1,1,0,0,1,0,1,1,1,1,0,0,1,0,0,1,1], 16] [[0,0,0,0,1,0,1,0,1,0,1,0,0,1,1,1,1,0,1,1], 15] [[0,0,1,0,0,0,1,0,1,0,0,0,0,1,1,1,1,1,1,1], 12] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1], 88] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,1,1], 84] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 65] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 40] [[0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1], 28] [[0,0,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,1,0], 28] [[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1], 21] [[0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,1,1,0,1,1], 21] [[0,0,0,0,1,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0], 14] [[0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,0,0,0], 11] +[[0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1,0], 69] [[0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1], 56] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 54] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1], 42] [[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1], 39] [[0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1], 37] [[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1], 36] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 28] [[0,0,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 21] [[0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0], 18] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 99] [[0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1,0], 58] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0], 42] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1], 36] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0], 36] [[0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,1,0,1,0], 31] [[0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1], 31] [[0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 29] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1,1], 28] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0], 10] diff --git a/src/.svn/text-base/gen1006.rb.svn-base b/src/.svn/text-base/gen1006.rb.svn-base new file mode 100644 index 0000000..2e49434 --- /dev/null +++ b/src/.svn/text-base/gen1006.rb.svn-base @@ -0,0 +1,35 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith + + +require 'libttc' +require 'libttc-pplayer' +require 'rdoc/usage' + + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves! moves + +player = Potential_player.new({:friend_pull => 0.0, + :enemy_pull => 0.0, + :base_pull => 0.0, + :safe_bonus => 10, + :capture_bonus => 2}) + +best_move = player.best_move(game, next_roll) + +# return that move +puts best_move diff --git a/src/.svn/text-base/libgenetics.rb.svn-base b/src/.svn/text-base/libgenetics.rb.svn-base new file mode 100644 index 0000000..3632440 --- /dev/null +++ b/src/.svn/text-base/libgenetics.rb.svn-base @@ -0,0 +1,176 @@ +# == Synopsis +# +# Library to support genetic algorithms +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +# A single genome in a population +class Genome + + attr_accessor :genome + + # Create a random genome of the given length + def initialize(bitstring_or_length) + if bitstring_or_length.class == Fixnum + @genome = [] + (1..bitstring_or_length).each do |i| + @genome << rand(2) + end + else + @genome = bitstring_or_length + end + end + + # Mutate a genome with the given rate per bit + def mutate(mutation_probability = 0.05) + new_genome = Genome.new(@genome.length) + (0...@genome.length).each do |i| + if rand < mutation_probability + if @genome[i] == 0 + new_genome.genome[i] = 1 + else + new_genome.genome[i] = 0 + end + else + new_genome.genome[i] = @genome[i] + end + end + new_genome + end + + # Mutate a genome in-place with the given rate per bit + def mutate!(mutation_probability = 0.05) + (0...@genome.length).each do |i| + if rand < mutation_probability + if @genome[i] == 0 + @genome[i] = 1 + else + @genome[i] = 0 + end + end + end + @genome + end + + # Crossover two genomes at the given point + def crossover(other_genome, crossover_point) + raise ArgumentError, "Different size genomes" if @genome.length != other_genome.genome.length + raise ArgumentError, "Our of bounds crossover point" if crossover_point < 0 or crossover_point > @genome.length + child1 = Genome.new(0) + child2 = Genome.new(0) + child1.genome = @genome[0, crossover_point] + other_genome.genome[crossover_point, @genome.length] + child2.genome = other_genome.genome[0, crossover_point] + @genome[crossover_point, @genome.length] + [child1, child2] + end + +end + + +class Array + def to_decimal + val = 0 + bits = self.dup + while not bits.empty? + val = val * 2 + bits[0] + bits = bits[1..bits.length] + end + val + end + + def gray_encode + gray = self[0..0] + (1...self.length).each do |i| + if (self[i - 1] == 1) ^ (self[i] == 1) + gray << 1 + else + gray << 0 + end + end + gray + end + + def gray_decode + binary = self[0..0] + (1...self.length).each do |i| + if (binary[i - 1] == 1) ^ (self[i] == 1) + binary << 1 + else + binary << 0 + end + end + binary + end + +end + +class Fixnum + def to_bitstring(min_length = 0) + bits = [] + k = self + while k > 0 do + if k % 2 == 1 + bits << 1 + else + bits << 0 + end + k = k >> 1 + end + while bits.length < min_length do + bits << 0 + end + bits.reverse + end +end + + +# A population of genomes +class Population + attr_accessor :individuals + + # Create a population of a given size + def initialize(population_size, genome_length = 0) + @individuals = [] + 1.upto(population_size) { @individuals << Genome.new(genome_length) } + end + + # Perform the crossover step in a population, giving a new population + def crossover(crossover_rate) + parents = @individuals.dup # genomes that haven't been parents yet + next_population = Population.new(0) + while parents.length > 1 + parent1 = parents.delete_at(rand(parents.length)).dup + parent2 = parents.delete_at(rand(parents.length)).dup + if rand < crossover_rate + child1, child2 = parent1.crossover parent2, rand(parent1.genome.length) + next_population.individuals << child1 << child2 + else + next_population.individuals << parent1 << parent2 + end + end + next_population.individuals.concat parents # pick up any parents that didn't get a chance to mate + next_population + end + + # Perform the mutation step in a population, giving a new population + def mutation(mutation_rate) + parents = @individuals.dup # genomes that haven't been parents yet + next_population = Population.new(0) + while parents.length > 0 + parent = parents.pop.dup + child = parent.mutate mutation_rate + next_population.individuals << child + end + next_population + end + + def make_next_generation(tournament_winner_success_rate = 0.8, game_length = 1000, crossover_rate = 0.7, mutation_rate = 0.05) + @individuals = tournament_select_population(tournament_winner_success_rate, game_length, false) + @individuals = crossover(crossover_rate) + @individuals = mutation(mutation_rate) + end + +end diff --git a/src/.svn/text-base/libttc-pplayer.rb.svn-base b/src/.svn/text-base/libttc-pplayer.rb.svn-base new file mode 100644 index 0000000..a848045 --- /dev/null +++ b/src/.svn/text-base/libttc-pplayer.rb.svn-base @@ -0,0 +1,74 @@ +# == Synopsis +# +# Library to support a Trap the Cap player that uses potentials to select the +# best move +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +require 'libttc' + +# Play Trap the Cap by using potential fields. For each possible move, +# calculate the field strength and pick the move with the lowest potential +class Potential_player + + attr_reader :friend_pull, :enemy_pull, :base_pull, + :safe_bonus, :capture_bonus + + def initialize(args, verbose = false) + @friend_pull = args[:friend_pull] || 1 + @enemy_pull = args[:enemy_pull] || 0.5 + @base_pull = args[:base_pull] || 2 + @safe_bonus = args[:safe_bonus] || 8 + @capture_bonus = args[:capture_bonus] || 10 + + @verbose = verbose + end + + # Find the best move of the possible ones + def best_move(game, die_result) + me = game.current_player + possible_moves = game.possible_moves(die_result, me) + scored_moves = possible_moves.collect do |m| + begin + game.apply_move! m + score = score_position(game, me) +# game.undo_move! + rescue GameWonNotice + score = 10000 + ensure + game.undo_move! + end + puts "#{m} scores #{score}" if @verbose + [m, score] + end + best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0] + end + + # Calculate the potential score of a position for a given player + def score_position(game, player) + score = 0 + game.pieces.each_value do |piece| + here = piece.position + if piece.colour == player + game.pieces.each_value do |other_piece| + if other_piece.colour == player + score += game.board.distance_between[here.place][other_piece.position.place] * @friend_pull + else + score += game.board.distance_between[here.place][other_piece.position.place] * @enemy_pull + end + end + score += piece.contains.length * @capture_bonus + score += game.board.distance_between[here.place][game.board.positions[player].place] * + piece.contains.length * @base_pull + elsif here == game.board.positions[player] + score += @safe_bonus + end + end + score + end + +end diff --git a/src/.svn/text-base/libttc.rb.svn-base b/src/.svn/text-base/libttc.rb.svn-base new file mode 100644 index 0000000..97845c7 --- /dev/null +++ b/src/.svn/text-base/libttc.rb.svn-base @@ -0,0 +1,615 @@ +# == Synopsis +# +# Library to support Trap the Cap play +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# == Change history +# Version 1.1:: 07 Sep 2007 +# * Changed format for showing moves via bases. +# * Raise error when moving via base without captured pieces +# * Raise error when moving onto a safe space with 3 or more +# pieces already there +# Version 1.2:: 10 Sep 2007 +# * Incorporated changes in move legality above into +# Game#possible_moves +# Version 1.3:: 25 Mar 2008 +# * Fixed bug to detect a winner, and also eliminate players +# that have no uncaptured pieces. + +# Errors for a game + +# Pieces can only capture pieces that they're on. +class InvalidCaptureError < StandardError +end + +# Moves can only be [1..6] spaces +class InvalidMoveError < StandardError +end + +# Game is won when only one player has uncaptured pieces +class GameWonNotice < StandardError +end + + +# Each possible position for a piece is an object +# Each neighbour is another position object +class Position + attr_reader :place # the name of this place + attr_accessor :contains # the pieces it contains + attr_accessor :neighbours # the positions that neighbour it + + def initialize(place, safety, base) + @place = place + @safe = safety + @base = base + @neighbours = Array.new + end + + # is this position a safety one (i.e. no captures allowed)? + def safe? + @safe + end + + # Is this position a base? + def base? + @base + end + + def to_s + @place + end + + def to_str + to_s + end + +end + + +# The game board +class Board + + attr_reader :positions + attr_reader :valid_moves + attr_reader :distance_between + attr_reader :centre + + + # A laborious procedure to create all the positions and tie them all together + def initialize(spokes, spoke_length, arc_length) + # A hash of all positions, indexed by position names + @positions = Hash.new + @centre = Position.new('ac' + spoke_length.to_s, false, false) + @positions['ac' + spoke_length.to_s] = centre + a1_corner = nil + end_of_previous_arc = nil + + # Do each arc-spoke-base set + (?a...(?a + spokes)).each do |arc_code| + arc = arc_code.chr + base = Position.new(arc, false, true) + this_arc = Array.new + + # build the arc + (1..arc_length).each do |arc_position| + position_name = arc + arc_position.to_s + arc_place = Position.new(position_name, arc_position == 4, false) + arc_place.neighbours = [] + @positions[position_name] = arc_place + this_arc << arc_place + a1_corner = a1_corner || arc_place + end + (0...arc_length).each do |arc_position| + if arc_position > 0 + this_arc[arc_position].neighbours << this_arc[arc_position - 1] + end + if arc_position < (arc_length - 1) + this_arc[arc_position].neighbours << this_arc[arc_position + 1] + end + end + + # build the spoke + this_spoke = Array.new + (1..(spoke_length - 1)).each do |spoke_position| + position_name = arc + "c" + spoke_position.to_s + spoke_place = Position.new(position_name, spoke_position == 3, false) + spoke_place.neighbours = [] + @positions[position_name] = spoke_place + this_spoke << spoke_place + end + (0...(spoke_length - 1)).each do |spoke_position| + if spoke_position > 0 + this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1] + end + if spoke_position < spoke_length - 2 + this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1] + end + end + + # tie the spoke and arc together, + this_arc[0].neighbours << this_spoke[0] + this_spoke[0].neighbours << this_arc[0] + + # tie the spoke to the centre, and + this_spoke[-1].neighbours << @centre + @centre.neighbours << this_spoke[-1] + + # tie the base to the arc + base = Position.new(arc, false, true) + @positions[arc] = base + base.neighbours << this_arc[0] + this_arc[0].neighbours << base + + # record the ends of the arc for tying to adjacent arcs + if end_of_previous_arc + end_of_previous_arc.neighbours << this_arc[0] + this_arc[0].neighbours << end_of_previous_arc + end + end_of_previous_arc = this_arc[-1] + + end # arc + + # tie both ends of the rim together + a1_corner.neighbours << end_of_previous_arc + end_of_previous_arc.neighbours << a1_corner + + cache_valid_moves + + end # def + + def to_s + layout + end + + def to_str + to_s + end + + + # For each position, show its name and what it touches + def layout + out_string = "" + @positions.keys.sort.each do |position| + out_string << sprintf("%s touches ", @positions[position]) + @positions[position].neighbours.each do |neighbour| + out_string << sprintf("%s, ", neighbour) + end + out_string << sprintf("\n") + end + out_string + end + + + # Precompute the valid moves for this board, and the distances between each + # pair of positions + def cache_valid_moves + # A hash of arrays. The has key is the name of a positions. The array + # element [i] stores the positions that are i spaces from here + @valid_moves = Hash.new + # A hash of hashes. Given two names, return the shortest distance between + # the two locations + @distance_between = Hash.new + @positions.each do |place, position| + @valid_moves[place] = Array.new + @distance_between[place] = Hash.new + @valid_moves[place][0] = [@positions[place]] + @distance_between[place][place] = 0 + # Find the shortest routes by Dijkstra's algorithm + agenda = [position] + closed_list = [position] + i = 1 + while not agenda.empty? + @valid_moves[place][i] = [] + new_agenda = [] + agenda.each do |pos| + valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) } + @valid_moves[place][i] += valid_extensions + valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i } + closed_list += valid_extensions + new_agenda += valid_extensions + end + agenda = new_agenda + i += 1 + end + end + end + +end + + +# Each piece on the board is an object +class Piece + attr_reader :colour + attr_accessor :position, :contains, :captured + + def initialize(number, position, colour) + @number = number + @position = position + @colour = colour + @captured = false + @contains = [] + end + + def name + @colour + @number.to_s + end + + def to_s + self.name + end + + def to_str + to_s + end + + def move_to(new_position) + @position = new_position + @contains.each {|c| c.move_to(new_position)} + end + + # Caputre another piece + def capture(other_piece) + if @position = other_piece.position + @contains << other_piece + @contains += other_piece.contains + other_piece.contains = [] + other_piece.captured = true + else + raise(InvalidCaptureError, + "Piece #{self.name} cannot capture #{other_piece.name}: different locations") + end + end + +end + + +# A move in a game +class Move + attr_reader :piece, :destination + + def initialize(piece, destination, via_base = false) + @piece = piece + @destination = destination + @via_base = via_base + end + + def via_base? + @via_base + end + + # Write a move to a string + # Note the inverse, String#to_move, is defined below + def to_s + if @via_base + if @destination.base? + @piece.to_s + " " + @destination.to_s + else + @piece.to_s + " " + piece.colour + " " + @destination.to_s + end + else + @piece.to_s + " " + @destination.to_s + end + end + + def to_str + to_s + end + +end + + + +# A class to record each of the states previously found in a game. +# Note that this is a deep copy of the pieces and what they've captured, so +# you'll need to convert back +class GameState + attr_accessor :move, :player, :pieces_after_move + + def initialize(move, player, pieces) + @move = move + @player = player + @pieces_after_move = Hash.new + pieces.each {|k, p| @pieces_after_move[k] = p.dup} + @pieces_after_move.each_value {|p| p.contains = []} + # and now to make the captured pieces point to the copies + pieces.each do |k, p| + p.contains.each do |captured_piece| + @pieces_after_move[k].capture(@pieces_after_move[captured_piece.name]) + end + end + end + + def ==(other) + @move.to_s == other.move.to_s and + @player == other.player and + @piece_after_move == other.pieces_after_move + end + +end + + +# A game of Trap the Cap. It keeps a history of all previous states. +class Game + + attr_reader :history + attr_reader :current_player, :players + attr_reader :board + attr_reader :pieces + + # Create a new game + def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, + pieces_each = 6) + @board = Board.new(spokes, spoke_length, arc_length) + @history = [] + @pieces = Hash.new + @players = case + when players == 2 ; ['a', 'd'] + when players == 3 ; ['a', 'c', 'e'] + when players == 4 ; ['a', 'b', 'd', 'e'] + when players == 5 ; ['a', 'b', 'c', 'd', 'e'] + when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f'] + end + @current_player = 'a' + @players.each do |player| + players_base = @board.positions[player] + (1..pieces_each).each do |count| + piece = Piece.new(count, players_base, player) + @pieces[player + count.to_s] = piece + end + end + end + + + # Apply a single move to a game. + def apply_move!(move, player = @current_player) + # Check the move is a valid one + raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name) + raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player + raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured + raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty? + if move.destination.safe? + if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3 + raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there") + end + end + if move.via_base? + moved_distance = board.distance_between[move.piece.position.place][player] + + board.distance_between[player][move.destination.place] + else + moved_distance = board.distance_between[move.piece.position.place][move.destination.place] + end + raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places (from #{move.piece.position} to #{move.destination})") if moved_distance < 1 or moved_distance > 6 + + # Apply this move + move.piece.move_to(move.destination) + + # Capture anything already there (unless it's a safe place or a base, + # or our own colour, or already captured) + unless move.destination.safe? or move.destination.base? + @pieces.each do |name, target_piece| + if target_piece.position == move.destination and + target_piece != move.piece and + not move.piece.contains.member?(target_piece) and + target_piece.colour != player and + not target_piece.captured + move.piece.capture(target_piece) + end + end + end + + # If the move was via our base, drop all captured pieces + if move.via_base? + capturers_base = board.positions[move.piece.colour] + move.piece.contains.each do |captured_piece| + captured_piece.move_to capturers_base + captured_piece.captured = false if captured_piece.colour == move.piece.colour + end + move.piece.contains = [] + end + + # Record the new stae + this_game_state = GameState.new(move, player, @pieces) + @history << this_game_state + + # Retain only players that have uncaptured pieces. + # If there's only one player with uncaptured pieces, declare a win. + potential_players = [] + @players.each do |p| + if (@pieces.values.select {|piece| piece.colour == p}).any? {|piece| not piece.captured} + potential_players << p + end + # potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured} + end + if potential_players.length <= 1 + raise(GameWonNotice, "Game won by #{potential_players[0]}") + end + @players = potential_players.sort + end + + # Undo a move + def undo_move! + if @history.length > 1 + # general case + state_to_restore = @history[-2] + @current_player = @history[-1].player + @pieces.each do |name, piece| + copy_piece = state_to_restore.pieces_after_move[name] + piece.position = copy_piece.position + piece.captured = copy_piece.captured + piece.contains = [] + copy_piece.contains.each do |p| +# piece.capture(@pieces[p.name]) + piece.contains << @pieces[p.name] + end + end + @history.pop + elsif @history.length == 1 + # reset to start + @current_player = 'a' + @pieces.each do |name, piece| + piece.position = @board.positions[piece.colour] + piece.captured = false + piece.contains = [] + end + @history.pop + end + end + + # Apply a list of moves in order + def apply_moves!(moves) + moves.each do |move| + if move.via_base? + moved_distance = board.distance_between[move.piece.position.place][@current_player] + + board.distance_between[@current_player][move.destination.place] + else + moved_distance = board.distance_between[move.piece.position.place][move.destination.place] + end + self.apply_move!(move, @current_player) + next_player! unless moved_distance == 6 + end + end + + + # Set the current player to be the next player + def next_player! + original_player = @current_player + begin + if @current_player == @players[-1] + @current_player = @players[0] + else + @current_player = @players[@players.index(@current_player) + 1] + end + end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player + @current_player + end + + + # Return an array of all possible moves from this state, given the die roll + # and the active player + def possible_moves(die_result, player = @current_player) + moves = [] + @pieces.each do |key, piece| + # only move current player's pieces, and only if they're not captured + if piece.colour == player and (not piece.captured) + (@board.valid_moves[piece.position.place][die_result]).each do |destination| + if destination.safe? + if (@pieces.find_all {|k, p| p.position == destination}).length < 3 + moves << Move.new(piece, destination, false) + end + else + moves << Move.new(piece, destination, false) unless destination.base? + end + end + # if we can move to our base (but not already on it), add moves via that... + if @board.distance_between[piece.position.place][player] <= die_result and + not piece.position.place == player and + not piece.contains.empty? + distance_after_base = die_result - @board.distance_between[piece.position.place][player] + (@board.valid_moves[player][distance_after_base]).each do |destination| + if destination.safe? + if (@pieces.find_all {|k, p| p.position == destination}).length < 3 + moves << Move.new(piece, destination, true) + end + else + moves << Move.new(piece, destination, true) + end + end + end + end + end + moves + end + + + def build_state_string + outstr = "Current player = #{@current_player}\n" + @pieces.keys.sort.each do |piece_name| + if @pieces[piece_name].captured + outstr << "Piece #{piece_name} captured, at #{@pieces[piece_name].position}\n" + else + outstr << "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}\n" + end + end + outstr + end + + # Show the state of the board + def show_state + puts build_state_string +# @pieces.keys.sort.each do |piece_name| +# if @pieces[piece_name].captured +# puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}" +# else +# puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}" +# end +# end + end + + def to_s + show_state + end + + def to_str + to_s + end + + + # Given a set of lines from an input file, turn them into a Game object and + # a set of Move objects. + # Note the multiple return values. + # Class method + def Game.read_game(gamelines) + gamelines.each {|l| l.chomp!} + game = Game.new(gamelines[0].to_i, 6, 6, 6, 6) + moves = [] + gamelines[1..-2].each {|m| moves << m.to_move(game)} + return game, moves, gamelines[-1].to_i + end + + +end + + +# Extension to String class to convert a move-description string into a Move object. +# This is the inverse of the Move#to_s method +class String + def to_move(game) + move_elements = self.downcase.split + piece_name = move_elements[0] + destination_name = move_elements[-1] + if destination_name.length > 2 and + destination_name[-2,2] == game.board.centre.place[-2,2] + destination_name = game.board.centre.place + end + raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name) + raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name) + # Deal with the synonyms for the centre position + via_base = (destination_name.length == 1 or move_elements.length > 2) + Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base) + end +end + + +# Read a game description file and convert it into a Game object and set of Move objects. +# Note that Game.read_game method returns multiple values, so this one does too. +class IO + def IO.read_game(filename) + gamelines = IO.readlines(filename) + return Game.read_game(gamelines) + end +end diff --git a/src/.svn/text-base/play.rb.netbeans-base b/src/.svn/text-base/play.rb.netbeans-base new file mode 100644 index 0000000..01b2f29 --- /dev/null +++ b/src/.svn/text-base/play.rb.netbeans-base @@ -0,0 +1,61 @@ +# == Synopsis +# +# Play a game of Trap the Cap. +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +require 'lib/libttc' +require 'lib/libpplayer' + +# Play a game to completion, given a set of player agents. +class GameHandler + + attr_reader :game + + # Create a game handler that uses a set of players + def initialize(players, limit = 5000, verbose = false, very_verbose = false) + @game = Game.new(players.length) + @verbose = verbose + @very_verbose = very_verbose + @limit = limit + + # Give each player a name + @named_players = Hash.new + (@game.players.zip players).each do |kv| + @named_players[kv[0]] = kv[1] + end + end + + # Play a game of Trap the Cap. If players make illegal moves, disqualify them and restart the game. + # Terminate the game if there's a winner, there's only one player left, + # or the game has gone on too long. + def play + while @game.history.length < @limit + roll = rand(6) + 1 + move_to_apply = @named_players[@game.current_player].best_move(@game, roll) + puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose + @game.apply_moves! [move_to_apply] + puts @game if @very_verbose + end + puts "Game terminated after #{@game.history.length} moves" if @verbose + [:draw, @limit] + rescue GameWonNotice => win_notification + winner = win_notification.message[-1,1] + puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose + [@named_players[winner], @game.history.length] + rescue InvalidCaptureError, InvalidMoveError + puts "Disqualifying player #{@game.current_player}" if @verbose + @named_players.delete @game.current_player + if @named_players.length > 1 + retry + else + puts "Game won by #{@named_players.keys[0]} by default" if @verbose + [@named_players[@named_players.keys[0]], 0] + end + end +end + \ No newline at end of file diff --git a/src/.svn/text-base/play.rb.svn-base b/src/.svn/text-base/play.rb.svn-base new file mode 100644 index 0000000..01b2f29 --- /dev/null +++ b/src/.svn/text-base/play.rb.svn-base @@ -0,0 +1,61 @@ +# == Synopsis +# +# Play a game of Trap the Cap. +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +require 'lib/libttc' +require 'lib/libpplayer' + +# Play a game to completion, given a set of player agents. +class GameHandler + + attr_reader :game + + # Create a game handler that uses a set of players + def initialize(players, limit = 5000, verbose = false, very_verbose = false) + @game = Game.new(players.length) + @verbose = verbose + @very_verbose = very_verbose + @limit = limit + + # Give each player a name + @named_players = Hash.new + (@game.players.zip players).each do |kv| + @named_players[kv[0]] = kv[1] + end + end + + # Play a game of Trap the Cap. If players make illegal moves, disqualify them and restart the game. + # Terminate the game if there's a winner, there's only one player left, + # or the game has gone on too long. + def play + while @game.history.length < @limit + roll = rand(6) + 1 + move_to_apply = @named_players[@game.current_player].best_move(@game, roll) + puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose + @game.apply_moves! [move_to_apply] + puts @game if @very_verbose + end + puts "Game terminated after #{@game.history.length} moves" if @verbose + [:draw, @limit] + rescue GameWonNotice => win_notification + winner = win_notification.message[-1,1] + puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose + [@named_players[winner], @game.history.length] + rescue InvalidCaptureError, InvalidMoveError + puts "Disqualifying player #{@game.current_player}" if @verbose + @named_players.delete @game.current_player + if @named_players.length > 1 + retry + else + puts "Game won by #{@named_players.keys[0]} by default" if @verbose + [@named_players[@named_players.keys[0]], 0] + end + end +end + \ No newline at end of file diff --git a/src/.svn/text-base/sample-game.txt.svn-base b/src/.svn/text-base/sample-game.txt.svn-base new file mode 100644 index 0000000..9cffeaf --- /dev/null +++ b/src/.svn/text-base/sample-game.txt.svn-base @@ -0,0 +1,8 @@ +3 +A1 AC2 +C4 B5 +E1 EC5 +E2 E3 +A1 EC5 +C4 B2 +4 \ No newline at end of file diff --git a/src/.svn/text-base/selection.rb.svn-base b/src/.svn/text-base/selection.rb.svn-base new file mode 100644 index 0000000..7422a7d --- /dev/null +++ b/src/.svn/text-base/selection.rb.svn-base @@ -0,0 +1,78 @@ +# == Synopsis +# +# Use a GA to breed a good potential player +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + + +require 'libttc' +require 'libpplayer' +require 'libgenetics' +require 'play' + +class Population + # Use tournament selection to pick an individual for the next generation + def tournament_select_one(winner_success_chance = 0.8, max_game_length= 1000, verbose = false) + player_count = rand(5) + 2 + pool_size = @individuals.length + players = [] + 1.upto(player_count) { players << @individuals[rand(pool_size)].to_potential_player } + game = GameHandler.new(players, max_game_length, false, false) + winner, length = game.play + puts "Winner = #{winner} in #{length} moves. Game had #{player_count} players" if verbose + # If the game was a draw, or the winner is unlucky, pick a parent at random + if winner == :draw or rand > winner_success_chance + successful_player = players[rand(player_count)] + else + successful_player = winner + end + successful_player + end + + # Select a new population the same size as the current population + def tournament_select_population(winner_success_chance = 0.8, max_game_length = 1000, verbose = false) + new_population = [] + 1.upto(@individuals.length) do + new_population << tournament_select_one(winner_success_chance, max_game_length, verbose).to_genome + puts "Created #{new_population.length} indivduals" if verbose + end + new_population + end + +end + +class Potential_player + # Convert a player to a bitstring + def to_bitstring + (@friend_pull * 4).to_i.to_bitstring(4).gray_encode + + (@enemy_pull * 4).to_i.to_bitstring(4).gray_encode + + (@base_pull * 4).to_i.to_bitstring(4).gray_encode + + @safe_bonus.to_bitstring(4).gray_encode + + @capture_bonus.to_bitstring(4).gray_encode + end + + # Convert a player to a genome + def to_genome + Genome.new(self.to_bitstring) + end +end + + +class Genome + + # Create a potential player from a genome + def to_potential_player + friend_pull = @genome[0, 4].gray_decode.to_decimal.to_f / 4 + enemy_pull = @genome[4, 4].gray_decode.to_decimal.to_f / 4 + base_pull = @genome[8, 4].gray_decode.to_decimal.to_f / 4 + safe_bonus = @genome[12, 4].gray_decode.to_decimal + capture_bonus = @genome[16, 4].gray_decode.to_decimal + Potential_player.new({:friend_pull => friend_pull, + :enemy_pull => enemy_pull, :base_pull => base_pull, + :safe_bonus => safe_bonus, :capture_bonus => capture_bonus}) + end +end diff --git a/src/.svn/text-base/ttc-ga-clustering.rb.svn-base b/src/.svn/text-base/ttc-ga-clustering.rb.svn-base new file mode 100644 index 0000000..6396d06 --- /dev/null +++ b/src/.svn/text-base/ttc-ga-clustering.rb.svn-base @@ -0,0 +1,27 @@ +require '/home/neil/programming/ruby/programming-collective/intelligence/k-means-clustering' + +def read_genome_file(filename) + genomes = [] + IO.foreach(filename) { |line| genomes << line.chomp.split('').collect {|i| i.to_i} } + genomes +end + +def find_centroid_sets(rows, k = 10, n = 10) + centroid_set = [] + 1.upto(n) do + centroid_set << (k_means_cluster(rows, k, :domain => :discrete) {|x, y| hamming_distance x, y}) + end + centroid_set +end + +def order_centroids_by_cluster_size(centroids, rows) + clusters = clusters_of_centroids(centroids, rows) {|x, y| hamming_distance x, y} + cluster_sizes = clusters.collect {|c| c.length} + sized_centroids = centroid.zip(cluster_sizes) + sorted_sized_centroids = (sized_centroids.sort_by {|t| t[1]}).reverse +end + +def best_centroids(centroid_set) + centroid_set.collect {|tc| tc[0][0]} +end + \ No newline at end of file diff --git a/src/.svn/text-base/ttc.rb.svn-base b/src/.svn/text-base/ttc.rb.svn-base new file mode 100644 index 0000000..9526d54 --- /dev/null +++ b/src/.svn/text-base/ttc.rb.svn-base @@ -0,0 +1,36 @@ +#!/usr/bin/ruby -w +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# ttc [ -b | --board-size SIZE ] [ -i | --input FILE ] [ -r | --robot ROBOT ] [ -h | --help ] +# +# == Author +# Neil Smith + +require File.join(File.dirname(__FILE__), '..', 'lib', 'libttc') +require 'open3' +require 'timeout' +require 'optparse' +require 'rdoc/usage' + + +class InvalidRobotError < StandardError +end + +class NoInputFileError < StandardError +end + +class InvalidMoveInHistoryError < StandardError +end + +class GameWonInHistoryError < StandardError +end + + + +board = Board.new(6, 5, 6) +puts board + diff --git a/src/cgi-files/.svn/all-wcprops b/src/cgi-files/.svn/all-wcprops new file mode 100644 index 0000000..6ce5f64 --- /dev/null +++ b/src/cgi-files/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 52 +/svn/njae/!svn/ver/65/TrapTheCap/trunk/src/cgi-files +END +ttc-simple.rb +K 25 +svn:wc:ra_dav:version-url +V 66 +/svn/njae/!svn/ver/71/TrapTheCap/trunk/src/cgi-files/ttc-simple.rb +END diff --git a/src/cgi-files/.svn/entries b/src/cgi-files/.svn/entries new file mode 100644 index 0000000..7287613 --- /dev/null +++ b/src/cgi-files/.svn/entries @@ -0,0 +1,41 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/src/cgi-files +http://scripts.njae.me.uk/svn/njae + + + +2009-01-30T14:59:52.075953Z +65 + + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +ttc-simple.rb +file +71 + + + +2009-02-23T14:20:37.000000Z +ba2f5d4e3bfffbcc1393e87df9638fcd +2009-02-23T14:20:51.158868Z +71 + +has-props + diff --git a/src/cgi-files/.svn/format b/src/cgi-files/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/src/cgi-files/.svn/format @@ -0,0 +1 @@ +8 diff --git a/src/cgi-files/.svn/prop-base/ttc-simple.rb.svn-base b/src/cgi-files/.svn/prop-base/ttc-simple.rb.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/cgi-files/.svn/prop-base/ttc-simple.rb.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/cgi-files/.svn/text-base/ttc-simple.rb.svn-base b/src/cgi-files/.svn/text-base/ttc-simple.rb.svn-base new file mode 100644 index 0000000..903754b --- /dev/null +++ b/src/cgi-files/.svn/text-base/ttc-simple.rb.svn-base @@ -0,0 +1,151 @@ +#!/usr/bin/ruby -w +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# ttc [ -b | --board-size SIZE ] [ -i | --input FILE ] [ -r | --robot ROBOT ] [ -h | --help ] +# +# == Author +# Neil Smith + +require 'libttc' +require 'cgi' +require 'open3' +require 'timeout' + +# Prevent dangerous operations +$SAFE = 1 + +class InvalidRobotError < StandardError +end + +class NoInputFileError < StandardError +end + +class InvalidMoveInHistoryError < StandardError +end + +class GameWonInHistoryError < StandardError +end + + +# A table of the known game-playing robots + +$ROBOT_NAME_TABLE = { + 'Always clockwise simple' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/1', + 'Clockwise cloud' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/2', + 'GA generation 1006' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/3' +} + +$ROBOT_CODE_TABLE = { + '1' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/1', + '2' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/2', + '3' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/3' +} + + +# How long the robot has to respond +$ROBOT_TIMEOUT = 10 + + +def generate_output(cgi, returned_move, annotation) + if returned_move.empty? + return_part = "" + else + return_part = cgi.p { "Result is: " } + "\n" + cgi.h1 { returned_move } + "\n" + end + + if annotation.empty? + annotation_part = "" + else + annotation_part = cgi.p { annotation } + end + + cgi.html { + cgi.head { "\n" + cgi.title{"Move result"} } + "\n" + + cgi.body { return_part + annotation_part } + } +end + + +begin + + cgi = CGI.new("html4") + + chosen_robot = cgi['robot'] + if $ROBOT_NAME_TABLE.has_key? chosen_robot + chosen_robot_dir = $ROBOT_NAME_TABLE[chosen_robot] + chosen_robot_dir.untaint + else + raise InvalidRobotError, "#{chosen_robot} is not a valid robot code" + end + + begin + game, moves, next_roll = Game.read_game(cgi['moves'].downcase.split("\n")) + game.apply_moves! moves + rescue InvalidMoveError => error + raise(InvalidMoveInHistoryError, error.message) + rescue GameWonNotice => error + raise(GameWonInHistoryError, error.message) + end + + current_directory = Dir.pwd + current_directory.untaint + Dir.chdir chosen_robot_dir + + returned_move = "" + returned_error = "" + robot_input = game.players.length.to_s + "\n" + robot_input += (moves.collect {|m| m.to_s}).join("\n") + "\n" if not moves.empty? + robot_input += next_roll.to_s + +# cgi.out { generate_output(cgi, "", "passing robot #{game.players.length.to_s + "#" + (moves.collect {|m| m.to_s}).join('!\n!') + "#" + next_roll.to_s}!") } +# cgi.out { generate_output(cgi, "", "passing robot #{robot_input}!") } + + + Timeout.timeout($ROBOT_TIMEOUT + 1) do + Open3.popen3('./runme') do |robot_in, robot_out, robot_err| + robot_in << robot_input + robot_in.close_write + returned_move = robot_out.gets + returned_error = robot_err.gets + end + end + + Dir.chdir current_directory + +# cgi.out { generate_output(cgi, "", "Returned move #{returned_move}; robot error was #{returned_error}!") } + + raise(InvalidMoveError, "Robot returned error '#{returned_error}'") if returned_error != nil + raise(InvalidMoveError, "Null move") if returned_move.nil? or returned_move.empty? + next_move = returned_move.chomp.to_move(game) + game.apply_move! next_move + +# cgi.out { generate_output(cgi, "", "Applied move #{returned_move}!") } + cgi.out { generate_output(cgi, returned_move, "") } + +rescue InvalidMoveInHistoryError => error + cgi.out { generate_output(cgi, "", "Invalid move in history: #{error}") } +# puts "Invalid move in history: #{error}" +rescue GameWonInHistoryError => error + cgi.out { generate_output(cgi, "", "Game already won in historic moves: #{error}") } +# puts "Game already won in historic moves: #{error}" + +rescue InvalidMoveError => error + cgi.out { generate_output(cgi, "", "Robot returned invalid move: #{error}") } +# puts "Robot returned invalid move: #{error}" +rescue GameWonNotice => error + cgi.out { generate_output(cgi, returned_move, "Game won: #{error}") } +# puts "Robot returned #{returned_move}" +# puts "Game won: #{error}" + +rescue InvalidRobotError => error + cgi.out { generate_output(cgi, "", "Invalid robot selection: #{error}") } +# puts "Invalid robot selection: #{error}" +rescue Timeout::Error => error + cgi.out { generate_output(cgi, "", "Robot timed out") } +# puts "Robot timeout: #{error}" + +end diff --git a/src/cgi-files/ttc-simple.rb b/src/cgi-files/ttc-simple.rb new file mode 100755 index 0000000..903754b --- /dev/null +++ b/src/cgi-files/ttc-simple.rb @@ -0,0 +1,151 @@ +#!/usr/bin/ruby -w +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# ttc [ -b | --board-size SIZE ] [ -i | --input FILE ] [ -r | --robot ROBOT ] [ -h | --help ] +# +# == Author +# Neil Smith + +require 'libttc' +require 'cgi' +require 'open3' +require 'timeout' + +# Prevent dangerous operations +$SAFE = 1 + +class InvalidRobotError < StandardError +end + +class NoInputFileError < StandardError +end + +class InvalidMoveInHistoryError < StandardError +end + +class GameWonInHistoryError < StandardError +end + + +# A table of the known game-playing robots + +$ROBOT_NAME_TABLE = { + 'Always clockwise simple' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/1', + 'Clockwise cloud' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/2', + 'GA generation 1006' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/3' +} + +$ROBOT_CODE_TABLE = { + '1' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/1', + '2' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/2', + '3' => '/var/www/scripts.njae.me.uk/trap-the-cap/robots/3' +} + + +# How long the robot has to respond +$ROBOT_TIMEOUT = 10 + + +def generate_output(cgi, returned_move, annotation) + if returned_move.empty? + return_part = "" + else + return_part = cgi.p { "Result is: " } + "\n" + cgi.h1 { returned_move } + "\n" + end + + if annotation.empty? + annotation_part = "" + else + annotation_part = cgi.p { annotation } + end + + cgi.html { + cgi.head { "\n" + cgi.title{"Move result"} } + "\n" + + cgi.body { return_part + annotation_part } + } +end + + +begin + + cgi = CGI.new("html4") + + chosen_robot = cgi['robot'] + if $ROBOT_NAME_TABLE.has_key? chosen_robot + chosen_robot_dir = $ROBOT_NAME_TABLE[chosen_robot] + chosen_robot_dir.untaint + else + raise InvalidRobotError, "#{chosen_robot} is not a valid robot code" + end + + begin + game, moves, next_roll = Game.read_game(cgi['moves'].downcase.split("\n")) + game.apply_moves! moves + rescue InvalidMoveError => error + raise(InvalidMoveInHistoryError, error.message) + rescue GameWonNotice => error + raise(GameWonInHistoryError, error.message) + end + + current_directory = Dir.pwd + current_directory.untaint + Dir.chdir chosen_robot_dir + + returned_move = "" + returned_error = "" + robot_input = game.players.length.to_s + "\n" + robot_input += (moves.collect {|m| m.to_s}).join("\n") + "\n" if not moves.empty? + robot_input += next_roll.to_s + +# cgi.out { generate_output(cgi, "", "passing robot #{game.players.length.to_s + "#" + (moves.collect {|m| m.to_s}).join('!\n!') + "#" + next_roll.to_s}!") } +# cgi.out { generate_output(cgi, "", "passing robot #{robot_input}!") } + + + Timeout.timeout($ROBOT_TIMEOUT + 1) do + Open3.popen3('./runme') do |robot_in, robot_out, robot_err| + robot_in << robot_input + robot_in.close_write + returned_move = robot_out.gets + returned_error = robot_err.gets + end + end + + Dir.chdir current_directory + +# cgi.out { generate_output(cgi, "", "Returned move #{returned_move}; robot error was #{returned_error}!") } + + raise(InvalidMoveError, "Robot returned error '#{returned_error}'") if returned_error != nil + raise(InvalidMoveError, "Null move") if returned_move.nil? or returned_move.empty? + next_move = returned_move.chomp.to_move(game) + game.apply_move! next_move + +# cgi.out { generate_output(cgi, "", "Applied move #{returned_move}!") } + cgi.out { generate_output(cgi, returned_move, "") } + +rescue InvalidMoveInHistoryError => error + cgi.out { generate_output(cgi, "", "Invalid move in history: #{error}") } +# puts "Invalid move in history: #{error}" +rescue GameWonInHistoryError => error + cgi.out { generate_output(cgi, "", "Game already won in historic moves: #{error}") } +# puts "Game already won in historic moves: #{error}" + +rescue InvalidMoveError => error + cgi.out { generate_output(cgi, "", "Robot returned invalid move: #{error}") } +# puts "Robot returned invalid move: #{error}" +rescue GameWonNotice => error + cgi.out { generate_output(cgi, returned_move, "Game won: #{error}") } +# puts "Robot returned #{returned_move}" +# puts "Game won: #{error}" + +rescue InvalidRobotError => error + cgi.out { generate_output(cgi, "", "Invalid robot selection: #{error}") } +# puts "Invalid robot selection: #{error}" +rescue Timeout::Error => error + cgi.out { generate_output(cgi, "", "Robot timed out") } +# puts "Robot timeout: #{error}" + +end diff --git a/src/clockwise-cloud.rb b/src/clockwise-cloud.rb new file mode 100644 index 0000000..3df362f --- /dev/null +++ b/src/clockwise-cloud.rb @@ -0,0 +1,77 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +require 'libttc' + +def more_clockwise(this, other) + here = this.place + there = other.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves moves + + +# The piece to move is the least clockwise of my uncaptured pieces +# Always move pieces on the base first +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort {|x, y| more_clockwise x.position, y.position})[0] + +# Find the most clockwise move for this piece +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x.destination, y.destination} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/clockwise-p1.rb b/src/clockwise-p1.rb new file mode 100644 index 0000000..fd8e726 --- /dev/null +++ b/src/clockwise-p1.rb @@ -0,0 +1,63 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith + + +require 'libttc' +require 'rdoc/usage' + +def more_clockwise(this, other) + here = this.destination.place + there = other.destination.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves moves + +# The piece to move is the uncaptured one of mine with the lowest number +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort_by {|p| p.name})[0] + +# find the most clockwise move +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x, y} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/gen1006-clusters-old.txt b/src/gen1006-clusters-old.txt new file mode 100644 index 0000000..3f15863 --- /dev/null +++ b/src/gen1006-clusters-old.txt @@ -0,0 +1,156 @@ +[[0,0,0,0,0,1,0,0,1,1,1,0,1,1,1,1,0,0,1,1], 16] +[[0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,1], 17] +[[0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1], 19] +[[0,0,0,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,0,1], 20] +[[0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1], 22] +[[0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,1,0], 27] +[[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,1,1,0], 31] +[[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,1], 43] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0], 65] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 140] +-- +[[0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,1,1], 19] +[[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0], 26] +[[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0], 29] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0], 29] +[[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,1,1,1,1], 29] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0], 29] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0], 45] +[[0,0,0,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,0,1], 48] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1], 65] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 81] +-- +[[0,1,0,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1], 10] +[[0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,1,1,0,1,0], 17] +[[0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0], 20] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1], 31] +[[0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,0], 34] +[[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 38] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1], 40] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0], 56] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1], 73] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0], 81] +-- +[[0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0], 17] +[[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,1,1,1], 23] +[[0,1,0,1,0,1,1,0,1,0,0,1,1,0,0,0,1,0,1,0], 26] +[[0,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0], 29] +[[0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0], 29] +[[0,0,0,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1,1,0], 35] +[[0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 49] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 51] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1], 67] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1], 74] +-- +[[0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,1,0,1,1], 12] +[[0,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1], 15] +[[0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1], 23] +[[0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1], 26] +[[0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 33] +[[0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0,0], 39] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 45] +[[0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1], 54] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,1,1], 58] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0], 95] +-- +[[0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1,1,0,1,1], 16] +[[0,1,0,1,0,1,0,0,0,0,1,1,1,0,1,0,0,0,1,1], 20] +[[0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0], 23] +[[0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1], 26] +[[0,0,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0], 39] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0], 46] +[[0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1], 48] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0], 49] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1], 64] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1], 69] +-- +[[1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,1], 8] +[[0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1], 16] +[[0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1], 22] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1], 27] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0], 29] +[[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0], 40] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,1,0], 48] +[[0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1], 51] +[[0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0], 58] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 101] +-- +[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1], 20] +[[0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0], 25] +[[0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 26] +[[0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0], 28] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1], 35] +[[0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0], 38] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 48] +[[0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,0], 55] +[[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 57] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1], 68] +-- +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 0] +[[0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1], 13] +[[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,0,1,0], 22] +[[0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,0,0], 26] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1], 33] +[[0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,1,0,0], 33] +[[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,1,1], 58] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 64] +[[0,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1], 75] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 76] +-- +[[0,0,1,0,0,0,1,0,1,0,0,0,0,1,1,1,1,1,1,1], 12] +[[0,0,0,0,1,0,1,0,1,0,1,0,0,1,1,1,1,0,1,1], 15] +[[0,0,0,1,1,0,0,1,0,1,1,1,1,0,0,1,0,0,1,1], 16] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 21] +[[0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0], 26] +[[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0], 27] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1], 47] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0], 55] +[[0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 61] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 120] +-- +[[0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,0,0,0], 11] +[[0,0,0,0,1,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0], 14] +[[0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,1,1,0,1,1], 21] +[[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1], 21] +[[0,0,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,1,0], 28] +[[0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1], 28] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 40] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 65] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,1,1], 84] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1], 88] +-- +[[0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0], 18] +[[0,0,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 21] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 28] +[[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1], 36] +[[0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1], 37] +[[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1], 39] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1], 42] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 54] +[[0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1], 56] +[[0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1,0], 69] +-- +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0], 10] +[[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1,1], 28] +[[0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 29] +[[0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1], 31] +[[0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,1,0,1,0], 31] +[[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0], 36] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1], 36] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0], 42] +[[0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1,0], 58] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 99] +-- +[[0,0,0,0,0,1,0,0,1,1,1,0,1,1,1,1,0,0,1,1], 16] [[0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,1], 17] [[0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1], 19] [[0,0,0,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,0,1], 20] [[0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1], 22] [[0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,1,0], 27] [[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,1,1,0], 31] [[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,1], 43] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0], 65] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 140] +[[0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,1,1], 19] [[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0], 26] [[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0], 29] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0], 29] [[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,1,1,1,1], 29] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0], 29] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0], 45] [[0,0,0,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,0,1], 48] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1], 65] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 81] +[[0,1,0,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1], 10] [[0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,1,1,0,1,0], 17] [[0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0], 20] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1], 31] [[0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,0], 34] [[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 38] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1], 40] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0], 56] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1], 73] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0], 81] +[[0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0], 17] [[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,1,1,1], 23] [[0,1,0,1,0,1,1,0,1,0,0,1,1,0,0,0,1,0,1,0], 26] [[0,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0], 29] [[0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0], 29] [[0,0,0,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1,1,0], 35] [[0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 49] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 51] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1], 67] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1], 74] +[[0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,1,0,1,1], 12] [[0,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1], 15] [[0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1], 23] [[0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1], 26] [[0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 33] [[0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0,0], 39] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 45] [[0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1], 54] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,1,1], 58] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0], 95] +[[0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1,1,0,1,1], 16] [[0,1,0,1,0,1,0,0,0,0,1,1,1,0,1,0,0,0,1,1], 20] [[0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0], 23] [[0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1], 26] [[0,0,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0], 39] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0], 46] [[0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1], 48] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0], 49] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1], 64] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1], 69] +[[1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,1], 8] [[0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1], 16] [[0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1], 22] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1], 27] [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0], 29] [[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0], 40] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,1,0], 48] [[0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1], 51] [[0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0], 58] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 101] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1], 20] [[0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0], 25] [[0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 26] [[0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0], 28] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1], 35] [[0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0], 38] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 48] [[0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,0], 55] [[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 57] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1], 68] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 0] [[0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1], 13] [[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,0,1,0], 22] [[0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,0,0], 26] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1], 33] [[0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,1,0,0], 33] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,1,1], 58] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 64] [[0,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1], 75] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 76] +[[0,0,1,0,0,0,1,0,1,0,0,0,0,1,1,1,1,1,1,1], 12] [[0,0,0,0,1,0,1,0,1,0,1,0,0,1,1,1,1,0,1,1], 15] [[0,0,0,1,1,0,0,1,0,1,1,1,1,0,0,1,0,0,1,1], 16] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 21] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0], 26] [[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0], 27] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1], 47] [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0], 55] [[0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 61] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 120] +[[0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,0,0,0], 11] [[0,0,0,0,1,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0], 14] [[0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,1,1,0,1,1], 21] [[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1], 21] [[0,0,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,1,0], 28] [[0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1], 28] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 40] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 65] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,1,1], 84] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1], 88] +[[0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0], 18] [[0,0,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 21] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 28] [[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1], 36] [[0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1], 37] [[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1], 39] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1], 42] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 54] [[0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1], 56] [[0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1,0], 69] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0], 10] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1,1], 28] [[0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 29] [[0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1], 31] [[0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,1,0,1,0], 31] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0], 36] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1], 36] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0], 42] [[0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1,0], 58] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 99] diff --git a/src/gen1006-clusters.txt b/src/gen1006-clusters.txt new file mode 100644 index 0000000..60fe934 --- /dev/null +++ b/src/gen1006-clusters.txt @@ -0,0 +1,13 @@ +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 140] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0], 65] [[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,1], 43] [[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,1,1,0], 31] [[0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,1,0], 27] [[0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1], 22] [[0,0,0,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,0,1], 20] [[0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1], 19] [[0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,1], 17] [[0,0,0,0,0,1,0,0,1,1,1,0,1,1,1,1,0,0,1,1], 16] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 81] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1], 65] [[0,0,0,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,0,1], 48] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0], 45] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0], 29] [[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,1,1,1,1], 29] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0], 29] [[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0], 29] [[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0], 26] [[0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,1,1], 19] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0], 81] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1], 73] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0], 56] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1], 40] [[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 38] [[0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,0], 34] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1], 31] [[0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0], 20] [[0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,1,1,0,1,0], 17] [[0,1,0,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1], 10] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1], 74] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1], 67] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 51] [[0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 49] [[0,0,0,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1,1,0], 35] [[0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0], 29] [[0,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0], 29] [[0,1,0,1,0,1,1,0,1,0,0,1,1,0,0,0,1,0,1,0], 26] [[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,1,1,1], 23] [[0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0], 17] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0], 95] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,1,1], 58] [[0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1], 54] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 45] [[0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0,0], 39] [[0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 33] [[0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1], 26] [[0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1], 23] [[0,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1], 15] [[0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,1,0,1,1], 12] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1], 69] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1], 64] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0], 49] [[0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1], 48] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0], 46] [[0,0,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0], 39] [[0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1], 26] [[0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0], 23] [[0,1,0,1,0,1,0,0,0,0,1,1,1,0,1,0,0,0,1,1], 20] [[0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1,1,0,1,1], 16] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0], 101] [[0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0], 58] [[0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1], 51] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,1,0], 48] [[0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0], 40] [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0], 29] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1], 27] [[0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1], 22] [[0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1], 16] [[1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,1], 8] +[[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1], 68] [[0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1], 57] [[0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,0], 55] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 48] [[0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,0], 38] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1], 35] [[0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0], 28] [[0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 26] [[0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0], 25] [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1], 20] +[[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 76] [[0,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1], 75] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 64] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,1,1], 58] [[0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,1,0,0], 33] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1], 33] [[0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,0,0], 26] [[0,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,0,1,0], 22] [[0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1], 13] [[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0], 0] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1], 120] [[0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 61] [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0], 55] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1], 47] [[0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,0], 27] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0], 26] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 21] [[0,0,0,1,1,0,0,1,0,1,1,1,1,0,0,1,0,0,1,1], 16] [[0,0,0,0,1,0,1,0,1,0,1,0,0,1,1,1,1,0,1,1], 15] [[0,0,1,0,0,0,1,0,1,0,0,0,0,1,1,1,1,1,1,1], 12] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1], 88] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,1,1], 84] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0], 65] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0], 40] [[0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1], 28] [[0,0,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,1,0], 28] [[0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1], 21] [[0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,1,1,0,1,1], 21] [[0,0,0,0,1,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0], 14] [[0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,0,0,0], 11] +[[0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,1,0], 69] [[0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1], 56] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0], 54] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1], 42] [[0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1], 39] [[0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1], 37] [[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1], 36] [[0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0], 28] [[0,0,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0], 21] [[0,0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0], 18] +[[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1], 99] [[0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1,0], 58] [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0], 42] [[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1], 36] [[0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0], 36] [[0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,1,0,1,0], 31] [[0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1], 31] [[0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,1,1,0], 29] [[0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,1,1], 28] [[0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0], 10] diff --git a/src/gen1006.rb b/src/gen1006.rb new file mode 100755 index 0000000..2e49434 --- /dev/null +++ b/src/gen1006.rb @@ -0,0 +1,35 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith + + +require 'libttc' +require 'libttc-pplayer' +require 'rdoc/usage' + + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves! moves + +player = Potential_player.new({:friend_pull => 0.0, + :enemy_pull => 0.0, + :base_pull => 0.0, + :safe_bonus => 10, + :capture_bonus => 2}) + +best_move = player.best_move(game, next_roll) + +# return that move +puts best_move diff --git a/src/html-files/.svn/all-wcprops b/src/html-files/.svn/all-wcprops new file mode 100644 index 0000000..660e5fd --- /dev/null +++ b/src/html-files/.svn/all-wcprops @@ -0,0 +1,59 @@ +K 25 +svn:wc:ra_dav:version-url +V 53 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files +END +layout.html +K 25 +svn:wc:ra_dav:version-url +V 65 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/layout.html +END +board-thumb.jpg +K 25 +svn:wc:ra_dav:version-url +V 69 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/board-thumb.jpg +END +interface.html +K 25 +svn:wc:ra_dav:version-url +V 68 +/svn/njae/!svn/ver/70/TrapTheCap/trunk/src/html-files/interface.html +END +schematic-board-thumb.png +K 25 +svn:wc:ra_dav:version-url +V 79 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/schematic-board-thumb.png +END +board.jpg +K 25 +svn:wc:ra_dav:version-url +V 63 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/board.jpg +END +schematic-board.png +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/schematic-board.png +END +index.html +K 25 +svn:wc:ra_dav:version-url +V 64 +/svn/njae/!svn/ver/70/TrapTheCap/trunk/src/html-files/index.html +END +simple.html +K 25 +svn:wc:ra_dav:version-url +V 65 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/html-files/simple.html +END +trap-the-cap.pdf +K 25 +svn:wc:ra_dav:version-url +V 70 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/trap-the-cap.pdf +END diff --git a/src/html-files/.svn/entries b/src/html-files/.svn/entries new file mode 100644 index 0000000..a909c3b --- /dev/null +++ b/src/html-files/.svn/entries @@ -0,0 +1,128 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/src/html-files +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +layout.html +file + + + + +2007-05-14T21:17:46.000000Z +2f4d0c3ae6d9e99aeb5023c4a1d06463 +2008-10-16T14:11:23.436422Z +41 + +interface.html +file +70 + + + +2009-02-23T14:08:48.000000Z +cb3ca592cfbf181798dd5374fb31c5df +2009-02-23T14:09:06.882172Z +70 + +board-thumb.jpg +file + + + + +2007-05-14T21:17:46.000000Z +11bf63c82d0d8b62e42e1868a3247cff +2008-10-16T14:11:23.436422Z +41 + +has-props + +schematic-board-thumb.png +file + + + + +2007-05-14T21:17:46.000000Z +faa2c4f54dcd474c027faec304b91548 +2008-10-16T14:11:23.436422Z +41 + +has-props + +board.jpg +file + + + + +2007-05-14T21:17:46.000000Z +b52bed753ac7272a364b4569d235b219 +2008-10-16T14:11:23.436422Z +41 + +has-props + +robots +dir + +schematic-board.png +file + + + + +2007-05-14T21:17:46.000000Z +7369d4c42a02fc535e19bd68d0d2e209 +2008-10-16T14:11:23.436422Z +41 + +has-props + +index.html +file +70 + + + +2009-02-23T14:08:12.000000Z +3be6c076657c7510db235ab857136314 +2009-02-23T14:09:06.882172Z +70 + +simple.html +file +69 + + + +2009-02-23T13:55:00.000000Z +f9a24e4eadb298e29094a60ebbb20f4c +2009-02-23T14:02:44.812274Z +69 + +trap-the-cap.pdf +file + + + + +2007-05-14T21:17:46.000000Z +9b7e0b7381e7e7e0894f105690345a7c +2008-10-16T14:11:23.436422Z +41 + +has-props + diff --git a/src/html-files/.svn/format b/src/html-files/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/src/html-files/.svn/format @@ -0,0 +1 @@ +8 diff --git a/src/html-files/.svn/prop-base/board-thumb.jpg.svn-base b/src/html-files/.svn/prop-base/board-thumb.jpg.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/html-files/.svn/prop-base/board-thumb.jpg.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/html-files/.svn/prop-base/board.jpg.svn-base b/src/html-files/.svn/prop-base/board.jpg.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/html-files/.svn/prop-base/board.jpg.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/html-files/.svn/prop-base/schematic-board-thumb.png.svn-base b/src/html-files/.svn/prop-base/schematic-board-thumb.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/html-files/.svn/prop-base/schematic-board-thumb.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/html-files/.svn/prop-base/schematic-board.png.svn-base b/src/html-files/.svn/prop-base/schematic-board.png.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/html-files/.svn/prop-base/schematic-board.png.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/html-files/.svn/prop-base/trap-the-cap.pdf.svn-base b/src/html-files/.svn/prop-base/trap-the-cap.pdf.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/src/html-files/.svn/prop-base/trap-the-cap.pdf.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/src/html-files/.svn/text-base/board-thumb.jpg.svn-base b/src/html-files/.svn/text-base/board-thumb.jpg.svn-base new file mode 100644 index 0000000..16faf49 Binary files /dev/null and b/src/html-files/.svn/text-base/board-thumb.jpg.svn-base differ diff --git a/src/html-files/.svn/text-base/board.jpg.svn-base b/src/html-files/.svn/text-base/board.jpg.svn-base new file mode 100644 index 0000000..1f6787c Binary files /dev/null and b/src/html-files/.svn/text-base/board.jpg.svn-base differ diff --git a/src/html-files/.svn/text-base/index.html.svn-base b/src/html-files/.svn/text-base/index.html.svn-base new file mode 100644 index 0000000..3533ab1 --- /dev/null +++ b/src/html-files/.svn/text-base/index.html.svn-base @@ -0,0 +1,70 @@ + + +Trap the Cap + + + +

Trap The Cap

+ + + + +
The board
+ +

Changes

+ + + + + + + + + + + + + + + + + + + + +
23 February 2009Added a new player robot and fixed the sample game file to a legal one.
22 April 2008Updated library again: fixed bugs to detect a winner, and also eliminate players that have no uncaptured pieces.
10 September 2007Updated library again: Game#possible_moves now shows the legal moves as described below.
7 September 2007Updated library: now prevents moves via base without captured pieces and prevents more than three pieces on a safe position.
+Changed format for moves that end on a base
+ +

Trap The Cap is a simple board game of captuing (and +recapturing) pieces. You can read the +rules and look at the board to see how the game is played (rules +and image both from Board Game +Geek).

+ +

The challenge is to build a computer program that will play the +game well. The structure of the challenge is heavily based on the one +for Pousse. What needs to be fixed +for the game is how the various pieces and +places on the board are identified and how your player will be called (updated 22 April 2008).

+ +

There is a simple interface to a test for +your programs, with two simple robots to play against.

+ +

'Always clockwise simple' [source +code] always moves the lowest-valued piece clockwise around the +rim of the board. 'Clockwise cloud' [source +code] always moves the least clockwise piece clockwise around the +rim. They should be pretty easy to beat. Both robots are witten in +Ruby and use the libttc.rb library (updated 10 +September 2007). Feel free to base your own robots on this code. All +this code is released under the GNU General Public Licence +v3.

+ + + diff --git a/src/html-files/.svn/text-base/interface.html.svn-base b/src/html-files/.svn/text-base/interface.html.svn-base new file mode 100644 index 0000000..c761980 --- /dev/null +++ b/src/html-files/.svn/text-base/interface.html.svn-base @@ -0,0 +1,106 @@ + + +Trap the Cap Interface + + + +

Trap the Cap Computer Interface

+ +

Changes

+ + + + + + + + + + + + + + + +
23 February 2009Fixed the sample game file to a legal one.
7 September 2007Updated library: now prevents moves via base without captured pieces and prevents more than three pieces on a safe position.
+Changed format for moves that end on a base
31 August 2007Changed example input file (old one was invalid)
+Added notation for moves via bases
+Changed time limit to 10 seconds
+ +

The game will be played between two and six players. See below for +the identities of the players.

+ + + + + + + +
No. of playersPlayers +
2A, D
3A, C, E
4A, B, D, E
5A, B, C, D, E
6A, B, C, D, E, F
+ +

Your program will be run afresh for each move it has to make. Your +program will be fed the history of the game so far on standard input. +It will then have 10 seconds to report its move on standard +output.

+ +

The format of the input is as follows. The first line will be a +single digit, giving the number of players. Subsequent lines will +give the moves played so far in the game. The final line will be the +dice roll for your move. Each move will be in the format
+<piece moved> <location moved to>
+ +(that's a single space between the two parts of the line). If a move +is via a base, the move will be in the format
+<piece moved> <base moved via> <location moved +to>
+If a move is to a base, the move notation may be in either form.

+ +

It may be that one player may have many consecutive moves if they +roll multiple sixes. There are no additional spaces or blank lines in +the file.

+ +

Here is an example of a valid input file:

+ +
3
+A1 AC2
+C4 B5
+E1 EC5
+E2 E3
+A1 EC5
+C4 B2
+4
+ +

(Note the caputre of piece E1 by piece A1 on position EC5.) + +

Player program will run on a Linux machine (probably some version +of Ubuntu Linux). Exact specification is unclear at the moment, but +it may run on a twin-processor machine.

+ +

The player's program must be named runme; it may be a +binary executable or a driver shell script that starts up the actual +program. It will be invoked as
+ +

    ./runme

+ +with the program's top-level directory as the current working +directory; libraries and other support data may thus be accessed with +the relative path name
+ +
    support/...

+ +

The program is run once for every move and then terminates; the +current move state will be passed to the program on standard +input. Persistent inter-move state may be kept in the +support/ directory if desired. When the program has +chosen a move, it should print the move to standard output and +exit. If the program has not done so after 10 seconds (real or "wall +clock" time), the program will be terminated forcibly, and lose the +game.

+ +

There should be no child processes alive after the top-level +process exits; the program must ensure that all its child processes +have exited before the top-level process exits itself.

+ + + diff --git a/src/html-files/.svn/text-base/layout.html.svn-base b/src/html-files/.svn/text-base/layout.html.svn-base new file mode 100644 index 0000000..e738373 --- /dev/null +++ b/src/html-files/.svn/text-base/layout.html.svn-base @@ -0,0 +1,32 @@ + + +Trap the Cap Board Layout + + + +

Trap the Cap Board Layout and Labelling

+ + + + +
The board
+ +

Given the rules and board layout +(right), we can start to label the pieces and places.

+ +
    +
  • The six home bases are labelled 'A' .. 'F'.
  • +
  • The six playing pieces for each player each have their own names: +A1.. A6 for player A, B1..B6 for player B, and so on.
  • +
  • The locations on the board are given in terms of the nearest home base.
  • +
  • The player's home base is given the label 'A' for player A, and so +on.
  • +
  • Places around the rim are counted clockwise from the home base, +given labels 'A1', 'A2' ... 'A6'.
  • +
  • Places on the spokes are labelled, from the outside in, 'AC1', +'AC2' ... 'AC5'
  • +
  • The central space is, simultaneously, 'AC6', 'BC6', 'CC6'...
  • +
+ + + diff --git a/src/html-files/.svn/text-base/schematic-board-thumb.png.svn-base b/src/html-files/.svn/text-base/schematic-board-thumb.png.svn-base new file mode 100644 index 0000000..078063b Binary files /dev/null and b/src/html-files/.svn/text-base/schematic-board-thumb.png.svn-base differ diff --git a/src/html-files/.svn/text-base/schematic-board.png.svn-base b/src/html-files/.svn/text-base/schematic-board.png.svn-base new file mode 100644 index 0000000..3afe838 Binary files /dev/null and b/src/html-files/.svn/text-base/schematic-board.png.svn-base differ diff --git a/src/html-files/.svn/text-base/simple.html.svn-base b/src/html-files/.svn/text-base/simple.html.svn-base new file mode 100644 index 0000000..3afa6d0 --- /dev/null +++ b/src/html-files/.svn/text-base/simple.html.svn-base @@ -0,0 +1,35 @@ + + +Simple Trap the Cap form + + + +

Simple Trap the Cap form

+ +
+ + + + + + + + + + + + + + + +
Robot input:
Robot: +
+ +
+ + + diff --git a/src/html-files/.svn/text-base/trap-the-cap.pdf.svn-base b/src/html-files/.svn/text-base/trap-the-cap.pdf.svn-base new file mode 100644 index 0000000..fc0c15c Binary files /dev/null and b/src/html-files/.svn/text-base/trap-the-cap.pdf.svn-base differ diff --git a/src/html-files/board-thumb.jpg b/src/html-files/board-thumb.jpg new file mode 100644 index 0000000..16faf49 Binary files /dev/null and b/src/html-files/board-thumb.jpg differ diff --git a/src/html-files/board.jpg b/src/html-files/board.jpg new file mode 100644 index 0000000..1f6787c Binary files /dev/null and b/src/html-files/board.jpg differ diff --git a/src/html-files/index.html b/src/html-files/index.html new file mode 100644 index 0000000..3533ab1 --- /dev/null +++ b/src/html-files/index.html @@ -0,0 +1,70 @@ + + +Trap the Cap + + + +

Trap The Cap

+ + + + +
The board
+ +

Changes

+ + + + + + + + + + + + + + + + + + + + +
23 February 2009Added a new player robot and fixed the sample game file to a legal one.
22 April 2008Updated library again: fixed bugs to detect a winner, and also eliminate players that have no uncaptured pieces.
10 September 2007Updated library again: Game#possible_moves now shows the legal moves as described below.
7 September 2007Updated library: now prevents moves via base without captured pieces and prevents more than three pieces on a safe position.
+Changed format for moves that end on a base
+ +

Trap The Cap is a simple board game of captuing (and +recapturing) pieces. You can read the +rules and look at the board to see how the game is played (rules +and image both from Board Game +Geek).

+ +

The challenge is to build a computer program that will play the +game well. The structure of the challenge is heavily based on the one +for Pousse. What needs to be fixed +for the game is how the various pieces and +places on the board are identified and how your player will be called (updated 22 April 2008).

+ +

There is a simple interface to a test for +your programs, with two simple robots to play against.

+ +

'Always clockwise simple' [source +code] always moves the lowest-valued piece clockwise around the +rim of the board. 'Clockwise cloud' [source +code] always moves the least clockwise piece clockwise around the +rim. They should be pretty easy to beat. Both robots are witten in +Ruby and use the libttc.rb library (updated 10 +September 2007). Feel free to base your own robots on this code. All +this code is released under the GNU General Public Licence +v3.

+ + + diff --git a/src/html-files/interface.html b/src/html-files/interface.html new file mode 100644 index 0000000..c761980 --- /dev/null +++ b/src/html-files/interface.html @@ -0,0 +1,106 @@ + + +Trap the Cap Interface + + + +

Trap the Cap Computer Interface

+ +

Changes

+ + + + + + + + + + + + + + + +
23 February 2009Fixed the sample game file to a legal one.
7 September 2007Updated library: now prevents moves via base without captured pieces and prevents more than three pieces on a safe position.
+Changed format for moves that end on a base
31 August 2007Changed example input file (old one was invalid)
+Added notation for moves via bases
+Changed time limit to 10 seconds
+ +

The game will be played between two and six players. See below for +the identities of the players.

+ + + + + + + +
No. of playersPlayers +
2A, D
3A, C, E
4A, B, D, E
5A, B, C, D, E
6A, B, C, D, E, F
+ +

Your program will be run afresh for each move it has to make. Your +program will be fed the history of the game so far on standard input. +It will then have 10 seconds to report its move on standard +output.

+ +

The format of the input is as follows. The first line will be a +single digit, giving the number of players. Subsequent lines will +give the moves played so far in the game. The final line will be the +dice roll for your move. Each move will be in the format
+<piece moved> <location moved to>
+ +(that's a single space between the two parts of the line). If a move +is via a base, the move will be in the format
+<piece moved> <base moved via> <location moved +to>
+If a move is to a base, the move notation may be in either form.

+ +

It may be that one player may have many consecutive moves if they +roll multiple sixes. There are no additional spaces or blank lines in +the file.

+ +

Here is an example of a valid input file:

+ +
3
+A1 AC2
+C4 B5
+E1 EC5
+E2 E3
+A1 EC5
+C4 B2
+4
+ +

(Note the caputre of piece E1 by piece A1 on position EC5.) + +

Player program will run on a Linux machine (probably some version +of Ubuntu Linux). Exact specification is unclear at the moment, but +it may run on a twin-processor machine.

+ +

The player's program must be named runme; it may be a +binary executable or a driver shell script that starts up the actual +program. It will be invoked as
+ +

    ./runme

+ +with the program's top-level directory as the current working +directory; libraries and other support data may thus be accessed with +the relative path name
+ +
    support/...

+ +

The program is run once for every move and then terminates; the +current move state will be passed to the program on standard +input. Persistent inter-move state may be kept in the +support/ directory if desired. When the program has +chosen a move, it should print the move to standard output and +exit. If the program has not done so after 10 seconds (real or "wall +clock" time), the program will be terminated forcibly, and lose the +game.

+ +

There should be no child processes alive after the top-level +process exits; the program must ensure that all its child processes +have exited before the top-level process exits itself.

+ + + diff --git a/src/html-files/layout.html b/src/html-files/layout.html new file mode 100644 index 0000000..e738373 --- /dev/null +++ b/src/html-files/layout.html @@ -0,0 +1,32 @@ + + +Trap the Cap Board Layout + + + +

Trap the Cap Board Layout and Labelling

+ + + + +
The board
+ +

Given the rules and board layout +(right), we can start to label the pieces and places.

+ +
    +
  • The six home bases are labelled 'A' .. 'F'.
  • +
  • The six playing pieces for each player each have their own names: +A1.. A6 for player A, B1..B6 for player B, and so on.
  • +
  • The locations on the board are given in terms of the nearest home base.
  • +
  • The player's home base is given the label 'A' for player A, and so +on.
  • +
  • Places around the rim are counted clockwise from the home base, +given labels 'A1', 'A2' ... 'A6'.
  • +
  • Places on the spokes are labelled, from the outside in, 'AC1', +'AC2' ... 'AC5'
  • +
  • The central space is, simultaneously, 'AC6', 'BC6', 'CC6'...
  • +
+ + + diff --git a/src/html-files/robots/.svn/all-wcprops b/src/html-files/robots/.svn/all-wcprops new file mode 100644 index 0000000..260701e --- /dev/null +++ b/src/html-files/robots/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/robots +END diff --git a/src/html-files/robots/.svn/entries b/src/html-files/robots/.svn/entries new file mode 100644 index 0000000..37dc581 --- /dev/null +++ b/src/html-files/robots/.svn/entries @@ -0,0 +1,25 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/src/html-files/robots +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +1 +dir + +2 +dir + +3 +dir + diff --git a/src/html-files/robots/.svn/format b/src/html-files/robots/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/src/html-files/robots/.svn/format @@ -0,0 +1 @@ +8 diff --git a/src/html-files/robots/1/.svn/all-wcprops b/src/html-files/robots/1/.svn/all-wcprops new file mode 100644 index 0000000..bc1edd1 --- /dev/null +++ b/src/html-files/robots/1/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 62 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/robots/1 +END +runme +K 25 +svn:wc:ra_dav:version-url +V 68 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/robots/1/runme +END diff --git a/src/html-files/robots/1/.svn/entries b/src/html-files/robots/1/.svn/entries new file mode 100644 index 0000000..b69db3d --- /dev/null +++ b/src/html-files/robots/1/.svn/entries @@ -0,0 +1,29 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/src/html-files/robots/1 +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +runme +file + + + + +2008-05-22T10:01:10.000000Z +508e127b6cb4b5f78a524e17c54cf532 +2008-10-16T14:11:23.436422Z +41 + +has-props + diff --git a/src/html-files/robots/1/.svn/format b/src/html-files/robots/1/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/src/html-files/robots/1/.svn/format @@ -0,0 +1 @@ +8 diff --git a/src/html-files/robots/1/.svn/prop-base/runme.svn-base b/src/html-files/robots/1/.svn/prop-base/runme.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/html-files/robots/1/.svn/prop-base/runme.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/html-files/robots/1/.svn/text-base/runme.svn-base b/src/html-files/robots/1/.svn/text-base/runme.svn-base new file mode 100644 index 0000000..a702f0e --- /dev/null +++ b/src/html-files/robots/1/.svn/text-base/runme.svn-base @@ -0,0 +1,75 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +require 'libttc' + +def more_clockwise(this, other) + here = this.destination.place + there = other.destination.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves! moves + +# The piece to move is the uncaptured one of mine with the lowest number +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort_by {|p| p.name})[0] + +# find the most clockwise move +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x, y} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/html-files/robots/1/runme b/src/html-files/robots/1/runme new file mode 100755 index 0000000..a702f0e --- /dev/null +++ b/src/html-files/robots/1/runme @@ -0,0 +1,75 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +require 'libttc' + +def more_clockwise(this, other) + here = this.destination.place + there = other.destination.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves! moves + +# The piece to move is the uncaptured one of mine with the lowest number +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort_by {|p| p.name})[0] + +# find the most clockwise move +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x, y} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/html-files/robots/1/runme~ b/src/html-files/robots/1/runme~ new file mode 100755 index 0000000..ddeb2d8 --- /dev/null +++ b/src/html-files/robots/1/runme~ @@ -0,0 +1,75 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +require 'libttc' + +def more_clockwise(this, other) + here = this.destination.place + there = other.destination.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves moves + +# The piece to move is the uncaptured one of mine with the lowest number +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort_by {|p| p.name})[0] + +# find the most clockwise move +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x, y} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/html-files/robots/2/.svn/all-wcprops b/src/html-files/robots/2/.svn/all-wcprops new file mode 100644 index 0000000..f4455ac --- /dev/null +++ b/src/html-files/robots/2/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 62 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/robots/2 +END +runme +K 25 +svn:wc:ra_dav:version-url +V 68 +/svn/njae/!svn/ver/41/TrapTheCap/trunk/src/html-files/robots/2/runme +END diff --git a/src/html-files/robots/2/.svn/entries b/src/html-files/robots/2/.svn/entries new file mode 100644 index 0000000..3985f66 --- /dev/null +++ b/src/html-files/robots/2/.svn/entries @@ -0,0 +1,29 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/src/html-files/robots/2 +http://scripts.njae.me.uk/svn/njae + + + +2008-10-16T14:11:23.436422Z +41 + + + +svn:special svn:externals svn:needs-lock + +runme +file + + + + +2008-05-22T10:01:21.000000Z +15f27beb7a6886db08f2b276546a8cdb +2008-10-16T14:11:23.436422Z +41 + +has-props + diff --git a/src/html-files/robots/2/.svn/format b/src/html-files/robots/2/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/src/html-files/robots/2/.svn/format @@ -0,0 +1 @@ +8 diff --git a/src/html-files/robots/2/.svn/prop-base/runme.svn-base b/src/html-files/robots/2/.svn/prop-base/runme.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/html-files/robots/2/.svn/prop-base/runme.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/html-files/robots/2/.svn/text-base/runme.svn-base b/src/html-files/robots/2/.svn/text-base/runme.svn-base new file mode 100644 index 0000000..f086b57 --- /dev/null +++ b/src/html-files/robots/2/.svn/text-base/runme.svn-base @@ -0,0 +1,77 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +require 'libttc' + +def more_clockwise(this, other) + here = this.place + there = other.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves! moves + + +# The piece to move is the least clockwise of my uncaptured pieces +# Always move pieces on the base first +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort {|x, y| more_clockwise x.position, y.position})[0] + +# Find the most clockwise move for this piece +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x.destination, y.destination} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/html-files/robots/2/runme b/src/html-files/robots/2/runme new file mode 100755 index 0000000..f086b57 --- /dev/null +++ b/src/html-files/robots/2/runme @@ -0,0 +1,77 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +require 'libttc' + +def more_clockwise(this, other) + here = this.place + there = other.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves! moves + + +# The piece to move is the least clockwise of my uncaptured pieces +# Always move pieces on the base first +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort {|x, y| more_clockwise x.position, y.position})[0] + +# Find the most clockwise move for this piece +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x.destination, y.destination} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/html-files/robots/2/runme~ b/src/html-files/robots/2/runme~ new file mode 100755 index 0000000..3df362f --- /dev/null +++ b/src/html-files/robots/2/runme~ @@ -0,0 +1,77 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +require 'libttc' + +def more_clockwise(this, other) + here = this.place + there = other.place + + # if both are on a spoke, choose the one with the lowest number (nearer the rim) + if here =~ /.c./ and there =~ /.c./ + # break ties by preferring the most clockwise arc + if here[-1] == there[-1] + return here[0] <=> there[0] + else + return -1 * (here[-1] <=> there[-1]) + end + # If one is one a spoke and the other is on the rim, choose the one on the rim + elsif here =~ /.c./ or there =~ /.c./ + return -1 * (here.length <=> there.length) + # If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a' + elsif here[0,1] == 'a' and there[0,1] == 'f' + return +1 + elsif here[0,1] == 'f' and there[0,1] == 'a' + return -1 + # Otherwise, choose the one with highest arc code + else + return here <=> there + end + +end + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves moves + + +# The piece to move is the least clockwise of my uncaptured pieces +# Always move pieces on the base first +my_pieces = game.pieces.values.select {|p| p.colour == game.current_player and not p.captured} +piece_to_move = (my_pieces.sort {|x, y| more_clockwise x.position, y.position})[0] + +# Find the most clockwise move for this piece +potential_moves = game.possible_moves(next_roll).select {|m| m.piece == piece_to_move} +sorted_moves = potential_moves.sort {|x, y| more_clockwise x.destination, y.destination} +best_move = sorted_moves[-1] + +# return that move +puts best_move + + diff --git a/src/html-files/robots/3/.svn/all-wcprops b/src/html-files/robots/3/.svn/all-wcprops new file mode 100644 index 0000000..92906ad --- /dev/null +++ b/src/html-files/robots/3/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 62 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/html-files/robots/3 +END +runme.rb +K 25 +svn:wc:ra_dav:version-url +V 71 +/svn/njae/!svn/ver/69/TrapTheCap/trunk/src/html-files/robots/3/runme.rb +END diff --git a/src/html-files/robots/3/.svn/entries b/src/html-files/robots/3/.svn/entries new file mode 100644 index 0000000..d63a278 --- /dev/null +++ b/src/html-files/robots/3/.svn/entries @@ -0,0 +1,27 @@ +8 + +dir +69 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/src/html-files/robots/3 +http://scripts.njae.me.uk/svn/njae + + + +2009-02-23T14:02:44.812274Z +69 + + + +svn:special svn:externals svn:needs-lock + +runme.rb +file + + + + +2009-02-23T14:01:47.000000Z +597c993fb86e5502356a806a91127c5e +2009-02-23T14:02:44.812274Z +69 + diff --git a/src/html-files/robots/3/.svn/format b/src/html-files/robots/3/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/src/html-files/robots/3/.svn/format @@ -0,0 +1 @@ +8 diff --git a/src/html-files/robots/3/.svn/text-base/runme.rb.svn-base b/src/html-files/robots/3/.svn/text-base/runme.rb.svn-base new file mode 100644 index 0000000..2e49434 --- /dev/null +++ b/src/html-files/robots/3/.svn/text-base/runme.rb.svn-base @@ -0,0 +1,35 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith + + +require 'libttc' +require 'libttc-pplayer' +require 'rdoc/usage' + + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves! moves + +player = Potential_player.new({:friend_pull => 0.0, + :enemy_pull => 0.0, + :base_pull => 0.0, + :safe_bonus => 10, + :capture_bonus => 2}) + +best_move = player.best_move(game, next_roll) + +# return that move +puts best_move diff --git a/src/html-files/robots/3/runme.rb b/src/html-files/robots/3/runme.rb new file mode 100644 index 0000000..2e49434 --- /dev/null +++ b/src/html-files/robots/3/runme.rb @@ -0,0 +1,35 @@ +#!/usr/bin/ruby +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# clockwise-p1 +# Game state file read on STDIN +# Move produced on STDOUT +# +# == Author +# Neil Smith + + +require 'libttc' +require 'libttc-pplayer' +require 'rdoc/usage' + + +# Get the current game state +game_lines = readlines +game, moves, next_roll = Game.read_game(game_lines) +game.apply_moves! moves + +player = Potential_player.new({:friend_pull => 0.0, + :enemy_pull => 0.0, + :base_pull => 0.0, + :safe_bonus => 10, + :capture_bonus => 2}) + +best_move = player.best_move(game, next_roll) + +# return that move +puts best_move diff --git a/src/html-files/schematic-board-thumb.png b/src/html-files/schematic-board-thumb.png new file mode 100644 index 0000000..078063b Binary files /dev/null and b/src/html-files/schematic-board-thumb.png differ diff --git a/src/html-files/schematic-board.png b/src/html-files/schematic-board.png new file mode 100644 index 0000000..3afe838 Binary files /dev/null and b/src/html-files/schematic-board.png differ diff --git a/src/html-files/simple.html b/src/html-files/simple.html new file mode 100644 index 0000000..3afa6d0 --- /dev/null +++ b/src/html-files/simple.html @@ -0,0 +1,35 @@ + + +Simple Trap the Cap form + + + +

Simple Trap the Cap form

+ +
+ + + + + + + + + + + + + + + +
Robot input:
Robot: +
+ +
+ + + diff --git a/src/html-files/trap-the-cap.pdf b/src/html-files/trap-the-cap.pdf new file mode 100644 index 0000000..fc0c15c Binary files /dev/null and b/src/html-files/trap-the-cap.pdf differ diff --git a/src/libgenetics.rb b/src/libgenetics.rb new file mode 100644 index 0000000..3632440 --- /dev/null +++ b/src/libgenetics.rb @@ -0,0 +1,176 @@ +# == Synopsis +# +# Library to support genetic algorithms +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +# A single genome in a population +class Genome + + attr_accessor :genome + + # Create a random genome of the given length + def initialize(bitstring_or_length) + if bitstring_or_length.class == Fixnum + @genome = [] + (1..bitstring_or_length).each do |i| + @genome << rand(2) + end + else + @genome = bitstring_or_length + end + end + + # Mutate a genome with the given rate per bit + def mutate(mutation_probability = 0.05) + new_genome = Genome.new(@genome.length) + (0...@genome.length).each do |i| + if rand < mutation_probability + if @genome[i] == 0 + new_genome.genome[i] = 1 + else + new_genome.genome[i] = 0 + end + else + new_genome.genome[i] = @genome[i] + end + end + new_genome + end + + # Mutate a genome in-place with the given rate per bit + def mutate!(mutation_probability = 0.05) + (0...@genome.length).each do |i| + if rand < mutation_probability + if @genome[i] == 0 + @genome[i] = 1 + else + @genome[i] = 0 + end + end + end + @genome + end + + # Crossover two genomes at the given point + def crossover(other_genome, crossover_point) + raise ArgumentError, "Different size genomes" if @genome.length != other_genome.genome.length + raise ArgumentError, "Our of bounds crossover point" if crossover_point < 0 or crossover_point > @genome.length + child1 = Genome.new(0) + child2 = Genome.new(0) + child1.genome = @genome[0, crossover_point] + other_genome.genome[crossover_point, @genome.length] + child2.genome = other_genome.genome[0, crossover_point] + @genome[crossover_point, @genome.length] + [child1, child2] + end + +end + + +class Array + def to_decimal + val = 0 + bits = self.dup + while not bits.empty? + val = val * 2 + bits[0] + bits = bits[1..bits.length] + end + val + end + + def gray_encode + gray = self[0..0] + (1...self.length).each do |i| + if (self[i - 1] == 1) ^ (self[i] == 1) + gray << 1 + else + gray << 0 + end + end + gray + end + + def gray_decode + binary = self[0..0] + (1...self.length).each do |i| + if (binary[i - 1] == 1) ^ (self[i] == 1) + binary << 1 + else + binary << 0 + end + end + binary + end + +end + +class Fixnum + def to_bitstring(min_length = 0) + bits = [] + k = self + while k > 0 do + if k % 2 == 1 + bits << 1 + else + bits << 0 + end + k = k >> 1 + end + while bits.length < min_length do + bits << 0 + end + bits.reverse + end +end + + +# A population of genomes +class Population + attr_accessor :individuals + + # Create a population of a given size + def initialize(population_size, genome_length = 0) + @individuals = [] + 1.upto(population_size) { @individuals << Genome.new(genome_length) } + end + + # Perform the crossover step in a population, giving a new population + def crossover(crossover_rate) + parents = @individuals.dup # genomes that haven't been parents yet + next_population = Population.new(0) + while parents.length > 1 + parent1 = parents.delete_at(rand(parents.length)).dup + parent2 = parents.delete_at(rand(parents.length)).dup + if rand < crossover_rate + child1, child2 = parent1.crossover parent2, rand(parent1.genome.length) + next_population.individuals << child1 << child2 + else + next_population.individuals << parent1 << parent2 + end + end + next_population.individuals.concat parents # pick up any parents that didn't get a chance to mate + next_population + end + + # Perform the mutation step in a population, giving a new population + def mutation(mutation_rate) + parents = @individuals.dup # genomes that haven't been parents yet + next_population = Population.new(0) + while parents.length > 0 + parent = parents.pop.dup + child = parent.mutate mutation_rate + next_population.individuals << child + end + next_population + end + + def make_next_generation(tournament_winner_success_rate = 0.8, game_length = 1000, crossover_rate = 0.7, mutation_rate = 0.05) + @individuals = tournament_select_population(tournament_winner_success_rate, game_length, false) + @individuals = crossover(crossover_rate) + @individuals = mutation(mutation_rate) + end + +end diff --git a/src/libttc-pplayer.rb b/src/libttc-pplayer.rb new file mode 100644 index 0000000..a848045 --- /dev/null +++ b/src/libttc-pplayer.rb @@ -0,0 +1,74 @@ +# == Synopsis +# +# Library to support a Trap the Cap player that uses potentials to select the +# best move +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +require 'libttc' + +# Play Trap the Cap by using potential fields. For each possible move, +# calculate the field strength and pick the move with the lowest potential +class Potential_player + + attr_reader :friend_pull, :enemy_pull, :base_pull, + :safe_bonus, :capture_bonus + + def initialize(args, verbose = false) + @friend_pull = args[:friend_pull] || 1 + @enemy_pull = args[:enemy_pull] || 0.5 + @base_pull = args[:base_pull] || 2 + @safe_bonus = args[:safe_bonus] || 8 + @capture_bonus = args[:capture_bonus] || 10 + + @verbose = verbose + end + + # Find the best move of the possible ones + def best_move(game, die_result) + me = game.current_player + possible_moves = game.possible_moves(die_result, me) + scored_moves = possible_moves.collect do |m| + begin + game.apply_move! m + score = score_position(game, me) +# game.undo_move! + rescue GameWonNotice + score = 10000 + ensure + game.undo_move! + end + puts "#{m} scores #{score}" if @verbose + [m, score] + end + best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0] + end + + # Calculate the potential score of a position for a given player + def score_position(game, player) + score = 0 + game.pieces.each_value do |piece| + here = piece.position + if piece.colour == player + game.pieces.each_value do |other_piece| + if other_piece.colour == player + score += game.board.distance_between[here.place][other_piece.position.place] * @friend_pull + else + score += game.board.distance_between[here.place][other_piece.position.place] * @enemy_pull + end + end + score += piece.contains.length * @capture_bonus + score += game.board.distance_between[here.place][game.board.positions[player].place] * + piece.contains.length * @base_pull + elsif here == game.board.positions[player] + score += @safe_bonus + end + end + score + end + +end diff --git a/src/libttc.rb b/src/libttc.rb new file mode 100644 index 0000000..97845c7 --- /dev/null +++ b/src/libttc.rb @@ -0,0 +1,615 @@ +# == Synopsis +# +# Library to support Trap the Cap play +# +# == Author +# Neil Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# == Change history +# Version 1.1:: 07 Sep 2007 +# * Changed format for showing moves via bases. +# * Raise error when moving via base without captured pieces +# * Raise error when moving onto a safe space with 3 or more +# pieces already there +# Version 1.2:: 10 Sep 2007 +# * Incorporated changes in move legality above into +# Game#possible_moves +# Version 1.3:: 25 Mar 2008 +# * Fixed bug to detect a winner, and also eliminate players +# that have no uncaptured pieces. + +# Errors for a game + +# Pieces can only capture pieces that they're on. +class InvalidCaptureError < StandardError +end + +# Moves can only be [1..6] spaces +class InvalidMoveError < StandardError +end + +# Game is won when only one player has uncaptured pieces +class GameWonNotice < StandardError +end + + +# Each possible position for a piece is an object +# Each neighbour is another position object +class Position + attr_reader :place # the name of this place + attr_accessor :contains # the pieces it contains + attr_accessor :neighbours # the positions that neighbour it + + def initialize(place, safety, base) + @place = place + @safe = safety + @base = base + @neighbours = Array.new + end + + # is this position a safety one (i.e. no captures allowed)? + def safe? + @safe + end + + # Is this position a base? + def base? + @base + end + + def to_s + @place + end + + def to_str + to_s + end + +end + + +# The game board +class Board + + attr_reader :positions + attr_reader :valid_moves + attr_reader :distance_between + attr_reader :centre + + + # A laborious procedure to create all the positions and tie them all together + def initialize(spokes, spoke_length, arc_length) + # A hash of all positions, indexed by position names + @positions = Hash.new + @centre = Position.new('ac' + spoke_length.to_s, false, false) + @positions['ac' + spoke_length.to_s] = centre + a1_corner = nil + end_of_previous_arc = nil + + # Do each arc-spoke-base set + (?a...(?a + spokes)).each do |arc_code| + arc = arc_code.chr + base = Position.new(arc, false, true) + this_arc = Array.new + + # build the arc + (1..arc_length).each do |arc_position| + position_name = arc + arc_position.to_s + arc_place = Position.new(position_name, arc_position == 4, false) + arc_place.neighbours = [] + @positions[position_name] = arc_place + this_arc << arc_place + a1_corner = a1_corner || arc_place + end + (0...arc_length).each do |arc_position| + if arc_position > 0 + this_arc[arc_position].neighbours << this_arc[arc_position - 1] + end + if arc_position < (arc_length - 1) + this_arc[arc_position].neighbours << this_arc[arc_position + 1] + end + end + + # build the spoke + this_spoke = Array.new + (1..(spoke_length - 1)).each do |spoke_position| + position_name = arc + "c" + spoke_position.to_s + spoke_place = Position.new(position_name, spoke_position == 3, false) + spoke_place.neighbours = [] + @positions[position_name] = spoke_place + this_spoke << spoke_place + end + (0...(spoke_length - 1)).each do |spoke_position| + if spoke_position > 0 + this_spoke[spoke_position].neighbours << this_spoke[spoke_position - 1] + end + if spoke_position < spoke_length - 2 + this_spoke[spoke_position].neighbours << this_spoke[spoke_position + 1] + end + end + + # tie the spoke and arc together, + this_arc[0].neighbours << this_spoke[0] + this_spoke[0].neighbours << this_arc[0] + + # tie the spoke to the centre, and + this_spoke[-1].neighbours << @centre + @centre.neighbours << this_spoke[-1] + + # tie the base to the arc + base = Position.new(arc, false, true) + @positions[arc] = base + base.neighbours << this_arc[0] + this_arc[0].neighbours << base + + # record the ends of the arc for tying to adjacent arcs + if end_of_previous_arc + end_of_previous_arc.neighbours << this_arc[0] + this_arc[0].neighbours << end_of_previous_arc + end + end_of_previous_arc = this_arc[-1] + + end # arc + + # tie both ends of the rim together + a1_corner.neighbours << end_of_previous_arc + end_of_previous_arc.neighbours << a1_corner + + cache_valid_moves + + end # def + + def to_s + layout + end + + def to_str + to_s + end + + + # For each position, show its name and what it touches + def layout + out_string = "" + @positions.keys.sort.each do |position| + out_string << sprintf("%s touches ", @positions[position]) + @positions[position].neighbours.each do |neighbour| + out_string << sprintf("%s, ", neighbour) + end + out_string << sprintf("\n") + end + out_string + end + + + # Precompute the valid moves for this board, and the distances between each + # pair of positions + def cache_valid_moves + # A hash of arrays. The has key is the name of a positions. The array + # element [i] stores the positions that are i spaces from here + @valid_moves = Hash.new + # A hash of hashes. Given two names, return the shortest distance between + # the two locations + @distance_between = Hash.new + @positions.each do |place, position| + @valid_moves[place] = Array.new + @distance_between[place] = Hash.new + @valid_moves[place][0] = [@positions[place]] + @distance_between[place][place] = 0 + # Find the shortest routes by Dijkstra's algorithm + agenda = [position] + closed_list = [position] + i = 1 + while not agenda.empty? + @valid_moves[place][i] = [] + new_agenda = [] + agenda.each do |pos| + valid_extensions = pos.neighbours.reject {|new_position| closed_list.include?(new_position) } + @valid_moves[place][i] += valid_extensions + valid_extensions.each {|ext| @distance_between[place][ext.place] ||= i } + closed_list += valid_extensions + new_agenda += valid_extensions + end + agenda = new_agenda + i += 1 + end + end + end + +end + + +# Each piece on the board is an object +class Piece + attr_reader :colour + attr_accessor :position, :contains, :captured + + def initialize(number, position, colour) + @number = number + @position = position + @colour = colour + @captured = false + @contains = [] + end + + def name + @colour + @number.to_s + end + + def to_s + self.name + end + + def to_str + to_s + end + + def move_to(new_position) + @position = new_position + @contains.each {|c| c.move_to(new_position)} + end + + # Caputre another piece + def capture(other_piece) + if @position = other_piece.position + @contains << other_piece + @contains += other_piece.contains + other_piece.contains = [] + other_piece.captured = true + else + raise(InvalidCaptureError, + "Piece #{self.name} cannot capture #{other_piece.name}: different locations") + end + end + +end + + +# A move in a game +class Move + attr_reader :piece, :destination + + def initialize(piece, destination, via_base = false) + @piece = piece + @destination = destination + @via_base = via_base + end + + def via_base? + @via_base + end + + # Write a move to a string + # Note the inverse, String#to_move, is defined below + def to_s + if @via_base + if @destination.base? + @piece.to_s + " " + @destination.to_s + else + @piece.to_s + " " + piece.colour + " " + @destination.to_s + end + else + @piece.to_s + " " + @destination.to_s + end + end + + def to_str + to_s + end + +end + + + +# A class to record each of the states previously found in a game. +# Note that this is a deep copy of the pieces and what they've captured, so +# you'll need to convert back +class GameState + attr_accessor :move, :player, :pieces_after_move + + def initialize(move, player, pieces) + @move = move + @player = player + @pieces_after_move = Hash.new + pieces.each {|k, p| @pieces_after_move[k] = p.dup} + @pieces_after_move.each_value {|p| p.contains = []} + # and now to make the captured pieces point to the copies + pieces.each do |k, p| + p.contains.each do |captured_piece| + @pieces_after_move[k].capture(@pieces_after_move[captured_piece.name]) + end + end + end + + def ==(other) + @move.to_s == other.move.to_s and + @player == other.player and + @piece_after_move == other.pieces_after_move + end + +end + + +# A game of Trap the Cap. It keeps a history of all previous states. +class Game + + attr_reader :history + attr_reader :current_player, :players + attr_reader :board + attr_reader :pieces + + # Create a new game + def initialize(players = 6, spokes = 6, spoke_length = 6, arc_length = 6, + pieces_each = 6) + @board = Board.new(spokes, spoke_length, arc_length) + @history = [] + @pieces = Hash.new + @players = case + when players == 2 ; ['a', 'd'] + when players == 3 ; ['a', 'c', 'e'] + when players == 4 ; ['a', 'b', 'd', 'e'] + when players == 5 ; ['a', 'b', 'c', 'd', 'e'] + when players == 6 ; ['a', 'b', 'c', 'd', 'e', 'f'] + end + @current_player = 'a' + @players.each do |player| + players_base = @board.positions[player] + (1..pieces_each).each do |count| + piece = Piece.new(count, players_base, player) + @pieces[player + count.to_s] = piece + end + end + end + + + # Apply a single move to a game. + def apply_move!(move, player = @current_player) + # Check the move is a valid one + raise(InvalidMoveError, "Piece #{move.piece} does not exist") unless @pieces.has_key?(move.piece.name) + raise(InvalidMoveError, "Player #{player} moving piece #{move.piece}") unless move.piece.colour == player + raise(InvalidMoveError, "Attempting to move captured piece #{move.piece}") if move.piece.captured + raise(InvalidMoveError, "Attempting to move #{move.piece} onto or via base without captured pieces") if move.via_base? and move.piece.contains.empty? + if move.destination.safe? + if (@pieces.find_all {|k, p| p.position == move.destination}).length >= 3 + raise(InvalidMoveError, "Attempting to move #{move.piece} onto safe position #{move.destination} when there are already three or more pieces there") + end + end + if move.via_base? + moved_distance = board.distance_between[move.piece.position.place][player] + + board.distance_between[player][move.destination.place] + else + moved_distance = board.distance_between[move.piece.position.place][move.destination.place] + end + raise(InvalidMoveError, "Attempting to move piece #{move.piece} #{moved_distance} places (from #{move.piece.position} to #{move.destination})") if moved_distance < 1 or moved_distance > 6 + + # Apply this move + move.piece.move_to(move.destination) + + # Capture anything already there (unless it's a safe place or a base, + # or our own colour, or already captured) + unless move.destination.safe? or move.destination.base? + @pieces.each do |name, target_piece| + if target_piece.position == move.destination and + target_piece != move.piece and + not move.piece.contains.member?(target_piece) and + target_piece.colour != player and + not target_piece.captured + move.piece.capture(target_piece) + end + end + end + + # If the move was via our base, drop all captured pieces + if move.via_base? + capturers_base = board.positions[move.piece.colour] + move.piece.contains.each do |captured_piece| + captured_piece.move_to capturers_base + captured_piece.captured = false if captured_piece.colour == move.piece.colour + end + move.piece.contains = [] + end + + # Record the new stae + this_game_state = GameState.new(move, player, @pieces) + @history << this_game_state + + # Retain only players that have uncaptured pieces. + # If there's only one player with uncaptured pieces, declare a win. + potential_players = [] + @players.each do |p| + if (@pieces.values.select {|piece| piece.colour == p}).any? {|piece| not piece.captured} + potential_players << p + end + # potential_players << p if (@pieces.values.select {|p| p.colour == @current_player}).any? {|p| not p.captured} + end + if potential_players.length <= 1 + raise(GameWonNotice, "Game won by #{potential_players[0]}") + end + @players = potential_players.sort + end + + # Undo a move + def undo_move! + if @history.length > 1 + # general case + state_to_restore = @history[-2] + @current_player = @history[-1].player + @pieces.each do |name, piece| + copy_piece = state_to_restore.pieces_after_move[name] + piece.position = copy_piece.position + piece.captured = copy_piece.captured + piece.contains = [] + copy_piece.contains.each do |p| +# piece.capture(@pieces[p.name]) + piece.contains << @pieces[p.name] + end + end + @history.pop + elsif @history.length == 1 + # reset to start + @current_player = 'a' + @pieces.each do |name, piece| + piece.position = @board.positions[piece.colour] + piece.captured = false + piece.contains = [] + end + @history.pop + end + end + + # Apply a list of moves in order + def apply_moves!(moves) + moves.each do |move| + if move.via_base? + moved_distance = board.distance_between[move.piece.position.place][@current_player] + + board.distance_between[@current_player][move.destination.place] + else + moved_distance = board.distance_between[move.piece.position.place][move.destination.place] + end + self.apply_move!(move, @current_player) + next_player! unless moved_distance == 6 + end + end + + + # Set the current player to be the next player + def next_player! + original_player = @current_player + begin + if @current_player == @players[-1] + @current_player = @players[0] + else + @current_player = @players[@players.index(@current_player) + 1] + end + end while (@pieces.values.select {|p| p.colour == @current_player}).all? {|p| p.captured} and @current_player != original_player + @current_player + end + + + # Return an array of all possible moves from this state, given the die roll + # and the active player + def possible_moves(die_result, player = @current_player) + moves = [] + @pieces.each do |key, piece| + # only move current player's pieces, and only if they're not captured + if piece.colour == player and (not piece.captured) + (@board.valid_moves[piece.position.place][die_result]).each do |destination| + if destination.safe? + if (@pieces.find_all {|k, p| p.position == destination}).length < 3 + moves << Move.new(piece, destination, false) + end + else + moves << Move.new(piece, destination, false) unless destination.base? + end + end + # if we can move to our base (but not already on it), add moves via that... + if @board.distance_between[piece.position.place][player] <= die_result and + not piece.position.place == player and + not piece.contains.empty? + distance_after_base = die_result - @board.distance_between[piece.position.place][player] + (@board.valid_moves[player][distance_after_base]).each do |destination| + if destination.safe? + if (@pieces.find_all {|k, p| p.position == destination}).length < 3 + moves << Move.new(piece, destination, true) + end + else + moves << Move.new(piece, destination, true) + end + end + end + end + end + moves + end + + + def build_state_string + outstr = "Current player = #{@current_player}\n" + @pieces.keys.sort.each do |piece_name| + if @pieces[piece_name].captured + outstr << "Piece #{piece_name} captured, at #{@pieces[piece_name].position}\n" + else + outstr << "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}\n" + end + end + outstr + end + + # Show the state of the board + def show_state + puts build_state_string +# @pieces.keys.sort.each do |piece_name| +# if @pieces[piece_name].captured +# puts "Piece #{piece_name} captured, at #{@pieces[piece_name].position}" +# else +# puts "Piece #{piece_name} is at #{@pieces[piece_name].position}, holds #{(@pieces[piece_name].contains.collect{|c| c.name}).join(' ')}" +# end +# end + end + + def to_s + show_state + end + + def to_str + to_s + end + + + # Given a set of lines from an input file, turn them into a Game object and + # a set of Move objects. + # Note the multiple return values. + # Class method + def Game.read_game(gamelines) + gamelines.each {|l| l.chomp!} + game = Game.new(gamelines[0].to_i, 6, 6, 6, 6) + moves = [] + gamelines[1..-2].each {|m| moves << m.to_move(game)} + return game, moves, gamelines[-1].to_i + end + + +end + + +# Extension to String class to convert a move-description string into a Move object. +# This is the inverse of the Move#to_s method +class String + def to_move(game) + move_elements = self.downcase.split + piece_name = move_elements[0] + destination_name = move_elements[-1] + if destination_name.length > 2 and + destination_name[-2,2] == game.board.centre.place[-2,2] + destination_name = game.board.centre.place + end + raise(InvalidMoveError, "Invalid piece in move read") unless game.pieces.has_key?(piece_name) + raise(InvalidMoveError, "Invalid destination in move read") unless game.board.positions.has_key?(destination_name) + # Deal with the synonyms for the centre position + via_base = (destination_name.length == 1 or move_elements.length > 2) + Move.new(game.pieces[piece_name], game.board.positions[destination_name], via_base) + end +end + + +# Read a game description file and convert it into a Game object and set of Move objects. +# Note that Game.read_game method returns multiple values, so this one does too. +class IO + def IO.read_game(filename) + gamelines = IO.readlines(filename) + return Game.read_game(gamelines) + end +end diff --git a/src/play.rb b/src/play.rb new file mode 100644 index 0000000..01b2f29 --- /dev/null +++ b/src/play.rb @@ -0,0 +1,61 @@ +# == Synopsis +# +# Play a game of Trap the Cap. +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + +require 'lib/libttc' +require 'lib/libpplayer' + +# Play a game to completion, given a set of player agents. +class GameHandler + + attr_reader :game + + # Create a game handler that uses a set of players + def initialize(players, limit = 5000, verbose = false, very_verbose = false) + @game = Game.new(players.length) + @verbose = verbose + @very_verbose = very_verbose + @limit = limit + + # Give each player a name + @named_players = Hash.new + (@game.players.zip players).each do |kv| + @named_players[kv[0]] = kv[1] + end + end + + # Play a game of Trap the Cap. If players make illegal moves, disqualify them and restart the game. + # Terminate the game if there's a winner, there's only one player left, + # or the game has gone on too long. + def play + while @game.history.length < @limit + roll = rand(6) + 1 + move_to_apply = @named_players[@game.current_player].best_move(@game, roll) + puts "Move #{@game.history.length + 1}: Player #{@game.current_player} rolled #{roll}: making move #{move_to_apply}" if @verbose + @game.apply_moves! [move_to_apply] + puts @game if @very_verbose + end + puts "Game terminated after #{@game.history.length} moves" if @verbose + [:draw, @limit] + rescue GameWonNotice => win_notification + winner = win_notification.message[-1,1] + puts "Game won by #{winner} in #{@game.history.length} moves" if @verbose + [@named_players[winner], @game.history.length] + rescue InvalidCaptureError, InvalidMoveError + puts "Disqualifying player #{@game.current_player}" if @verbose + @named_players.delete @game.current_player + if @named_players.length > 1 + retry + else + puts "Game won by #{@named_players.keys[0]} by default" if @verbose + [@named_players[@named_players.keys[0]], 0] + end + end +end + \ No newline at end of file diff --git a/src/sample-game.txt b/src/sample-game.txt new file mode 100644 index 0000000..9cffeaf --- /dev/null +++ b/src/sample-game.txt @@ -0,0 +1,8 @@ +3 +A1 AC2 +C4 B5 +E1 EC5 +E2 E3 +A1 EC5 +C4 B2 +4 \ No newline at end of file diff --git a/src/selection.rb b/src/selection.rb new file mode 100644 index 0000000..7422a7d --- /dev/null +++ b/src/selection.rb @@ -0,0 +1,78 @@ +# == Synopsis +# +# Use a GA to breed a good potential player +# +# == Author +# Neil Smith +# +# == Change history +# Version 1.1:: 23 April 2008 + + +require 'libttc' +require 'libpplayer' +require 'libgenetics' +require 'play' + +class Population + # Use tournament selection to pick an individual for the next generation + def tournament_select_one(winner_success_chance = 0.8, max_game_length= 1000, verbose = false) + player_count = rand(5) + 2 + pool_size = @individuals.length + players = [] + 1.upto(player_count) { players << @individuals[rand(pool_size)].to_potential_player } + game = GameHandler.new(players, max_game_length, false, false) + winner, length = game.play + puts "Winner = #{winner} in #{length} moves. Game had #{player_count} players" if verbose + # If the game was a draw, or the winner is unlucky, pick a parent at random + if winner == :draw or rand > winner_success_chance + successful_player = players[rand(player_count)] + else + successful_player = winner + end + successful_player + end + + # Select a new population the same size as the current population + def tournament_select_population(winner_success_chance = 0.8, max_game_length = 1000, verbose = false) + new_population = [] + 1.upto(@individuals.length) do + new_population << tournament_select_one(winner_success_chance, max_game_length, verbose).to_genome + puts "Created #{new_population.length} indivduals" if verbose + end + new_population + end + +end + +class Potential_player + # Convert a player to a bitstring + def to_bitstring + (@friend_pull * 4).to_i.to_bitstring(4).gray_encode + + (@enemy_pull * 4).to_i.to_bitstring(4).gray_encode + + (@base_pull * 4).to_i.to_bitstring(4).gray_encode + + @safe_bonus.to_bitstring(4).gray_encode + + @capture_bonus.to_bitstring(4).gray_encode + end + + # Convert a player to a genome + def to_genome + Genome.new(self.to_bitstring) + end +end + + +class Genome + + # Create a potential player from a genome + def to_potential_player + friend_pull = @genome[0, 4].gray_decode.to_decimal.to_f / 4 + enemy_pull = @genome[4, 4].gray_decode.to_decimal.to_f / 4 + base_pull = @genome[8, 4].gray_decode.to_decimal.to_f / 4 + safe_bonus = @genome[12, 4].gray_decode.to_decimal + capture_bonus = @genome[16, 4].gray_decode.to_decimal + Potential_player.new({:friend_pull => friend_pull, + :enemy_pull => enemy_pull, :base_pull => base_pull, + :safe_bonus => safe_bonus, :capture_bonus => capture_bonus}) + end +end diff --git a/src/ttc-ga-clustering.rb b/src/ttc-ga-clustering.rb new file mode 100755 index 0000000..6396d06 --- /dev/null +++ b/src/ttc-ga-clustering.rb @@ -0,0 +1,27 @@ +require '/home/neil/programming/ruby/programming-collective/intelligence/k-means-clustering' + +def read_genome_file(filename) + genomes = [] + IO.foreach(filename) { |line| genomes << line.chomp.split('').collect {|i| i.to_i} } + genomes +end + +def find_centroid_sets(rows, k = 10, n = 10) + centroid_set = [] + 1.upto(n) do + centroid_set << (k_means_cluster(rows, k, :domain => :discrete) {|x, y| hamming_distance x, y}) + end + centroid_set +end + +def order_centroids_by_cluster_size(centroids, rows) + clusters = clusters_of_centroids(centroids, rows) {|x, y| hamming_distance x, y} + cluster_sizes = clusters.collect {|c| c.length} + sized_centroids = centroid.zip(cluster_sizes) + sorted_sized_centroids = (sized_centroids.sort_by {|t| t[1]}).reverse +end + +def best_centroids(centroid_set) + centroid_set.collect {|tc| tc[0][0]} +end + \ No newline at end of file diff --git a/src/ttc.rb b/src/ttc.rb new file mode 100644 index 0000000..9526d54 --- /dev/null +++ b/src/ttc.rb @@ -0,0 +1,36 @@ +#!/usr/bin/ruby -w +# +# == Synopsis +# +# Play one move of a Trap the Cap game +# +# == Usage +# ttc [ -b | --board-size SIZE ] [ -i | --input FILE ] [ -r | --robot ROBOT ] [ -h | --help ] +# +# == Author +# Neil Smith + +require File.join(File.dirname(__FILE__), '..', 'lib', 'libttc') +require 'open3' +require 'timeout' +require 'optparse' +require 'rdoc/usage' + + +class InvalidRobotError < StandardError +end + +class NoInputFileError < StandardError +end + +class InvalidMoveInHistoryError < StandardError +end + +class GameWonInHistoryError < StandardError +end + + + +board = Board.new(6, 5, 6) +puts board + diff --git a/systemu.rb b/systemu.rb new file mode 100644 index 0000000..27c0323 --- /dev/null +++ b/systemu.rb @@ -0,0 +1,299 @@ +# vim: ts=2:sw=2:sts=2:et:fdm=marker +require 'tmpdir' +require 'socket' +require 'fileutils' +require 'rbconfig' +require 'thread' +require 'yaml' + +class Object + def systemu(*a, &b) SystemUniversal.new(*a, &b).systemu end +end + +class SystemUniversal +# +# constants +# + SystemUniversal::VERSION = '1.2.0' unless defined? SystemUniversal::VERSION + def version() SystemUniversal::VERSION end +# +# class methods +# + + @host = Socket.gethostname + @ppid = Process.ppid + @pid = Process.pid + @turd = ENV['SYSTEMU_TURD'] + + c = ::Config::CONFIG + ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT'] + @ruby = if system('%s -e 42' % ruby) + ruby + else + system('%s -e 42' % 'ruby') ? 'ruby' : warn('no ruby in PATH/CONFIG') + end + + class << self + %w( host ppid pid ruby turd ).each{|a| attr_accessor a} + end + +# +# instance methods +# + + def initialize argv, opts = {}, &block + getopt = getopts opts + + @argv = argv + @block = block + + @stdin = getopt[ ['stdin', 'in', '0', 0] ] + @stdout = getopt[ ['stdout', 'out', '1', 1] ] + @stderr = getopt[ ['stderr', 'err', '2', 2] ] + @env = getopt[ 'env' ] + @cwd = getopt[ 'cwd' ] + + @host = getopt[ 'host', self.class.host ] + @ppid = getopt[ 'ppid', self.class.ppid ] + @pid = getopt[ 'pid', self.class.pid ] + @ruby = getopt[ 'ruby', self.class.ruby ] + end + + def systemu + tmpdir do |tmp| + c = child_setup tmp + status = nil + + begin + thread = nil + + quietly{ + IO.popen "#{ @ruby } #{ c['program'] }", 'r+' do |pipe| + line = pipe.gets + case line + when %r/^pid: \d+$/ + cid = Integer line[%r/\d+/] + else + begin + buf = pipe.read + buf = "#{ line }#{ buf }" + e = Marshal.load buf + raise unless Exception === e + raise e + rescue + raise "wtf?\n#{ buf }\n" + end + end + thread = new_thread cid, @block if @block + pipe.read rescue nil + end + } + status = $? + ensure + if thread + begin + class << status + attr 'thread' + end + status.instance_eval{ @thread = thread } + rescue + 42 + end + end + end + + if @stdout or @stderr + open(c['stdout']){|f| relay f => @stdout} if @stdout + open(c['stderr']){|f| relay f => @stderr} if @stderr + status + else + [status, IO.read(c['stdout']), IO.read(c['stderr'])] + end + end + end + + def new_thread cid, block + q = Queue.new + Thread.new(cid) do |cid| + current = Thread.current + current.abort_on_exception = true + q.push current + block.call cid + end + q.pop + end + + def child_setup tmp + stdin = File.expand_path(File.join(tmp, 'stdin')) + stdout = File.expand_path(File.join(tmp, 'stdout')) + stderr = File.expand_path(File.join(tmp, 'stderr')) + program = File.expand_path(File.join(tmp, 'program')) + config = File.expand_path(File.join(tmp, 'config')) + + if @stdin + open(stdin, 'w'){|f| relay @stdin => f} + else + FileUtils.touch stdin + end + FileUtils.touch stdout + FileUtils.touch stderr + + c = {} + c['argv'] = @argv + c['env'] = @env + c['cwd'] = @cwd + c['stdin'] = stdin + c['stdout'] = stdout + c['stderr'] = stderr + c['program'] = program + open(config, 'w'){|f| YAML.dump c, f} + + open(program, 'w'){|f| f.write child_program(config)} + + c + end + + def quietly + v = $VERBOSE + $VERBOSE = nil + yield + ensure + $VERBOSE = v + end + + def child_program config + <<-program + PIPE = STDOUT.dup + begin + require 'yaml' + + config = YAML.load(IO.read('#{ config }')) + + argv = config['argv'] + env = config['env'] + cwd = config['cwd'] + stdin = config['stdin'] + stdout = config['stdout'] + stderr = config['stderr'] + + Dir.chdir cwd if cwd + env.each{|k,v| ENV[k.to_s] = v.to_s} if env + + STDIN.reopen stdin + STDOUT.reopen stdout + STDERR.reopen stderr + + PIPE.puts "pid: \#{ Process.pid }" + PIPE.flush ### the process is ready yo! + PIPE.close + + exec *argv + rescue Exception => e + PIPE.write Marshal.dump(e) rescue nil + exit 42 + end + program + end + + def relay srcdst + src, dst, ignored = srcdst.to_a.first + if src.respond_to? 'read' + while((buf = src.read(8192))); dst << buf; end + else + src.each{|buf| dst << buf} + end + end + + def tmpdir d = Dir.tmpdir, max = 42, &b + i = -1 and loop{ + i += 1 + + tmp = File.join d, "systemu_#{ @host }_#{ @ppid }_#{ @pid }_#{ rand }_#{ i += 1 }" + + begin + Dir.mkdir tmp + rescue Errno::EEXIST + raise if i >= max + next + end + + break( + if b + begin + b.call tmp + ensure + FileUtils.rm_rf tmp unless SystemU.turd + end + else + tmp + end + ) + } + end + + def getopts opts = {} + lambda do |*args| + keys, default, ignored = args + catch('opt') do + [keys].flatten.each do |key| + [key, key.to_s, key.to_s.intern].each do |key| + throw 'opt', opts[key] if opts.has_key?(key) + end + end + default + end + end + end +end + +SystemU = SystemUniversal unless defined? SystemU + + + + + + + + + + + + + +if $0 == __FILE__ +# +# date +# + date = %q( ruby -e" t = Time.now; STDOUT.puts t; STDERR.puts t " ) + + status, stdout, stderr = systemu date + p [status, stdout, stderr] + + status = systemu date, 1=>(stdout = '') + p [status, stdout] + + status = systemu date, 2=>(stderr = '') + p [status, stderr] +# +# sleep +# + sleep = %q( ruby -e" p(sleep(1)) " ) + status, stdout, stderr = systemu sleep + p [status, stdout, stderr] + + sleep = %q( ruby -e" p(sleep(42)) " ) + status, stdout, stderr = systemu(sleep){|cid| Process.kill 9, cid} + p [status, stdout, stderr] +# +# env +# + env = %q( ruby -e" p ENV['A'] " ) + status, stdout, stderr = systemu env, :env => {'A' => 42} + p [status, stdout, stderr] +# +# cwd +# + env = %q( ruby -e" p Dir.pwd " ) + status, stdout, stderr = systemu env, :cwd => Dir.tmpdir + p [status, stdout, stderr] +end diff --git a/test/.svn/all-wcprops b/test/.svn/all-wcprops new file mode 100644 index 0000000..bd72261 --- /dev/null +++ b/test/.svn/all-wcprops @@ -0,0 +1,11 @@ +K 25 +svn:wc:ra_dav:version-url +V 43 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/test +END +libttc_test.rb +K 25 +svn:wc:ra_dav:version-url +V 58 +/svn/njae/!svn/ver/24/TrapTheCap/trunk/test/libttc_test.rb +END diff --git a/test/.svn/entries b/test/.svn/entries new file mode 100644 index 0000000..367750e --- /dev/null +++ b/test/.svn/entries @@ -0,0 +1,40 @@ +8 + +dir +68 +http://scripts.njae.me.uk/svn/njae/TrapTheCap/trunk/test +http://scripts.njae.me.uk/svn/njae + + + +2008-03-28T15:47:09.723420Z +24 +neil + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +0ada9808-85ab-4924-adda-5bf89eae3818 + +libttc_test.rb +file + + + + +2008-03-26T13:52:59.000000Z +0b82863be49d0bcbd00bcedb9db8a1e4 +2008-03-28T15:47:09.723420Z +24 +neil + diff --git a/test/.svn/format b/test/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/test/.svn/format @@ -0,0 +1 @@ +8 diff --git a/test/.svn/text-base/libttc_test.rb.svn-base b/test/.svn/text-base/libttc_test.rb.svn-base new file mode 100644 index 0000000..8a7ada5 --- /dev/null +++ b/test/.svn/text-base/libttc_test.rb.svn-base @@ -0,0 +1,976 @@ +# test/game_test.rb +require File.join(File.dirname(__FILE__), '..', 'lib', 'libttc') +require 'test/unit' + +class GameTest < Test::Unit::TestCase + + def test_init + assert_nothing_raised { Game.new(6,6,6,6,6) } + assert_equal [], Game.new(6,6,6,6,6).history + end + + + def test_game_init + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + end + + + def test_single_moves_1 + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + assert_raise(InvalidMoveError) {game.apply_move!(moveA1A5, 'b')} + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + end + + def test_separate_moves + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A3, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + end + + + + def test_captures + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A5, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + end + + + def test_no_captures_on_safe_spaces + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA2A4, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A4, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a4'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + end + + def test_move_after_captures + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A5, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveA2A4, 'a') + assert_equal game.history.length, 3 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveB2A3, 'b') + assert_equal game.history.length, 4 + assert_equal game.pieces['a1'].position, game.board.positions['a3'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + end + + + def test_game + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A3 = Move.new(pieceA1, posA3) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A3, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA2A4, 'a') + assert_equal game.history.length, 3 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A5, 'b') + assert_equal game.history.length, 4 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + assert_raise(InvalidMoveError) {game.apply_move!(moveA1A3, 'a')} + assert_equal game.history.length, 4 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveA2A3, 'a') + assert_equal game.history.length, 5 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a3'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveB2A4, 'b') + assert_equal game.history.length, 6 + assert_equal game.pieces['a1'].position, game.board.positions['a4'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a3'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a4'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveA2A4, 'a') + assert_equal game.history.length, 7 + assert_equal game.pieces['a1'].position, game.board.positions['a4'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a4'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveB2A3, 'b') + assert_equal game.history.length, 8 + assert_equal game.pieces['a1'].position, game.board.positions['a3'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveA2A3, 'a') + assert_equal game.history.length, 9 + assert_equal game.pieces['a1'].position, game.board.positions['a3'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a3'] + assert_equal game.pieces['a2'].captured, false + assert game.pieces['a2'].contains.include?(pieceA1) + assert game.pieces['a2'].contains.include?(pieceB2) + assert_equal game.pieces['a2'].contains.length, 2 + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, true + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA2A, 'a') + assert_equal game.history.length, 10 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a'] + assert_equal game.pieces['b2'].captured, true + assert_equal game.pieces['b2'].contains, [] + end + + def test_apply_moves! + game = Game.new(3) + move_set = ['A1 A2', 'C1 C2', 'E1 E2'] + assert_nothing_raised { move_set.collect { |m| m.to_move(game) } } + move_set_m = move_set.collect { |m| m.to_move(game) } + assert_nothing_raised { game.apply_moves! move_set_m } + end + + def test_eliminations + game = Game.new(3, 6, 6, 6, 2) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceC1 = game.pieces['c1'] + pieceC2 = game.pieces['c2'] + pieceE1 = game.pieces['e1'] + pieceE2 = game.pieces['e2'] + + posAC5 = game.board.positions['ac5'] + posBC5 = game.board.positions['bc5'] + posCC5 = game.board.positions['cc5'] + posEC5 = game.board.positions['ec5'] + posAC6 = game.board.positions['ac6'] + + move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', + 'C1 CC5', 'C2 CC5', 'C1 AC6'] # A1 now captured by C1 + move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1 + move_set3 = ['A2 AC6'] # E1+C1+A1 captured by A2 + move_set4 = ['C2 AC6'] # A2+E1+C1+A1 captured by C2. Player A now eliminated + move_set5 = ['E2 BC5'] + move_set6 = ['C2 BC5'] # C2 (plus stack) captures E2. Player E now eliminated + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.apply_moves! move_set1.collect {|m| m.to_move(game)} + assert_equal game.history.length, 6 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, false + assert game.pieces['c1'].contains.include?(pieceA1) + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + game.apply_moves! move_set2.collect {|m| m.to_move(game)} + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, false + assert game.pieces['e1'].contains.include?(pieceA1) + assert game.pieces['e1'].contains.include?(pieceC1) + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.apply_moves! move_set3.collect {|m| m.to_move(game)} + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac6'] + assert_equal game.pieces['a2'].captured, false + assert game.pieces['a2'].contains.include?(pieceA1) + assert game.pieces['a2'].contains.include?(pieceC1) + assert game.pieces['a2'].contains.include?(pieceE1) + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, true + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'c' + + game.apply_moves! move_set4.collect {|m| m.to_move(game)} + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac6'] + assert_equal game.pieces['a2'].captured, true + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['ac6'] + assert_equal game.pieces['c2'].captured, false + assert game.pieces['c2'].contains.include?(pieceA1) + assert game.pieces['c2'].contains.include?(pieceA2) + assert game.pieces['c2'].contains.include?(pieceC1) + assert game.pieces['c2'].contains.include?(pieceE1) + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, true + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + game.apply_moves! move_set5.collect {|m| m.to_move(game)} + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac6'] + assert_equal game.pieces['a2'].captured, true + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['ac6'] + assert_equal game.pieces['c2'].captured, false + assert game.pieces['c2'].contains.include?(pieceA1) + assert game.pieces['c2'].contains.include?(pieceA2) + assert game.pieces['c2'].contains.include?(pieceC1) + assert game.pieces['c2'].contains.include?(pieceE1) + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, true + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['bc5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'c' + + assert_raise (GameWonNotice) { game.apply_moves! move_set6.collect {|m| m.to_move(game)} } + end + + def test_undo_move! + game = Game.new(3) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceC1 = game.pieces['c1'] + pieceC2 = game.pieces['c2'] + pieceE1 = game.pieces['e1'] + pieceE2 = game.pieces['e2'] + + assert_equal [], game.history + assert_equal game.pieces['a1'], pieceA1 + assert_equal game.pieces['a2'], pieceA2 + assert_equal game.pieces['c1'], pieceC1 + assert_equal game.pieces['c2'], pieceC2 + assert_equal game.pieces['e1'], pieceE1 + assert_equal game.pieces['e2'], pieceE2 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.undo_move! + assert_equal [], game.history + assert_equal game.pieces['a1'], pieceA1 + assert_equal game.pieces['a2'], pieceA2 + assert_equal game.pieces['c1'], pieceC1 + assert_equal game.pieces['c2'], pieceC2 + assert_equal game.pieces['e1'], pieceE1 + assert_equal game.pieces['e2'], pieceE2 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.apply_moves! ['A1 A3'].collect { |m| m.to_move(game) } + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'], pieceA1 + assert_equal game.pieces['a2'], pieceA2 + assert_equal game.pieces['c1'], pieceC1 + assert_equal game.pieces['c2'], pieceC2 + assert_equal game.pieces['e1'], pieceE1 + assert_equal game.pieces['e2'], pieceE2 + assert_equal game.pieces['a1'].position, game.board.positions['a3'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'c' + + game.undo_move! + assert_equal [], game.history + assert_equal game.pieces['a1'], pieceA1 + assert_equal game.pieces['a2'], pieceA2 + assert_equal game.pieces['c1'], pieceC1 + assert_equal game.pieces['c2'], pieceC2 + assert_equal game.pieces['e1'], pieceE1 + assert_equal game.pieces['e2'], pieceE2 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', + 'C1 CC5', 'C2 CC5', 'C1 AC6'] # A1 now captured by C1 + move_set1a = ['C1 AC6'] + move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1 + move_set2a = ['E1 AC6'] + + game.apply_moves! move_set1.collect {|m| m.to_move(game)} + assert_equal game.history.length, 6 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, false + assert game.pieces['c1'].contains.include?(pieceA1) + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + game.undo_move! + assert_equal game.history.length, 5 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['cc5'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'c' + + game.apply_moves! move_set1a.collect {|m| m.to_move(game)} + assert_equal game.history.length, 6 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, false + assert game.pieces['c1'].contains.include?(pieceA1) + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + game.apply_moves! move_set2.collect {|m| m.to_move(game)} + assert_equal game.history.length, 9 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, false + assert game.pieces['e1'].contains.include?(pieceA1) + assert game.pieces['e1'].contains.include?(pieceC1) + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.undo_move! + assert_equal game.history.length, 8 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].captured, false + assert game.pieces['c1'].contains.include?(pieceA1) + + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ec5'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + assert_equal game.pieces['c1'].position, game.pieces['a1'].position + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + + + game.apply_moves! move_set2a.collect {|m| m.to_move(game)} + assert_equal game.history.length, 9 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, false + assert game.pieces['e1'].contains.include?(pieceA1) + assert game.pieces['e1'].contains.include?(pieceC1) + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + end +end \ No newline at end of file diff --git a/test/libttc_test.rb b/test/libttc_test.rb new file mode 100644 index 0000000..8a7ada5 --- /dev/null +++ b/test/libttc_test.rb @@ -0,0 +1,976 @@ +# test/game_test.rb +require File.join(File.dirname(__FILE__), '..', 'lib', 'libttc') +require 'test/unit' + +class GameTest < Test::Unit::TestCase + + def test_init + assert_nothing_raised { Game.new(6,6,6,6,6) } + assert_equal [], Game.new(6,6,6,6,6).history + end + + + def test_game_init + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + end + + + def test_single_moves_1 + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + assert_raise(InvalidMoveError) {game.apply_move!(moveA1A5, 'b')} + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + end + + def test_separate_moves + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A3, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + end + + + + def test_captures + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A5, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + end + + + def test_no_captures_on_safe_spaces + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA2A4, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A4, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a4'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + end + + def test_move_after_captures + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A5, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveA2A4, 'a') + assert_equal game.history.length, 3 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveB2A3, 'b') + assert_equal game.history.length, 4 + assert_equal game.pieces['a1'].position, game.board.positions['a3'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + end + + + def test_game + game = Game.new(6,6,6,6,6) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceB2 = game.pieces['b2'] + + posA = game.board.positions['a'] + posB = game.board.positions['b'] + posA3 = game.board.positions['a3'] + posA4 = game.board.positions['a4'] + posA5 = game.board.positions['a5'] + + moveA2A = Move.new(pieceA2, posA , true) + moveA1A3 = Move.new(pieceA1, posA3) + moveA1A5 = Move.new(pieceA1, posA5) + moveA2A4 = Move.new(pieceA2, posA4) + moveA2A3 = Move.new(pieceA2, posA3) + moveB2A5 = Move.new(pieceB2, posA5) + moveB2A3 = Move.new(pieceB2, posA3) + moveB2A4 = Move.new(pieceB2, posA4) + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA1A5, 'a') + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['b'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A3, 'b') + assert_equal game.history.length, 2 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA2A4, 'a') + assert_equal game.history.length, 3 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveB2A5, 'b') + assert_equal game.history.length, 4 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + assert_raise(InvalidMoveError) {game.apply_move!(moveA1A3, 'a')} + assert_equal game.history.length, 4 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveA2A3, 'a') + assert_equal game.history.length, 5 + assert_equal game.pieces['a1'].position, game.board.positions['a5'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a3'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a5'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveB2A4, 'b') + assert_equal game.history.length, 6 + assert_equal game.pieces['a1'].position, game.board.positions['a4'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a3'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a4'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveA2A4, 'a') + assert_equal game.history.length, 7 + assert_equal game.pieces['a1'].position, game.board.positions['a4'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a4'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveB2A3, 'b') + assert_equal game.history.length, 8 + assert_equal game.pieces['a1'].position, game.board.positions['a3'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a4'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, false + assert game.pieces['b2'].contains.include?(pieceA1) + assert_equal game.pieces['b2'].contains.length, 1 + + game.apply_move!(moveA2A3, 'a') + assert_equal game.history.length, 9 + assert_equal game.pieces['a1'].position, game.board.positions['a3'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a3'] + assert_equal game.pieces['a2'].captured, false + assert game.pieces['a2'].contains.include?(pieceA1) + assert game.pieces['a2'].contains.include?(pieceB2) + assert_equal game.pieces['a2'].contains.length, 2 + assert_equal game.pieces['b2'].position, game.board.positions['a3'] + assert_equal game.pieces['b2'].captured, true + assert_equal game.pieces['b2'].contains, [] + + game.apply_move!(moveA2A, 'a') + assert_equal game.history.length, 10 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['b2'].position, game.board.positions['a'] + assert_equal game.pieces['b2'].captured, true + assert_equal game.pieces['b2'].contains, [] + end + + def test_apply_moves! + game = Game.new(3) + move_set = ['A1 A2', 'C1 C2', 'E1 E2'] + assert_nothing_raised { move_set.collect { |m| m.to_move(game) } } + move_set_m = move_set.collect { |m| m.to_move(game) } + assert_nothing_raised { game.apply_moves! move_set_m } + end + + def test_eliminations + game = Game.new(3, 6, 6, 6, 2) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceC1 = game.pieces['c1'] + pieceC2 = game.pieces['c2'] + pieceE1 = game.pieces['e1'] + pieceE2 = game.pieces['e2'] + + posAC5 = game.board.positions['ac5'] + posBC5 = game.board.positions['bc5'] + posCC5 = game.board.positions['cc5'] + posEC5 = game.board.positions['ec5'] + posAC6 = game.board.positions['ac6'] + + move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', + 'C1 CC5', 'C2 CC5', 'C1 AC6'] # A1 now captured by C1 + move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1 + move_set3 = ['A2 AC6'] # E1+C1+A1 captured by A2 + move_set4 = ['C2 AC6'] # A2+E1+C1+A1 captured by C2. Player A now eliminated + move_set5 = ['E2 BC5'] + move_set6 = ['C2 BC5'] # C2 (plus stack) captures E2. Player E now eliminated + + assert_equal [], game.history + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.apply_moves! move_set1.collect {|m| m.to_move(game)} + assert_equal game.history.length, 6 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, false + assert game.pieces['c1'].contains.include?(pieceA1) + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + game.apply_moves! move_set2.collect {|m| m.to_move(game)} + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, false + assert game.pieces['e1'].contains.include?(pieceA1) + assert game.pieces['e1'].contains.include?(pieceC1) + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.apply_moves! move_set3.collect {|m| m.to_move(game)} + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac6'] + assert_equal game.pieces['a2'].captured, false + assert game.pieces['a2'].contains.include?(pieceA1) + assert game.pieces['a2'].contains.include?(pieceC1) + assert game.pieces['a2'].contains.include?(pieceE1) + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, true + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'c' + + game.apply_moves! move_set4.collect {|m| m.to_move(game)} + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac6'] + assert_equal game.pieces['a2'].captured, true + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['ac6'] + assert_equal game.pieces['c2'].captured, false + assert game.pieces['c2'].contains.include?(pieceA1) + assert game.pieces['c2'].contains.include?(pieceA2) + assert game.pieces['c2'].contains.include?(pieceC1) + assert game.pieces['c2'].contains.include?(pieceE1) + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, true + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + game.apply_moves! move_set5.collect {|m| m.to_move(game)} + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac6'] + assert_equal game.pieces['a2'].captured, true + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['ac6'] + assert_equal game.pieces['c2'].captured, false + assert game.pieces['c2'].contains.include?(pieceA1) + assert game.pieces['c2'].contains.include?(pieceA2) + assert game.pieces['c2'].contains.include?(pieceC1) + assert game.pieces['c2'].contains.include?(pieceE1) + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, true + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['bc5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'c' + + assert_raise (GameWonNotice) { game.apply_moves! move_set6.collect {|m| m.to_move(game)} } + end + + def test_undo_move! + game = Game.new(3) + + pieceA1 = game.pieces['a1'] + pieceA2 = game.pieces['a2'] + pieceC1 = game.pieces['c1'] + pieceC2 = game.pieces['c2'] + pieceE1 = game.pieces['e1'] + pieceE2 = game.pieces['e2'] + + assert_equal [], game.history + assert_equal game.pieces['a1'], pieceA1 + assert_equal game.pieces['a2'], pieceA2 + assert_equal game.pieces['c1'], pieceC1 + assert_equal game.pieces['c2'], pieceC2 + assert_equal game.pieces['e1'], pieceE1 + assert_equal game.pieces['e2'], pieceE2 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.undo_move! + assert_equal [], game.history + assert_equal game.pieces['a1'], pieceA1 + assert_equal game.pieces['a2'], pieceA2 + assert_equal game.pieces['c1'], pieceC1 + assert_equal game.pieces['c2'], pieceC2 + assert_equal game.pieces['e1'], pieceE1 + assert_equal game.pieces['e2'], pieceE2 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.apply_moves! ['A1 A3'].collect { |m| m.to_move(game) } + assert_equal game.history.length, 1 + assert_equal game.pieces['a1'], pieceA1 + assert_equal game.pieces['a2'], pieceA2 + assert_equal game.pieces['c1'], pieceC1 + assert_equal game.pieces['c2'], pieceC2 + assert_equal game.pieces['e1'], pieceE1 + assert_equal game.pieces['e2'], pieceE2 + assert_equal game.pieces['a1'].position, game.board.positions['a3'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'c' + + game.undo_move! + assert_equal [], game.history + assert_equal game.pieces['a1'], pieceA1 + assert_equal game.pieces['a2'], pieceA2 + assert_equal game.pieces['c1'], pieceC1 + assert_equal game.pieces['c2'], pieceC2 + assert_equal game.pieces['e1'], pieceE1 + assert_equal game.pieces['e2'], pieceE2 + assert_equal game.pieces['a1'].position, game.board.positions['a'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['a'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['c'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['c'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', + 'C1 CC5', 'C2 CC5', 'C1 AC6'] # A1 now captured by C1 + move_set1a = ['C1 AC6'] + move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1 + move_set2a = ['E1 AC6'] + + game.apply_moves! move_set1.collect {|m| m.to_move(game)} + assert_equal game.history.length, 6 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, false + assert game.pieces['c1'].contains.include?(pieceA1) + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + game.undo_move! + assert_equal game.history.length, 5 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, false + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['cc5'] + assert_equal game.pieces['c1'].captured, false + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'c' + + game.apply_moves! move_set1a.collect {|m| m.to_move(game)} + assert_equal game.history.length, 6 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, false + assert game.pieces['c1'].contains.include?(pieceA1) + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['e'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['e'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + game.apply_moves! move_set2.collect {|m| m.to_move(game)} + assert_equal game.history.length, 9 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, false + assert game.pieces['e1'].contains.include?(pieceA1) + assert game.pieces['e1'].contains.include?(pieceC1) + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + game.undo_move! + assert_equal game.history.length, 8 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].captured, false + assert game.pieces['c1'].contains.include?(pieceA1) + + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ec5'] + assert_equal game.pieces['e1'].captured, false + assert_equal game.pieces['e1'].contains, [] + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'e' + + assert_equal game.pieces['c1'].position, game.pieces['a1'].position + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + + + game.apply_moves! move_set2a.collect {|m| m.to_move(game)} + assert_equal game.history.length, 9 + assert_equal game.pieces['a1'].position, game.board.positions['ac6'] + assert_equal game.pieces['a1'].captured, true + assert_equal game.pieces['a1'].contains, [] + assert_equal game.pieces['a2'].position, game.board.positions['ac5'] + assert_equal game.pieces['a2'].captured, false + assert_equal game.pieces['a2'].contains, [] + assert_equal game.pieces['c1'].position, game.board.positions['ac6'] + assert_equal game.pieces['c1'].captured, true + assert_equal game.pieces['c1'].contains, [] + assert_equal game.pieces['c2'].position, game.board.positions['cc5'] + assert_equal game.pieces['c2'].captured, false + assert_equal game.pieces['c2'].contains, [] + assert_equal game.pieces['e1'].position, game.board.positions['ac6'] + assert_equal game.pieces['e1'].captured, false + assert game.pieces['e1'].contains.include?(pieceA1) + assert game.pieces['e1'].contains.include?(pieceC1) + assert_equal game.pieces['e2'].position, game.board.positions['ec5'] + assert_equal game.pieces['e2'].captured, false + assert_equal game.pieces['e2'].contains, [] + assert_equal game.current_player, 'a' + + end +end \ No newline at end of file