ViewVC Help
View Directory | Revision Log | View Changeset | Root Listing
root/src/trunk/games
r2016
File (rev) Last Change
 ../
random/ 1153 (16 years ago) by laffer1: Forced commit to add: The changes in the randomize_fd.c are pretty simple: Basically in the older algorithm you had to walk thru the whole list element-by-element in order to reach an specific line and print it. This process is rather slow in big lists (big files :)), since it had to go all the way from the head of the list until it reached the element it randomly selected. The new algorithm only changes the way we access the elements, basically after the whole file is loaded up into the linked-list, we create an array of pointers to rand_node pointers, basically we walk over the whole list once (after the whole file is loaded into the list) and map each address into an array position (in the same order they were inserted on the list), after that whenever a random number is selected, we dont need to walk the whole list until we reach it, we simply rand_node_table[selected] it and get it in one move. If the unique option is used, after a rand_node_table[selected] gets visited we set it to NULL and if we reach that same slot afterwards, we simply go back and randomly select another number. Pretty simple. victor loureiro lima
primes/ 1042 (16 years ago) by laffer1: $MidnightBSD$
ppt/ 1043 (16 years ago) by laffer1: $MidnightBSD$
pom/ 1043 (16 years ago) by laffer1: $MidnightBSD$
number/ 1043 (16 years ago) by laffer1: $MidnightBSD$
morse/ 1054 (16 years ago) by laffer1: Correct bug in script adding $MidnightBSD$
grdc/ 1041 (16 years ago) by laffer1: $MidnightBSD$
fortune/ 1149 (16 years ago) by laffer1: Fix a tagging goof
factor/ 1043 (16 years ago) by laffer1: $MidnightBSD$
caesar/ 1039 (16 years ago) by laffer1: $MidnightBSD$
bcd/ 1039 (16 years ago) by laffer1: $MidnightBSD$
Makefile.inc 1043 (16 years ago) by laffer1: $MidnightBSD$
Makefile 1043 (16 years ago) by laffer1: $MidnightBSD$
11 directories and 2 files shown