Discussion:
Help ranking chess football
(too old to reply)
LuigiPaolo
2014-11-30 20:34:46 UTC
Permalink
Raw Message
Sorry for my bad english

the code mentioned below is part of an algorithm

to generate the list of a chess tournament (a bit more complex than
football).

Everything is based on the SET of Delphi7 and ranking

works perfectly only if the players do not exceed the number of 255.

The problem is that the SET can not contain more than 255 items

while a chess tournament can be up to 400-500 participants

Therefore I'm forced to work with arrays.

Some time ago I was suggested to use the functions

Contains and Procedure SetBit and below, respectively, instead of the

clause INCLUDE and IN of SET, the friend who sent me has

and I have not tested despite many efforts have failed

to solve the problem.

This would replace the IN clause and INCLUDE functions

suitable arrays.

I would also like to know how do you empty an array, with the SET

enough Set1 [] or Set2 []

Thanks for those who can help me by giving me even just a few ideas

Voltolini Luigi

Italy

?

///////// Suggested Functions

type

TMySet = array [0..63] of Byte; // 86 bytes = 512 bits

Contains function (const S: TMyset; bit: integer): boolean;

begin

Result: = (S [bit div 8] and (1 shr (bit mod 8))) <> 0;

end;

procedure SetBit (var S: TMyset; bit: integer);

begin

S [bit div 8]: = S [bit div 8] or (1 shr (bit mod 8));

end;

//////


?

Working code with the SET that replace

with ARRAY ....

?

?

////// Set1, Set2: set of 1..255;

?

Player with [ColumnA] do

begin

if (ColumnB in Set1) then begin

Include (Set2, ColumnB)

end;


if not (ColumnB in Set1) then begin

Include (Set1, ColumnB);

end;

....

Player with [ColumnB] do

begin

if (ColumnA in Set1) then begin

Include (Set2, ColumnA)

end;


if not (ColumnA in Set1) then begin

Include (Set1, ColumnA);

end;
Hans-Peter Diettrich
2014-11-30 21:14:59 UTC
Permalink
Raw Message
Post by LuigiPaolo
Everything is based on the SET of Delphi7 and ranking
works perfectly only if the players do not exceed the number of 255.
The problem is that the SET can not contain more than 255 items
You can use TBits for more than 255 members. Some functions:

Contains := MyBits[index];
MyBits[index] := Value; //Include/Exclude

DoDi
LuigiPaolo
2014-12-03 01:07:28 UTC
Permalink
Raw Message
You can use TBits for more than 255 members. Some functions:

Contains := MyBits[index];

MyBits[index] := Value; //Include/Exclude

?

?

Sorry for my bad english

Thanks for your response.

how can I adapt your suggestion to my code under which

and if you can how can I replace the sets with arrays?

I no I did

Thanks again.

?

?

?

?

?

////// Set1, Set2: set of 1..255;

?

Player with [ColumnA] do

begin

if (ColumnB in Set1) then begin

Include (Set2, ColumnB)

end;


if not (ColumnB in Set1) then begin

Include (Set1, ColumnB);

end;

....

Player with [ColumnB] do

begin

if (ColumnA in Set1) then begin

Include (Set2, ColumnA)

end;


if not (ColumnA in Set1) then begin

Include (Set1, ColumnA);

end;

Loading...