Hi, I'm writing an AI for a board game called Blokus, and I believe that the quality of the program is going to greatly depend on the efficiency of the algorithm I use to generate legal moves and rate them.
I know sort of how I'm going to do this legal move generation, and I know it is going to require lots of accesses to an array of some kind which will represent the game board. I'm fairly new to Python, and I am not sure whether it would be faster for me to use a Dictionary data type to represent the board (advantages: indices can be strings or tuples, and the dictionary can store different types of data as well, so programming would be easier) or the Numpy array type (don't know much about this, but I have heard Numpy is faster). So is Numpy faster for simple array accesses? That would be valuable and I'd deal with having an integer-indexed integer array if I had to. Code might look something like this: for playable_corner in all_playable_corners: for piece in all_available_pieces: for each_square in piece: # if square is not in a legal position, don't add to list of legal moves So that if statement would be accessing the board array many many times. I guess my question is: Is there any way to test Dictionary access time vs. Numpy array access time? Thanks, Adam _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor