summaryrefslogtreecommitdiff
path: root/util.h
blob: 2142c8f18515cfda849bd20f18b140de15370e7f (plain)
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
#pragma once

#include <iostream>
#include "params.h"

using namespace std;


#define NEXTTURN(_clr) ((_clr) % NC + 1)


struct Idx {
	inline Idx(int idx) : x(idx % BSZ - BMID), y(idx / BSZ - BMID) {}

	int x, y;
};

inline ostream& operator<<(ostream &os, const Idx &obj) {
	return os << '(' << obj.x << ',' << obj.y << ')';
}


inline constexpr int ipow(int b, int e) {
	int r = 1;
	for (int i = 0; i < e; i++) r *= b;
	return r;
}