summaryrefslogtreecommitdiff
path: root/src/moves.adb
blob: 4024a4d97b06bf70ea5de777bdfb8294b63c697e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71


package body Moves is


    procedure Add
           (This : in out Path;
            Item : in     Move) is
    begin
        This.Append (Item);
    end Add;


    procedure Add
           (This : in out Path;
            List : in     Path) is
    begin
        This.Append (List);
    end Add;


    procedure Prefix
           (This : in out Path;
            Item : in     Move) is
    begin
        This.Insert (1, Item);
    end Prefix;




    function Latest
           (This : in Path)
        return Move is
    begin
        return This.Last_Element;
    end Latest;


    procedure Drop_Latest
           (This : in out Path) is
    begin
        This.Delete_Last;
    end Drop_Latest;




    function Length
           (This : in Path)
        return Natural is
    begin
        return Natural (Move_Vectors.Vector (This).Length);
    end Length;


    procedure Total_Delta
           (This   : in     Path;
            DX, DY :    out Integer) is
    begin
        DX := 0;
        DY := 0;
        for M of This loop
            DX := DX + M.Delta_X;
            DY := DY + M.Delta_Y;
        end loop;
    end Total_Delta;


end Moves;