Changeset 38 for trunk/Forms


Ignore:
Timestamp:
Oct 13, 2019, 5:34:57 PM (5 years ago)
Author:
chronos
Message:
  • Added: In computer AI form allow to set delay of steps computation. Set to zero means fastest processing.
Location:
trunk/Forms
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormComputer.lfm

    r32 r38  
    3232    TabOrder = 1
    3333  end
     34  object TrackBar1: TTrackBar
     35    Left = 24
     36    Height = 58
     37    Top = 104
     38    Width = 430
     39    Max = 1000
     40    Position = 0
     41    Anchors = [akTop, akLeft, akRight]
     42    TabOrder = 2
     43  end
     44  object Label1: TLabel
     45    Left = 21
     46    Height = 26
     47    Top = 76
     48    Width = 127
     49    Caption = 'Delay per step:'
     50    ParentColor = False
     51  end
    3452end
  • trunk/Forms/UFormComputer.lrj

    r32 r38  
    22{"hash":1113,"name":"tformcomputer.caption","sourcebytes":[65,73],"value":"AI"},
    33{"hash":5941396,"name":"tformcomputer.buttonstart.caption","sourcebytes":[83,116,97,114,116],"value":"Start"},
    4 {"hash":371552,"name":"tformcomputer.buttonstop.caption","sourcebytes":[83,116,111,112],"value":"Stop"}
     4{"hash":371552,"name":"tformcomputer.buttonstop.caption","sourcebytes":[83,116,111,112],"value":"Stop"},
     5{"hash":116494394,"name":"tformcomputer.label1.caption","sourcebytes":[68,101,108,97,121,32,112,101,114,32,115,116,101,112,58],"value":"Delay per step:"}
    56]}
  • trunk/Forms/UFormComputer.pas

    r32 r38  
    66
    77uses
    8   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, UGame, fgl;
     8  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
     9  UGame, fgl;
    910
    1011type
     
    3031    ButtonStart: TButton;
    3132    ButtonStop: TButton;
     33    Label1: TLabel;
     34    TrackBar1: TTrackBar;
    3235    procedure ButtonStartClick(Sender: TObject);
    3336    procedure ButtonStopClick(Sender: TObject);
     
    135138  );
    136139begin
     140  ButtonStopClick(Self);
    137141  Core.PersistentForm1.Save(Self);
    138142end;
     
    187191        S := S + '), ';
    188192      end;
    189       MoveAllAndUpdate(GameTries[0].Moves[0]);
     193      MoveAllAndUpdate(GameTries[0].Moves[0], False);
    190194{      if CanMergeDirection(drDown) then MoveAllAnimate(drDown)
    191195      else if CanMergeDirection(drRight) then MoveAllAnimate(drRight)
     
    198202      }
    199203      Application.ProcessMessages;
    200       Sleep(10);
     204      Sleep(TrackBar1.Position);
    201205    end;
    202206  end;
     
    243247      NewTry.Game.UndoEnabled := False;
    244248      NewTry.Game.AnimationDuration := 0;
    245       NewTry.Game.MoveAllAnimate(Direction);
     249      NewTry.Game.MoveAll(Direction, False);
    246250      SetLength(NewTry.Moves, Length(NewTry.Moves) + 1);
    247251      NewTry.Moves[Length(NewTry.Moves) - 1] := Direction;
  • trunk/Forms/UFormMain.pas

    r37 r38  
    5757  if Core.Game.Running and not Core.Game.Moving then begin
    5858    case Key of
    59       37: Core.Game.MoveAllAndUpdate(drLeft);
    60       38: Core.Game.MoveAllAndUpdate(drUp);
    61       39: Core.Game.MoveAllAndUpdate(drRight);
    62       40: Core.Game.MoveAllAndUpdate(drDown);
     59      37: Core.Game.MoveAllAndUpdate(drLeft, True);
     60      38: Core.Game.MoveAllAndUpdate(drUp, True);
     61      39: Core.Game.MoveAllAndUpdate(drRight, True);
     62      40: Core.Game.MoveAllAndUpdate(drDown, True);
    6363    end;
    6464  end;
Note: See TracChangeset for help on using the changeset viewer.