doc changes to search function

This commit is contained in:
Dan Ballard 2011-09-12 18:08:23 -07:00
parent 34bccf463f
commit 78afdda3f0
1 changed files with 10 additions and 14 deletions

View File

@ -247,25 +247,20 @@ class Board
end
def search(team)
@top_depth = 26
search_do(team, @top_depth, 100.0, 0.0, "R", {TEAM_1 => -100, TEAM_2 => -100})
search_do(team, 0, 10, 100.0, 0.0, "R", {TEAM_1 => -100, TEAM_2 => -100})
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
if depth == 0
#puts "DONE"
return score(team)
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
puts "TEAM_2 WON!"
return score(team)
@ -291,7 +286,7 @@ class Board
#puts "SEARCH"
sub_score = move.search_do(opposite_team(team), depth -1, item_percent, last_percent+done, location + "." +i.to_s, maxs.dup )
done += item_percent
if done >= 0.0001
if done >= 0.01
last_percent += done;
puts "%.5f" % last_percent + "% depth: " + depth.to_s + " max: " + maxs.to_s
done = 0.0
@ -305,5 +300,6 @@ class Board
end
end
end
end