]> git.cworth.org Git - rrsolve/blob - src/rrsolve.h
Initial revision
[rrsolve] / src / rrsolve.h
1 /* rrsolve - Simple RR solver and librr client.
2  *
3  * Copyright © 2003 Carl Worth
4  *
5  * Permission to use, copy, modify, distribute, and sell this software
6  * and its documentation for any purpose is hereby granted without
7  * fee, provided that the above copyright notice appear in all copies
8  * and that both that copyright notice and this permission notice
9  * appear in supporting documentation, and that the name of Carl Worth
10  * not be used in advertising or publicity pertaining to distribution
11  * of the software without specific, written prior permission.
12  * Carl Worth makes no representations about the suitability of this
13  * software for any purpose.  It is provided "as is" without express
14  * or implied warranty.
15  * 
16  * CARL WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18  * NO EVENT SHALL CARL WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23  *
24  * Author: Carl Worth <carl@theworths.org>
25  */
26
27 #ifndef RRSOLVE_H
28 #define RRSOLVE_H
29
30 #include <rr.h>
31
32 #include "args.h"
33
34 typedef unsigned int rrs_state_t;
35
36 typedef struct {
37     rrs_state_t *state;
38     int num_states;
39
40     int size;
41
42     int sorted;
43 } rrs_state_buf_t;
44
45 typedef struct {
46     rr_robot_t robot;
47     rr_direction_t dir;
48 } rrs_move_t;
49
50 typedef struct {
51     rrs_move_t *move;
52     int num_moves;
53     int size;
54 } rrs_solution_t;
55
56 /* rrs_solution.c */
57
58 rr_status_t
59 rrs_solution_init (rrs_solution_t *solution);
60
61 void
62 rrs_solution_fini (rrs_solution_t *solution);
63
64 rr_status_t
65 rrs_solution_push (rrs_solution_t *solution,
66                    rr_robot_t robot, rr_direction_t dir);
67
68 rr_status_t
69 rrs_solution_pop (rrs_solution_t *solution,
70                   rr_robot_t *robot, rr_direction_t *dir);
71
72 rr_status_t
73 rrs_solution_prepend (rrs_solution_t *solution,
74                       rr_robot_t robot, rr_direction_t dir);
75
76 /* rrs_state_buf.c */
77
78 rrs_state_buf_t *
79 rrs_state_buf_create (int initial_size);
80
81 void
82 rrs_state_buf_destroy (rrs_state_buf_t *buf);
83
84 rr_status_t
85 rrs_state_buf_add (rrs_state_buf_t *buf, rrs_state_t state);
86
87 rr_status_t
88 rrs_state_buf_add_sorted (rrs_state_buf_t *buf, rrs_state_t state);
89
90 rr_status_t
91 rrs_state_buf_append (rrs_state_buf_t *buf, rrs_state_buf_t *other);
92
93 rr_status_t
94 rrs_state_buf_remove (rrs_state_buf_t *buf, rrs_state_t state);
95
96 int
97 rrs_state_buf_contains (rrs_state_buf_t *buf, rrs_state_t state);
98
99 #endif