Peter Eric (aka 'pew') WI Guest
|
Posted: Thu Feb 01, 2007 3:28 pm Post subject: Help needed to sort array (sort on enumerated data type). |
|
|
Hello All,
I am working on a game (a many year project!) and I have defined the
var "move_choices: move_choices_type;" & I need to sort the "move:
array[1..8*3] of move_record;" by the ordinal value of the
move_record's move_value (which is type of move_type enumerated value).
Would someone please be kind enough to paste up some code to sort the
"move" (of type move_records). Note that the will always be only 24
records in the array so the speed of the sort routine in not important
(eg even a slow sort routine would be okay... as it only needs to sort
24 records).
Any & all help appreciated.
Regards,
PEW ))
Hobart, Tas, AU.
---------------
//....
type
move_type = (winning_move,
essential_take,
safe_protective_take,
unsafe_protective_take,
safe_defensive_take,
unsafe_defensive_take,
safe_take,
unsafe_take,
best_clear_run,
has_won,
resignation,
safe_protective_move,
unsafe_protective_move,
safe_defensive_move,
unsafe_defensive_move,
best_forward_move,
safe_move,
unsafe_move,
stalemate,
may_lose,
losing_move,
current_X_move,
current_O_move,
current_player_X_move,
current_player_O_move,
rejected,
illegal);
win_type = (no_winner,
O_human,
X_human,
stalemated,
O_computer,
X_computer);
pattern_type = record
this_game: integer;
option: option_type;
x_piece,
o_piece: board_data_type;
end;
directions_type = (left_take, forward_move, right_take);
move_record = record
move_value : move_type;
pawn_number : byte;
direction: directions_type;
end;
move_choices_type = record
option_count: integer;
move: array[1..8*3] of move_record;
end;
var
move_choices: move_choices_type;
//...
---- end
--
Yours Truely,
PEW (poet) |
|