Skip to content

Commit 548c1e8

Browse files
committed
Day 15, starting progress
1 parent e6e6b40 commit 548c1e8

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

2018/15/combat.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const distance = require('manhattan');
2+
3+
class Unit {
4+
constructor(type, x, y, attack = 3, hp = 200) {}
5+
}
6+
7+
class MapPoint {
8+
constructor(type, x, y) {
9+
this.x = x;
10+
this.y = y;
11+
12+
this.type = type;
13+
this.isWall = this.type === '#';
14+
}
15+
}
16+
17+
class Combat {
18+
constructor(raw_map) {
19+
let map_and_units = this.parseMap(raw_map);
20+
this.map = map_and_units.map;
21+
this.units = map_and_units.units;
22+
}
23+
24+
parseMap(raw_map) {
25+
let initial_map = raw_map.split('\n').map(row => row.split(''));
26+
let map = initial_map.map((row, y) =>
27+
row.map((cell, x) => new MapPoint(cell === '#' ? '#' : '.', x, y))
28+
);
29+
30+
return {
31+
map,
32+
units,
33+
};
34+
}
35+
}
36+
37+
module.exports = Combat;

2018/15/input.js

Whitespace-only changes.

2018/15/input.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
################################
2+
#########################.G.####
3+
#########################....###
4+
##################.G.........###
5+
##################.##.......####
6+
#################...#.........##
7+
################..............##
8+
######..########...G...#.#....##
9+
#####....######.G.GG..G..##.####
10+
#######.#####G............#.####
11+
#####.........G..G......#...####
12+
#####..G......G..........G....##
13+
######GG......#####........E.###
14+
#######......#######..........##
15+
######...G.G#########........###
16+
######......#########.....E..###
17+
#####.......#########........###
18+
#####....G..#########........###
19+
######.##.#.#########......#####
20+
#######......#######.......#####
21+
#######.......#####....E...#####
22+
##.G..#.##............##.....###
23+
#.....#........###..#.#.....####
24+
#.........E.E...#####.#.#....###
25+
######......#.....###...#.#.E###
26+
#####........##...###..####..###
27+
####...G#.##....E####E.####...##
28+
####.#########....###E.####....#
29+
###...#######.....###E.####....#
30+
####..#######.##.##########...##
31+
####..######################.###
32+
################################

2018/15/part-one.js

Whitespace-only changes.

2018/15/part-two.js

Whitespace-only changes.

0 commit comments

Comments
 (0)