diff --git a/2018/15/combat.js b/2018/15/combat.js new file mode 100644 index 00000000..b3dcb94b --- /dev/null +++ b/2018/15/combat.js @@ -0,0 +1,37 @@ +const distance = require('manhattan'); + +class Unit { + constructor(type, x, y, attack = 3, hp = 200) {} +} + +class MapPoint { + constructor(type, x, y) { + this.x = x; + this.y = y; + + this.type = type; + this.isWall = this.type === '#'; + } +} + +class Combat { + constructor(raw_map) { + let map_and_units = this.parseMap(raw_map); + this.map = map_and_units.map; + this.units = map_and_units.units; + } + + parseMap(raw_map) { + let initial_map = raw_map.split('\n').map(row => row.split('')); + let map = initial_map.map((row, y) => + row.map((cell, x) => new MapPoint(cell === '#' ? '#' : '.', x, y)) + ); + + return { + map, + units, + }; + } +} + +module.exports = Combat; diff --git a/2018/15/input.js b/2018/15/input.js new file mode 100644 index 00000000..e69de29b diff --git a/2018/15/input.txt b/2018/15/input.txt new file mode 100644 index 00000000..627beabb --- /dev/null +++ b/2018/15/input.txt @@ -0,0 +1,32 @@ +################################ +#########################.G.#### +#########################....### +##################.G.........### +##################.##.......#### +#################...#.........## +################..............## +######..########...G...#.#....## +#####....######.G.GG..G..##.#### +#######.#####G............#.#### +#####.........G..G......#...#### +#####..G......G..........G....## +######GG......#####........E.### +#######......#######..........## +######...G.G#########........### +######......#########.....E..### +#####.......#########........### +#####....G..#########........### +######.##.#.#########......##### +#######......#######.......##### +#######.......#####....E...##### +##.G..#.##............##.....### +#.....#........###..#.#.....#### +#.........E.E...#####.#.#....### +######......#.....###...#.#.E### +#####........##...###..####..### +####...G#.##....E####E.####...## +####.#########....###E.####....# +###...#######.....###E.####....# +####..#######.##.##########...## +####..######################.### +################################ diff --git a/2018/15/part-one.js b/2018/15/part-one.js new file mode 100644 index 00000000..e69de29b diff --git a/2018/15/part-two.js b/2018/15/part-two.js new file mode 100644 index 00000000..e69de29b