gambit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. data/AUTHORS +2 -0
  2. data/CHANGELOG +7 -0
  3. data/COPYING +340 -0
  4. data/INSTALL +23 -0
  5. data/LICENSE +7 -0
  6. data/README +25 -0
  7. data/Rakefile +87 -0
  8. data/TODO +6 -0
  9. data/examples/bird_wars/game.rb +434 -0
  10. data/examples/bird_wars/html/chest.rhtml +37 -0
  11. data/examples/bird_wars/html/combat.rhtml +38 -0
  12. data/examples/bird_wars/html/fight.rhtml +71 -0
  13. data/examples/bird_wars/html/fridge.rhtml +31 -0
  14. data/examples/bird_wars/html/help.rhtml +30 -0
  15. data/examples/bird_wars/html/house.rhtml +36 -0
  16. data/examples/bird_wars/html/images/albatross.jpg +0 -0
  17. data/examples/bird_wars/html/images/alka_seltzer_small.png +0 -0
  18. data/examples/bird_wars/html/images/bazooka_small.png +0 -0
  19. data/examples/bird_wars/html/images/bb_gun_small.png +0 -0
  20. data/examples/bird_wars/html/images/cat_small.png +0 -0
  21. data/examples/bird_wars/html/images/combat.png +0 -0
  22. data/examples/bird_wars/html/images/crossbow_small.png +0 -0
  23. data/examples/bird_wars/html/images/cuckoo.jpg +0 -0
  24. data/examples/bird_wars/html/images/fridge.png +0 -0
  25. data/examples/bird_wars/html/images/gull.jpg +0 -0
  26. data/examples/bird_wars/html/images/house.jpg +0 -0
  27. data/examples/bird_wars/html/images/items.png +0 -0
  28. data/examples/bird_wars/html/images/not_found.png +0 -0
  29. data/examples/bird_wars/html/images/note.jpg +0 -0
  30. data/examples/bird_wars/html/images/oil_small.png +0 -0
  31. data/examples/bird_wars/html/images/one_stone_small.png +0 -0
  32. data/examples/bird_wars/html/images/owl.jpg +0 -0
  33. data/examples/bird_wars/html/images/poisoned_seeds_small.png +0 -0
  34. data/examples/bird_wars/html/images/rice_small.png +0 -0
  35. data/examples/bird_wars/html/images/shotgun_small.png +0 -0
  36. data/examples/bird_wars/html/images/slingshot_small.png +0 -0
  37. data/examples/bird_wars/html/images/soda_rings_small.png +0 -0
  38. data/examples/bird_wars/html/images/spear_small.png +0 -0
  39. data/examples/bird_wars/html/images/stork.jpg +0 -0
  40. data/examples/bird_wars/html/images/weapons.png +0 -0
  41. data/examples/bird_wars/html/images/woodpecker.jpg +0 -0
  42. data/examples/bird_wars/html/images/you.jpg +0 -0
  43. data/examples/bird_wars/html/index.rhtml +13 -0
  44. data/examples/bird_wars/html/weapons.rhtml +35 -0
  45. data/examples/cli/blackjack.rb +86 -0
  46. data/examples/cli/go.rb +93 -0
  47. data/examples/cli/space_trader2/planet_data +12280 -0
  48. data/examples/cli/space_trader2/space_trader2.rb +248 -0
  49. data/examples/cli/space_trader2/world.rb +127 -0
  50. data/examples/cli/spacetrader.rb +262 -0
  51. data/examples/cli/yahtzee.rb +161 -0
  52. data/examples/galactic_courier/Rakefile +9 -0
  53. data/examples/galactic_courier/bin/galactic_courier.rb +44 -0
  54. data/examples/galactic_courier/html/console.rhtml +15 -0
  55. data/examples/galactic_courier/html/images/barren.jpg +0 -0
  56. data/examples/galactic_courier/html/images/industrial.jpg +0 -0
  57. data/examples/galactic_courier/html/images/jungle.jpg +0 -0
  58. data/examples/galactic_courier/html/images/oceanic.jpg +0 -0
  59. data/examples/galactic_courier/html/images/tundra.jpg +0 -0
  60. data/examples/galactic_courier/html/images/volcanic.jpg +0 -0
  61. data/examples/galactic_courier/lib/galaxy.rb +64 -0
  62. data/examples/galactic_courier/lib/planet.rb +30 -0
  63. data/examples/galactic_courier/lib/sector.rb +84 -0
  64. data/examples/galactic_courier/lib/station.rb +18 -0
  65. data/examples/galactic_courier/test/tc_galaxy.rb +24 -0
  66. data/examples/galactic_courier/test/tc_planet.rb +22 -0
  67. data/examples/galactic_courier/test/tc_sector.rb +55 -0
  68. data/examples/galactic_courier/test/ts_all.rb +12 -0
  69. data/examples/gambit_mail/html/compose.rhtml +39 -0
  70. data/examples/gambit_mail/html/index.rhtml +3 -0
  71. data/examples/gambit_mail/html/mailbox.rhtml +47 -0
  72. data/examples/gambit_mail/html/message.rhtml +34 -0
  73. data/examples/gambit_mail/mail.rb +75 -0
  74. data/lib/gambit.rb +10 -0
  75. data/lib/gambit/server.rb +269 -0
  76. data/lib/gambit/server/gambiterror.rb +28 -0
  77. data/lib/gambit/server/game.rb +185 -0
  78. data/lib/gambit/server/game/eventform.rb +174 -0
  79. data/lib/gambit/server/message.rb +85 -0
  80. data/lib/gambit/server/player.rb +40 -0
  81. data/lib/gambit/tools.rb +13 -0
  82. data/lib/gambit/tools/board.rb +275 -0
  83. data/lib/gambit/tools/cards.rb +11 -0
  84. data/lib/gambit/tools/cards/card.rb +158 -0
  85. data/lib/gambit/tools/cards/deck.rb +99 -0
  86. data/lib/gambit/tools/cards/hand.rb +86 -0
  87. data/lib/gambit/tools/cards/pile.rb +107 -0
  88. data/lib/gambit/tools/currency.rb +148 -0
  89. data/lib/gambit/tools/dice.rb +219 -0
  90. data/lib/gambit/tools/movehistory.rb +164 -0
  91. data/lib/gambit/tools/scorecard.rb +333 -0
  92. data/lib/gambit/viewable.rb +71 -0
  93. data/setup.rb +1360 -0
  94. data/test/tc_board.rb +167 -0
  95. data/test/tc_cards.rb +182 -0
  96. data/test/tc_currency.rb +99 -0
  97. data/test/tc_dice.rb +83 -0
  98. data/test/tc_error.rb +34 -0
  99. data/test/tc_event.rb +367 -0
  100. data/test/tc_game.rb +29 -0
  101. data/test/tc_message.rb +35 -0
  102. data/test/tc_movehistory.rb +38 -0
  103. data/test/tc_player.rb +60 -0
  104. data/test/tc_scorecard.rb +112 -0
  105. data/test/tc_views.rb +353 -0
  106. data/test/test_game.rb +19 -0
  107. data/test/test_view.rhtml +2 -0
  108. data/test/ts_all.rb +12 -0
  109. data/test/ts_server.rb +14 -0
  110. data/test/ts_tools.rb +14 -0
  111. metadata +183 -0
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=ISO-8859-1"
5
+ http-equiv="content-type">
6
+ <style>
7
+ ul { list-style: none; margin: 0 0 30 0; padding: 0px; height: 25px; }
8
+ </style>
9
+ <title>The Battlefield</title>
10
+ </head>
11
+ <body style="background-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"
12
+ alink="#ffffff" link="#ffffff" vlink="#ffffff">
13
+ <div style="text-align: center;"><br>
14
+ <img src="images/combat.png" width="600" height="441" border="0"
15
+ usemap="#map" />
16
+ <map name="map">
17
+ <area shape="rect" coords="256,384,428,431"
18
+ href="<%= event(nil, "begin_combat") %>" />
19
+ <area shape="rect" coords="164,70,258,165"
20
+ href="<%= event(nil, "set_enemy", "enemy" => "woodpecker") %>" />
21
+ <area shape="rect" coords="294,66,390,167"
22
+ href="<%= event(nil, "set_enemy", "enemy" => "gull") %>" />
23
+ <area shape="rect" coords="418,75,514,167"
24
+ href="<%= event(nil, "set_enemy", "enemy" => "stork") %>" />
25
+ <area shape="rect" coords="157,295,252,387"
26
+ href="<%= event(nil, "set_enemy", "enemy" => "owl") %>" />
27
+ <area shape="rect" coords="294,293,387,379"
28
+ href="<%= event(nil, "set_enemy", "enemy" => "cuckoo") %>" />
29
+ <area shape="rect" coords="417,296,511,379"
30
+ href="<%= event(nil, "set_enemy", "enemy" => "albatross") %>" />
31
+ </map>
32
+ <br>
33
+ <br>
34
+ <%= view(:info_panel) %>
35
+ <br>
36
+ </div>
37
+ </body>
38
+ </html>
@@ -0,0 +1,71 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=ISO-8859-1"
5
+ http-equiv="content-type">
6
+ <style>
7
+ ul { list-style: none; margin: 0 0 30 0; padding: 0px; height: 25px; }
8
+ </style>
9
+ <title>Ron Martin's Home</title>
10
+ </head>
11
+ <body style="background-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"
12
+ alink="#000000" link="#000000" vlink="#000000">
13
+ <div style="text-align: center;">
14
+ <table
15
+ style="margin-left: auto; margin-right: auto; text-align: left; width: 647px;
16
+ height: 76px;" border="0" cellpadding="2" cellspacing="2">
17
+ <tbody>
18
+ <tr align="center">
19
+ <td style="background-color: rgb(204, 204, 204); vertical-align: top;">
20
+ <big><big><big>Bird Wars: Combat Mode</big></big></big><br>
21
+ </td>
22
+ </tr>
23
+ <tr>
24
+ <td style="background-color: rgb(255, 255, 255); vertical-align: top;">
25
+ <div style="text-align: center;"><br>
26
+ You have now entered heated battle with the mighty
27
+ <%= @player[:combat][:enemy][:name].capitalize %><br>
28
+ <br>
29
+ </div>
30
+ <table style="width: 100%; text-align: left;" border="1" cellpadding="2"
31
+ cellspacing="2">
32
+ <tbody>
33
+ <tr>
34
+ <td style="vertical-align: top; text-align: center;"><br>
35
+ <%= @player[:combat][:enemy][:name].capitalize %>: <br>
36
+ <img alt="" src="images/<%= @player[:combat][:enemy][:name] %>.jpg"><br>
37
+ </td>
38
+ <td style="width: 50%; vertical-align: top; text-align: center;">
39
+ <br>You:<br>
40
+ <img src="images/you.jpg" style="width: 230px; height: 270px;"><br>
41
+ </td>
42
+ </tr>
43
+ <tr>
44
+ <td style="vertical-align: top; text-align: center;">
45
+ Enemy HP: <%= @player[:combat][:enemy][:health] %><br>
46
+ </td>
47
+ <td style="vertical-align: top; text-align: center;">
48
+ Your HP: <%= @player[:health] %> <br>
49
+ </td>
50
+ </tr>
51
+ </tbody>
52
+ </table>
53
+ <br>
54
+ </td>
55
+ </tr>
56
+ <tr>
57
+ <td style="background-color: rgb(153, 153, 153); vertical-align: top;">
58
+ <br><div style="text-align: center;"><%= event("Flee","flee") %> |
59
+ <%= event("Fight","fight") %>
60
+ <%= @player[:item].nil? ? "" : event("| Use Item","use_item") %><br>
61
+ </div>
62
+ <br>
63
+ </td>
64
+ </tr>
65
+ </tbody>
66
+ </table>
67
+ <br>
68
+ <%= view(:info_panel) %>
69
+ </div>
70
+ </body>
71
+ </html>
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=ISO-8859-1"
5
+ http-equiv="content-type">
6
+ <style>
7
+ ul { list-style: none; margin: 0 0 30 0; padding: 0px; height: 25px; }
8
+ </style>
9
+ <title>Ron Martin's Home</title>
10
+ </head>
11
+ <body style="background-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"
12
+ alink="#ffffff" link="#ffffff" vlink="#ffffff">
13
+ <div style="text-align: center;"><br>
14
+ <img src="images/fridge.png" width="600" height="441" border="0"
15
+ usemap="#map" />
16
+
17
+ <map name="map">
18
+ <area shape="rect" coords="130,123,339,327"
19
+ href="<%= event(nil,"get_food", "food" => "pizza") %>" />
20
+ <area shape="rect" coords="357,121,556,324"
21
+ href="<%= event(nil,"get_food", "food" => "pepsi") %>" />
22
+ <area shape="rect" coords="300,375,399,417"
23
+ href="<%= event(nil,"go","place" => "house") %>"/>
24
+ </map>
25
+ <br>
26
+ <br>
27
+ <%= view(:info_panel) %>
28
+ <br>
29
+ </div>
30
+ </body>
31
+ </html>
@@ -0,0 +1,30 @@
1
+ <html><head><title>Help: For Losers</title></head><body>
2
+
3
+ This game is not meant to be user friendly so you're lucky this page exists.<br>
4
+ Fridge has health objects, Chest has items to use (figure out what they do)<br>
5
+ Closet has weapons, collect Ron points to unlock.<br><br>
6
+
7
+ Take out the goddamn cans to fight the birds. <br>
8
+ You click the bird you want and then hit begin combat. <br><br>
9
+
10
+ You need to unlock the birds by beating other birds, so do the woodpecker first<br>
11
+ and work your way up. You can play earlier birds as many times as you want. <br>
12
+
13
+ Combat itself is self explanatory. Fight, Flee, or Use item. Once you use an <br>
14
+ item, it takes effect, and you lose it. You can get another item next battle.<br><br>
15
+
16
+ If you want to reload all the defaults (start a fresh game), click the calander<br>
17
+ If you want to lock the game, click the security panel<br><br>
18
+
19
+ This is a prototype application for a pre-alpha design library. If it breaks,<br>
20
+ don't be surprised.<br><br>
21
+
22
+ Neat way to cheat: /event/prototype/hack_your_events_here<br><br>
23
+
24
+ Don't get what I just said? Too bad. Have a Rontacular day.
25
+
26
+ </body></html>
27
+
28
+
29
+
30
+
@@ -0,0 +1,36 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=ISO-8859-1"
5
+ http-equiv="content-type">
6
+ <style>
7
+ ul { list-style: none; margin: 0 0 30 0; padding: 0px; height: 25px; }
8
+ </style>
9
+ <title>Ron Martin's Home</title>
10
+ </head>
11
+ <body style="background-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"
12
+ alink="#ffffff" link="#ffffff" vlink="#ffffff">
13
+ <div style="text-align: center;"><br>
14
+ <img src="images/house.jpg" width="600" height="441" border="0" usemap="#map" />
15
+ <map name="map">
16
+ <area shape="poly" coords="139,111,159,322,224,361,223,313,284,254,273,
17
+ 111,267,111"
18
+ href="<%= event(nil, "go", "place" => "fridge") %>" />
19
+ <area shape="poly" coords="326,332,322,54,448,53,440,266,408,268,404,362"
20
+ href="<%= event(nil, "go", "place" => "closet") %>" />
21
+ <area shape="poly" coords="287,257,226,314,226,366,273,373,327,343,319,254"
22
+ href="<%= event(nil, "go", "place" => "combat") %>" />
23
+ <area shape="poly" coords="460,90,459,189,539,193,546,82"
24
+ href="<%= event(nil, "reset") %>" />
25
+ <area shape="poly" coords="473,298,445,293,423,306,425,353,455,393,515,
26
+ 383,514,332,513,330,513,331,502,325"
27
+ href="<%= event(nil, "go", "place" => "chest") %>" />
28
+ </map>
29
+ <br>
30
+ <br>
31
+ <%= view(:info_panel) %>
32
+ <br>
33
+ <a href="stats.rhtml">STATISTICS</a>
34
+ </div>
35
+ </body>
36
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <title>Bird Wars</title>
5
+ </head>
6
+ <body style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);"
7
+ alink="#ffffff" link="#ffffff" vlink="#ffffff">
8
+ <div style="text-align: center;"><a href="<%= event(nil, "begin") %>"><img
9
+ alt="Note: If you can't read this. Leave now" src="images/note.jpg"
10
+ style="border: 0px solid ; width: 415px; height: 615px;"></a><br>
11
+ </div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,35 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=ISO-8859-1"
5
+ http-equiv="content-type">
6
+ <style> ul { float: top; list-style: none; margin: 0 0 30 0; height: 25px} </style>
7
+ <title>Ron Martin's Secret Stash</title>
8
+ </head>
9
+ <body style="background-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"
10
+ alink="#ffffff" link="#ffffff" vlink="#ffffff">
11
+ <div style="text-align: center;"><br>
12
+ <img src="images/weapons.png" width="600" height="441" border="0" usemap="#map" />
13
+
14
+ <map name="map">
15
+ <area shape="rect" coords="166,68,267,168"
16
+ href="<%= event(nil, "set_weapon", "weapon" => "spear") %>" />
17
+ <area shape="rect" coords="299,66,396,170"
18
+ href="<%= event(nil, "set_weapon", "weapon" => "slingshot") %>" />
19
+ <area shape="rect" coords="439,68,541,169"
20
+ href="<%= event(nil, "set_weapon", "weapon" => "crossbow") %>" />
21
+ <area shape="rect" coords="237,185,338,290"
22
+ href="<%= event(nil, "set_weapon", "weapon" => "bb_gun") %>" />
23
+ <area shape="rect" coords="364,185,473,289"
24
+ href="<%= event(nil, "set_weapon", "weapon" => "shotgun") %>" />
25
+ <area shape="rect" coords="300,296,413,397"
26
+ href="<%= event(nil, "set_weapon", "weapon" => "bazooka") %>" />
27
+ <area shape="rect" coords="491,346,574,401" href="house.rhtml">
28
+ </map>
29
+ <br>
30
+ <br>
31
+ <%= view(:info_panel) %>
32
+ <br>
33
+ </div>
34
+ </body>
35
+ </html>
@@ -0,0 +1,86 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ # blackjack.rb
4
+ #
5
+ # Created by James Edward Gray II on 2005-05-30.
6
+ # Copyright 2005 Gray Productions. All rights reserved.
7
+
8
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "..", "lib"))
9
+ require "gambit/tools/cards"
10
+
11
+ def value( hand )
12
+ total = 0
13
+ hand.each do |card|
14
+ if card.value.is_a? Fixnum
15
+ total += card.value
16
+ elsif card.value == :ace
17
+ total += 11
18
+ else
19
+ total += 10
20
+ end
21
+ end
22
+
23
+ if total > 21
24
+ hand.each do |card|
25
+ total -= 10 if card.value == :ace
26
+ break if total <= 21
27
+ end
28
+ end
29
+
30
+ total
31
+ end
32
+
33
+ loop do
34
+ deck = Gambit::Tools::Cards::Deck.new
35
+ dealer_hand = Gambit::Tools::Cards::Pile.new
36
+ hand = Gambit::Tools::Cards::Hand.new
37
+
38
+ deck.shuffle!
39
+ deck.deal(hand, dealer_hand, 2)
40
+ dealer_hand.add_to_top = false
41
+ dealer_hand.face_up = lambda { |index| index != 0 }
42
+
43
+ puts
44
+ loop do
45
+ puts "The dealer shows #{dealer_hand.view(:gambit_text)}."
46
+ puts "You have #{hand.view(:gambit_text)} (a total of #{value(hand)})."
47
+ break if value(hand) > 21
48
+ print "Hit or Stand? "
49
+ if $stdin.gets.downcase[0, 1] == "h"
50
+ hand << deck.draw
51
+ else
52
+ break
53
+ end
54
+ end
55
+
56
+ puts
57
+ if value(hand) > 21
58
+ puts "You busted!"
59
+ else
60
+ dealer_hand.face_up = lambda { |index| true }
61
+ until value(dealer_hand) >= 16
62
+ puts "The dealer has #{dealer_hand.view(:gambit_text)} " +
63
+ "(a total of #{value(dealer_hand)})."
64
+ puts "The dealer hits."
65
+ dealer_hand << deck.draw
66
+ end
67
+
68
+ if value(dealer_hand) <= 21
69
+ puts "The dealer stands with #{dealer_hand.view(:gambit_text)} " +
70
+ "(a total of #{value(dealer_hand)})."
71
+
72
+ puts
73
+ if value(hand) <= value(dealer_hand)
74
+ puts "That hand goes to the dealer."
75
+ else
76
+ puts "That hand is yours. Nice job."
77
+ end
78
+ else
79
+ puts "The dealer busted with #{dealer_hand.view(:gambit_text)} " +
80
+ "(a total of #{value(dealer_hand)})!"
81
+ end
82
+ end
83
+
84
+ print "Play again? "
85
+ break unless $stdin.gets.downcase[0, 1] == "y"
86
+ end
@@ -0,0 +1,93 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ # go.rb
4
+ #
5
+ # Created by Gregory Brown on May 29, 2004.
6
+ # Copyright 2005 smtose.org. All rights reserved.
7
+
8
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "..", "lib"))
9
+ require "lib/gambit/tools/board"
10
+ require "lib/gambit/tools/movehistory"
11
+
12
+ Gambit::Tools::Board.register_view(:text, <<END_VIEW)
13
+ % each_row do |row|
14
+ -<%= row.join("-") %>-
15
+ % end
16
+ END_VIEW
17
+
18
+ class Go
19
+ def initialize( )
20
+ @theBoard = Gambit::Tools::Board.new(19,19);
21
+ @theBoard.each_location do |loc|
22
+ @theBoard[loc] = "+"
23
+ end
24
+ @theBoard.include_diagonals = false
25
+
26
+ @hist = Gambit::Tools::MoveHistory.new("Player1", "Player2")
27
+ @move = 0
28
+ end
29
+
30
+ def display()
31
+ unless @move.zero?
32
+ puts @hist.view(:gambit_text)
33
+ end
34
+ puts
35
+
36
+ puts @theBoard.view(:text)
37
+ print "\n> "
38
+ end
39
+
40
+ def get_move( )
41
+ loc = gets.chomp
42
+ return if !@theBoard[loc].eql?("+")
43
+ @hist << loc
44
+ case(@move % 2)
45
+ when 0:
46
+ @theBoard[loc] = "x"
47
+ else
48
+ @theBoard[loc] = "o"
49
+ end
50
+ @move += 1
51
+ end
52
+
53
+ def game_over( )
54
+ @theBoard.each_location do |location|
55
+ unless(@theBoard[location] == "+")
56
+ unit = unit(location)
57
+ has_empty = false
58
+ unit.each do |element|
59
+ if @theBoard.neighbors(element).include?("+")
60
+ has_empty = true
61
+ end
62
+ end
63
+ return true unless has_empty
64
+ end
65
+ end
66
+ return false
67
+ end
68
+
69
+ def unit( location, neighbor_hash = Hash.new() )
70
+ has_unique = false
71
+ possible_neighbors = @theBoard.neighboring_locations(location).
72
+ select { |nl| @theBoard[nl] == @theBoard[location] }
73
+ return [location] if possible_neighbors == []
74
+ possible_neighbors.each do |pn|
75
+ if !neighbor_hash.include?(pn)
76
+ has_unique = true
77
+ neighbor_hash[pn] = true
78
+ end
79
+ end
80
+ return neighbor_hash.keys if !has_unique
81
+ result = []
82
+ possible_neighbors.each do |pn|
83
+ result += unit(pn,neighbor_hash)
84
+ end
85
+ return result.uniq
86
+ end
87
+ end
88
+
89
+ game = Go.new
90
+ until game.game_over
91
+ game.display
92
+ game.get_move
93
+ end