MCPcopy Create free account
hub / github.com/dhbloo/rapfi / countLine

Function countLine

Rapfi/game/pattern.cpp:168–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166
167template <Rule R>
168constexpr std::tuple<int, int, int, int> countLine(const Line<R> &line)
169{
170 constexpr auto Mid = LineLen<R> / 2;
171
172 int realLen = 1, fullLen = 1;
173 int realLenInc = 1;
174 int start = Mid, end = Mid;
175
176 for (int i = Mid - 1; i >= 0; i--) {
177 if (line[i] == SELF)
178 realLen += realLenInc;
179 else if (line[i] == OPPO)
180 break;
181 else
182 realLenInc = 0;
183
184 fullLen++;
185 start = i;
186 }
187
188 realLenInc = 1;
189
190 for (int i = Mid + 1; i < LineLen<R>; i++) {
191 if (line[i] == SELF)
192 realLen += realLenInc;
193 else if (line[i] == OPPO)
194 break;
195 else
196 realLenInc = 0;
197
198 fullLen++;
199 end = i;
200 }
201
202 return std::make_tuple(realLen, fullLen, start, end);
203}
204
205template <Rule R>
206constexpr Line<R> shiftLine(const Line<R> &line, int i)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected