5c5
< 
---
> from board_utils import possible_from_poss
148c148
< @profile
---
> #@profile
184,185c184
< @profile
< def get_room_starts_from_hints(rm, board):
---
> def get_room_starts_from_hints_old(rm, board):
195,196c194
<     if len(rm.gatesqs) != rm.gsq_ct:
<         import ipdb;ipdb.set_trace()
---
>     out_start_allowed = True
199c197
<             if rm.gsq_ct == 2:
---
>             if len(rm.gatesqs) <= 2:
201,207c199,200
<     out_start_allowed = True
<     if len(rm.gatesqs) == 1:
<         if rm.curopen > 1:
<             out_start_allowed = False
<     for sq, hints in list(rm._hints.items()):
<         #if not rm.isopen(sq):
<             #import ipdb;ipdb.set_trace()
---
>                 out_start_allowed = False
>     for sq in list(rm._hints.store.keys()):
209,212c202
<         #sq may have been converted to a tunnel during dynamic; therefore some of the original hints for the room are not valid.
<         #TODO i should really exclude all the ones which now don't cross the sq.
<         #TODO convert this to use hintnums.
<         for indv, outdv in hints:
---
>         for indv, outdv in rm._hints[sq]:
215,221d204
<             if indv == IN and outdv == OUT and not inout_allowed:
<                 continue
<             if outdv == END:  #you can't use an END hint unless it would finish the room.
<                 if rm.all_ct == 1:
<                     pass
<                 else:
<                     continue
227a211,213
>     starts2 = get_room_starts_from_hints2(rm, board)
>     if set(starts) != set(starts2):
>         import ipdb;ipdb.set_trace()
229a216,268
> #@profile
> 
> 
> def get_room_starts_from_hints(rm, board):
>     '''added board later, trying to prevent dynamic rooms from being too obedient to static hints which aren't valid anymore.
>     
>     2016 addition:
>     1. if there are "inner" sqs and just 2 optgates, then don't do passby hints.
>     '''
>     starts = []
>     dynamic = not board.static and not board.doing_initial_placement
>     can_start = rm.can_start or rm.can_both
>     first_out_allowed = True
>     can_start = rm.can_start or rm.can_both
>     if rm.must_clean:
>         if rm.all_ct > len(rm.gatesqs) and len(rm.gatesqs) <= 2:
>             first_out_allowed = False
>     first_out_required = rm.all_ct == 1
>     for sq, hintnum in rm._hints.store.items():
>         thissq_first_inout_allowed = first_out_allowed
>         if thissq_first_inout_allowed:  #if there is an interior square with only one sourcel, and that source is me
>             #then don't freaking add an IN,OUT gate for me.
>             #TODO: thiere is more to do here - if there are say 3 gates which just so happen to have only real starts
>             #and one with a real & an INOUT, and also it must be clean, then the INOUT is useless.
>             if rm._hints.store[sq] & INOUT:
>                 if sq in rm.gatesqs:
>                     neis = [oo for oo in orth(sq) if oo in rm.sqs]
>                     for nei in neis:
>                         neisources = possible_from_poss(rm._hints.store[nei], nei, exclude_se = True)
>                         if len(neisources) == 1 and sq in neisources:
>                             #import ipdb;ipdb.set_trace()
>                             thissq_first_inout_allowed = False
>                             break
>         if rm.must_clean:
>             hintnum = hintnum & ALLIN  #only interested in IN
>         else:
>             if not can_start:
>                 hintnum = hintnum & ALLSTART_OPPOSITE
>             else:
>                 hintnum = hintnum & ALLINSTART
>         if not hintnum:
>             continue
>         if first_out_required:
>             hintnum = hintnum & ALLOUTEND
>         else:
>             if not first_out_allowed or not thissq_first_inout_allowed:  #exclude START,OUT IN,OUT
>                 hintnum = hintnum & ALLOUT_OPPOSITE
>             elif dynamic and isreqtunnel(rm.local2global(sq), board):
>                 hintnum = hintnum & INOUT_OPPOSITE
>         if not hintnum:
>             continue
>         starts.extend([(sq, hint[0], hint[1]) for hint in num2hints(hintnum)])
>     return starts
256c295
<     solved_gates = rm.gsq_ct - real_gates
---
>     solved_gates = len(rm.gatesqs) - real_gates
