From 15e690e0dc9f539ca0e8e9c98c3fdc9105ec9d74 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 28 Jun 2020 09:40:47 +0200 Subject: Added solve --- inc/hanoi.h | 30 +++++++++++++++++++++++++++++- inc/tower.h | 43 ------------------------------------------- 2 files changed, 29 insertions(+), 44 deletions(-) delete mode 100644 inc/tower.h (limited to 'inc') diff --git a/inc/hanoi.h b/inc/hanoi.h index 1953499..3091658 100644 --- a/inc/hanoi.h +++ b/inc/hanoi.h @@ -1,9 +1,15 @@ #ifndef HANOI_H # define HANOI_H +# include +# include +# include +# include +# include + # include -# include "tower.h" +# define MAX_HEIGHT 128 enum e_mode { @@ -11,4 +17,26 @@ enum e_mode MODE_SELECT_TO, }; + +typedef struct +{ + uint8_t data[MAX_HEIGHT]; + size_t len; +} t_tower; + +enum e_highlight +{ + HIGHLIGHT_NONE = 0, + HIGHLIGHT_FROM = 1 << 0, + HIGHLIGHT_CURRENT = 1 << 1, +}; + +void towers_init(t_tower towers[3], size_t disk_num); +void towers_move(t_tower towers[3], size_t from, size_t to); +void tower_put(t_tower *tower, WINDOW *win, enum e_highlight highlight_level); +uint8_t tower_peek(t_tower *tower); + +void solve(t_tower towers[3], WINDOW *wins[3], + int n, int from, int via, int to); + #endif diff --git a/inc/tower.h b/inc/tower.h deleted file mode 100644 index da3fb1e..0000000 --- a/inc/tower.h +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* . */ -/* tower.h / \ */ -/* / \ */ -/* By: charles /o o \ */ -/* / v \ */ -/* Created: 2020/06/27 14:06:50 by charles / _ \ */ -/* Updated: 2020/06/28 08:12:37 by charles '-----------' */ -/* */ -/* ************************************************************************** */ - -#ifndef TOWER_H -# define TOWER_H - -# include -# include -# include -# include - -# include - -# define MAX_HEIGHT 128 - -typedef struct -{ - uint8_t data[MAX_HEIGHT]; - size_t len; -} t_tower; - -enum e_highlight -{ - HIGHLIGHT_NONE = 0, - HIGHLIGHT_FROM = 1 << 0, - HIGHLIGHT_CURRENT = 1 << 1, -}; - -void towers_init(t_tower towers[3], size_t disk_num); -void towers_move(t_tower towers[3], size_t from, size_t to); -void tower_put(t_tower *tower, WINDOW *win, enum e_highlight highlight_level); -uint8_t tower_peek(t_tower *tower); - -#endif -- cgit