BoardSpace.net Forum Index BoardSpace.net
a place for board games
 
 FAQFAQ   SearchSearch      UsergroupsUsergroups    
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Optimising AIs using List_Of_Legal_Moves

 
Post new topic   Reply to topic    BoardSpace.net Forum Index -> Game Developers
View previous topic :: View next topic  
Author Message
AdamS



Joined: 16 Oct 2009
Posts: 6

PostPosted: Thu Oct 29, 2009 9:38 am    Post subject: Optimising AIs using List_Of_Legal_Moves Reply with quote

I have an AI (for Hex) that has an evaluate function that has a side-effect of giving a good indication of which moves are best.

The simplistic implementation ignores this information as the engine does:
    - List_Of_Legal_Moves
    - For every possible move
      - Make_Move
      - Static_Evaluate_Position: call EVALUATE
      - UnMake_Move


Instead I'd like to do this
    - List_Of_Legal_Moves: call EVALUATE
    - For subset of good moves
      - Make_Move
      - Static_Evaluate_Position - call EVALUATE
      - UnMake_Move


Net a lot less calls to EVALUATE as the branching factor of the search tree is reduced from say 100 to 10. But it's a shame because we will EVALUATE many positions twice. Any tips on how to get round this?

I could potentially implement my own mechanism based on a hash of "digest => score" but there is a small risk of collisions plus of course I don't want to reinvent the wheel.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Mar 2005
Posts: 689

PostPosted: Thu Oct 29, 2009 4:54 pm    Post subject: Reply with quote

What you are proposing to do is narrowing the width of the search,
which is dangerous unless your list of "good" moves is really really
good. Consider yourself warned.

To fit this strategy into the current framework, cache the result
of the static evaluation in the move object. Subclass "Search_Driver
and wrap
public double Static_Evaluate_Move(commonMove mm)
with a check for your precomputed result. Your shortcut
version will need to include the equivalent of this:

double val = r.Static_Evaluate_Position(mm);
mm.local_evaluation = val;
mm.evaluation = val;
mm.gameover = r.Game_Over_P();
mm.depth_limited = r.Depth_Limit(current_depth+1,max_depth);


One final note about this optimization: I predict you will not be able to detect the benefit. You'll be skipping the second evaluation only for the moves that were actually used, and only for the non-terminal nodes. This is a very small percentage of the total nodes. This kind of thinking about the expected benefits of a proposed "optimization" can save you a lot of work and prevent accumulation of unnecessary complexity in your robots.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    BoardSpace.net Forum Index -> Game Developers All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group