-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulation.h
More file actions
37 lines (28 loc) · 797 Bytes
/
simulation.h
File metadata and controls
37 lines (28 loc) · 797 Bytes
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
//
// Created by syeyoung on 8/9/24.
//
#ifndef WATERBOARD_SIMULATION_H
#define WATERBOARD_SIMULATION_H
#include <cstdint>
enum NodeType {
BLOCK, AIR, WATER, SOURCE
};
#define WIDTH 19
#define HEIGHT 25
struct Node {
NodeType nodeType;
uint8_t waterLevel;
bool update;
};
#define GET(x,y,n) n[y][x]
#define UP(x,y, n) n[y-1][x]
#define LEFT(x,y, n) n[y][x-1]
#define RIGHT(x,y, n) n[y][x+1]
#define DOWN(x,y, n) n[y+1][x]
#define BOTTOM_LEFT(x,y,n) n[y+1][x-1]
#define BOTTOM_RIGHT(x,y,n) n[y+1][x+1]
void set(Node nodes[HEIGHT][WIDTH], uint8_t x, uint8_t y, NodeType nodeType);
bool simulateSingleTick(Node nodes[HEIGHT][WIDTH]);
void clone(Node nodes[HEIGHT][WIDTH], Node newNodes[HEIGHT][WIDTH]);
void print(Node nodes[HEIGHT][WIDTH]);
#endif //WATERBOARD_SIMULATION_H