A
A
Alexey Ovsyankin2018-06-05 15:35:18
Delphi
Alexey Ovsyankin, 2018-06-05 15:35:18

How to simplify the payment matrix?

In general, it is necessary to simplify the payment matrix. Reduce it to a size of 2 by 2. It turned out only to simplify the lines (code below). I can't simplify by columns.
5b16833815d6d726347697.png

The code
procedure TForm2.Button2Click(Sender: TObject);
begin
 n:=SG.RowCount-1;
  m:=sg.ColCount-1;

  for i:=1 to n do
    for j:=1 to m do
      arplat[i,j]:=strtoint(SG.Cells[j,i]);
  //создание матрицы выигрышей
 //логический массив упрощенных строк игрока
 for i := 1 to 4 do
  arupr[i]:=0;
 //сравнивание строк платежной матрицы
 r:=4;
 for i := 1 to 3 do
 begin
 k:=0;
 r:=r-1;
  for j := 1 to r do
  begin
  k:=k+1;
  s:=0;
   for t := 1 to 4 do
   begin
    if (arplat[i,t]>=arpla
t[i+k,t]) then
    s:=s+1;
   end;
  if s=4 then arupr[i+k]:=1;
  if s=0 then arupr[i]:=1;
  end;
 end;
//определение размерности упрощенной матрицы
 s:=0;
 for i := 1 to 4 do
  if arupr[i]=0 then s:=s+1;
 St
ringGrid1.RowCount:=s+1;
 //заполнение упрощенной матрицы
k:=0;
 for i := 1 to 4 do
 begin
  if arupr[i]=0  then
  begin
   k:=k+1;
   StringGrid1.Cells[0,k]:='А'+inttostr(i);
   for j := 1 to 4 do
    StringGrid1.Cells[j,k]:=inttostr(arplat[i,j]);
  end;
 end;
end;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kalapanga, 2018-06-05
@kalapanga

Well, if I remember correctly, now all the same needs to be done on the resulting matrix only by columns.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question