-
Notifications
You must be signed in to change notification settings - Fork 0
/
klondike.h
64 lines (53 loc) · 1.61 KB
/
klondike.h
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
#ifndef KLONDIKE_H
# define KLONDIKE_H
# include <stdio.h>
# include <unistd.h>
# include <limits.h>
# include <stdlib.h>
# include <string.h>
# define SIZE_DESC 48
typedef struct s_board
{
int c;
int g;
int h;
int is_closed;
int is_open;
size_t hash;
struct s_board *parent;
char desc[SIZE_DESC];
char waste[24 + 1];
char stock[24 + 1];
char f[4][13 + 1];
char t[7][19 + 1];
} t_board;
int stoi(char *s);
char *itos(int i);
t_board *stob(char *s);
void print_board(t_board *b);
int num_moves(t_board *b);
t_board **make_moves(t_board *b);
size_t hash(void *data, size_t size);
int heuristic(t_board *b);
/* pq */
typedef struct s_priority_queue {
size_t capacity;
size_t num_nodes;
int (*cmp)(void *, void *);
void **nodes;
} pq;
pq *pq_init(int (*cmp)(void *, void *));
void pq_insert(pq *q, void *node);
void *pq_extract(pq *q);
void pq_destroy(pq *q);
/* ht */
typedef struct s_hash_table {
size_t capacity;
size_t num_keys;
void **entries;
} t_hash_table;
void ht_insert(t_hash_table *ht, t_board *b);
t_board *ht_find(t_hash_table *ht, t_board *b);
t_hash_table *ht_init();
void ht_destroy(t_hash_table *ht);
#endif