tag:blogger.com,1999:blog-4906546928149629084.post4849344371605743551..comments2023-10-31T01:54:54.868-07:00Comments on Flash Game Dev Blog: Word list in Flash word gamexenonhttp://www.blogger.com/profile/10326194693325918193noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4906546928149629084.post-55444798169923611782008-10-30T09:22:00.000-07:002008-10-30T09:22:00.000-07:00I agree with Jason. A binary search is the best in...I agree with Jason. A binary search is the best in this situation. I think any kind of tree implementation is overkill. The words from the word list are already presorted. The value of a tree comes when the input is unsorted.Brian Yamabehttps://www.blogger.com/profile/04535848221157850349noreply@blogger.comtag:blogger.com,1999:blog-4906546928149629084.post-76682432990413270022008-06-04T04:12:00.000-07:002008-06-04T04:12:00.000-07:00how are you loading the dictionary?how are you loading the dictionary?Sameerhttps://www.blogger.com/profile/10559504838891672531noreply@blogger.comtag:blogger.com,1999:blog-4906546928149629084.post-9508825712300184992008-06-04T04:11:00.000-07:002008-06-04T04:11:00.000-07:00I've just started work on a word game and a radix ...I've just started work on a word game and a <A HREF="http://en.wikipedia.org/wiki/Radix_tree" REL="nofollow">radix tree</A> immensly optimizes my search.<BR/><BR/>But my problem is the initial loading of the dictionary. It hangs up the game for about 15,20 seconds :S. Any hints to overcome this?Sameerhttps://www.blogger.com/profile/10559504838891672531noreply@blogger.comtag:blogger.com,1999:blog-4906546928149629084.post-52874901587976365862008-01-28T13:34:00.000-08:002008-01-28T13:34:00.000-08:00You should use a binary search instead, it should ...You should use a binary search instead, it should be able to search that list in a dozen or so iterations at most, which should be much faster than splitting things into 26*26 arrays..<BR/><BR/>something along these lines:<BR/><BR/> public function FindWordIdx(s:String):int<BR/> {<BR/> var low:int = 0<BR/> var high:int = mWordList.length - 1<BR/> var mid:int = 0;<BR/> while (low <= high)<BR/> {<BR/> mid = (low + high) / 2<BR/> var comp:int = s.localeCompare(mWordList[mid]);<BR/> if (comp < 0)<BR/> high = mid - 1<BR/> else if (comp > 0)<BR/> low = mid + 1<BR/> else<BR/> return mid // found<BR/> }<BR/> return -1 // not found<BR/> }Jason Boothhttps://www.blogger.com/profile/03832373920590563761noreply@blogger.com