Permalink
Browse files

solve a nasty suicide check bug

  • Loading branch information...
1 parent b25cf66 commit 4b6b581c2a2c7b75f5728af85a68ad94f8cdf5fd @imonyse committed Dec 29, 2011
Showing with 15 additions and 39 deletions.
  1. +5 −2 app/assets/javascripts/board.coffee
  2. +0 −37 config/god.rb
  3. +10 −0 spec/javascripts/board_spec.coffee
@@ -225,7 +225,10 @@ class Board
@capture_stones()
else
if examinee.owner isnt examiner.owner
- @capture_stones()
+ if @captured_color is examiner.owner
+ @add_captured examiner
+ else
+ @capture_stones()
is_alive: (dot) ->
rc = false
@@ -407,7 +410,7 @@ class BoardDot
return dots
# @flag: true => sibling dots of same color live
- # false => sibling dots of same color die
+ # false => sibling dots of same color die if no opponent dots get eaten
check_nearby_dots: (flag) ->
dots = @get_nearby_dots()
View
@@ -77,40 +77,3 @@
end
end
-God.watch do |w|
- w.name = 'juggernaut-worker'
- w.interval = 30.seconds
- w.env = {"RAILS_ENV" => "production"}
- w.start = "/usr/local/bin/juggernaut"
- w.log = "#{RAILS_ROOT}/log/juggernaut-worker.log"
-
- w.start_if do |start|
- start.condition(:process_running) do |c|
- c.running = false
- end
- end
-
- w.restart_if do |restart|
- restart.condition(:memory_usage) do |c|
- c.above = 100.megabytes
- c.times = [3, 5]
- end
-
- restart.condition(:cpu_usage) do |c|
- c.above = 50.percent
- c.times = 5
- end
- end
-
- w.lifecycle do |on|
- on.condition(:flapping) do |c|
- c.to_state = [:start, :restart]
- c.times = 5
- c.within = 5.minute
- c.transition = :unmonitored
- c.retry_in = 10.minutes
- c.retry_times = 5
- c.retry_within = 2.hours
- end
- end
-end
@@ -147,6 +147,16 @@ describe 'Board', ->
expect(board.find_stone_by_name("oe").owner).toEqual("e")
expect(board.find_stone_by_name("ne").owner).toEqual("w")
+ it 'should remove opponent stone without liberty first', ->
+ # bug found at http://www.laoqipan.com/games/1067
+ for pos in ["pd","pj","pp","kk","dq","fj","cd","cj","ed","qn","co","jp","nq","jr","qh","jd","hc","me","pf","kh","on","hl","mn","mi","ml","gq","cl","dl","kn","cm","cg","lb","ro","oc","pc","pb","qb","pa","fh","qc","rb","oe","pe","rc","sb","sc","rd","qd","re","qa","qe","ra","sd","sa","bl","oh","bm","ck","ob","nb","na","la","nc","od","of","mb","ne"]
+ board.click_via_name pos
+
+ board.click_via_name 'oa'
+
+ expect(board.find_stone_by_name('ob').owner).toEqual('e')
+ expect(board.find_stone_by_name('pa').owner).toEqual('w')
+
it "normally you wouldn't placed positions", ->
for pos in ['t18', 's18', 'r19']
board.click_via_coordinates pos, 'w'

0 comments on commit 4b6b581

Please sign in to comment.