doc changes to search function
This commit is contained in:
parent
34bccf463f
commit
78afdda3f0
24
checkers.rb
24
checkers.rb
|
@ -247,25 +247,20 @@ class Board
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(team)
|
def search(team)
|
||||||
@top_depth = 26
|
search_do(team, 0, 10, 100.0, 0.0, "R", {TEAM_1 => -100, TEAM_2 => -100})
|
||||||
search_do(team, @top_depth, 100.0, 0.0, "R", {TEAM_1 => -100, TEAM_2 => -100})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_do(team, depth, percent, last_percent, location, maxs)
|
# team - current player this turn
|
||||||
|
# current depth - counting up to max_depth
|
||||||
|
# max_depth - when we should stop our search
|
||||||
|
# my_percent - the percent range this work covers
|
||||||
|
# done_percent - the percent of work already done
|
||||||
|
# maxs -
|
||||||
|
def search_do(team, current_depth, max_depth, my_percent, done_percent, maxs)
|
||||||
#puts location
|
#puts location
|
||||||
if depth == 0
|
if depth == 0
|
||||||
#puts "DONE"
|
|
||||||
return score(team)
|
return score(team)
|
||||||
end
|
end
|
||||||
if score(team) < maxs[team]
|
|
||||||
return score(team)
|
|
||||||
end
|
|
||||||
#if team == TEAM_1
|
|
||||||
# puts depth.to_s + ": TEAM_1's turn:"
|
|
||||||
#else
|
|
||||||
# puts depth.to_s + ": TEAM_2's turn:"
|
|
||||||
#end
|
|
||||||
#puts to_s #moves[0].to_s
|
|
||||||
if @stats[TEAM_1]['count'] == 0
|
if @stats[TEAM_1]['count'] == 0
|
||||||
puts "TEAM_2 WON!"
|
puts "TEAM_2 WON!"
|
||||||
return score(team)
|
return score(team)
|
||||||
|
@ -291,7 +286,7 @@ class Board
|
||||||
#puts "SEARCH"
|
#puts "SEARCH"
|
||||||
sub_score = move.search_do(opposite_team(team), depth -1, item_percent, last_percent+done, location + "." +i.to_s, maxs.dup )
|
sub_score = move.search_do(opposite_team(team), depth -1, item_percent, last_percent+done, location + "." +i.to_s, maxs.dup )
|
||||||
done += item_percent
|
done += item_percent
|
||||||
if done >= 0.0001
|
if done >= 0.01
|
||||||
last_percent += done;
|
last_percent += done;
|
||||||
puts "%.5f" % last_percent + "% depth: " + depth.to_s + " max: " + maxs.to_s
|
puts "%.5f" % last_percent + "% depth: " + depth.to_s + " max: " + maxs.to_s
|
||||||
done = 0.0
|
done = 0.0
|
||||||
|
@ -305,5 +300,6 @@ class Board
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue