-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove.h
More file actions
57 lines (50 loc) · 987 Bytes
/
move.h
File metadata and controls
57 lines (50 loc) · 987 Bytes
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
#ifndef MOVE_H
#define MOVE_H
/**
* Enumeration of different directions.
*/
typedef enum Direction Direction;
enum Direction {
UP,
DOWN,
LEFT,
RIGHT,
NO_DIRECTION
};
/**
* A move item. Implemented as a node in a doubly linked list.
*/
typedef struct MoveItem MoveItem;
struct MoveItem {
MoveItem* next;
MoveItem* prev;
int age;
Direction direction;
};
/**
* The list of moves.
* Sort of implemented as a FIFO queue, but is used as a doubly linked list as well.
*/
typedef struct MoveList MoveList;
struct MoveList {
MoveItem* oldest;
MoveItem* latest;
int length;
};
/**
* Create a new move list.
*/
MoveList* new_move_list();
/**
* Delete a move list and free the memory associated with it.
*/
void delete_move_list(MoveList* list);
/**
* Pop and throw away the oldest move of the list.
*/
void pop_move(MoveList* list);
/**
* Add the latest move to the list.
*/
void push_move(MoveList* list, Direction direction);
#endif