Skip to content

Commit

Permalink
Rename to cover
Browse files Browse the repository at this point in the history
  • Loading branch information
knewjade committed Oct 27, 2020
1 parent aaf7a57 commit 3661158
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 85 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ solution-finderは、探索ツールとして次の特徴を持っています

* spin: ある地形からT-Spinできるようになる手順を列挙する

* cover: 指定したミノの置き場所通りに置くことができるミノ順をすべて列挙する

* util: solution-finderの機能を補助するユーティリティ
- fig: テト譜をもとに画像を生成

Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
============================================================
コマンド: sequence
コマンド: cover
============================================================

Alias command: seq

概要
============================================================

Expand All @@ -16,7 +14,7 @@ Alias command: seq
基本コマンド
============================================================

``java -jar sfinder.jar sequence --tetfu v115@vhFRQJUGJKJJvMJTNJGBJ v115@vhFRQJPGJKJJGMJTNJ0BJ --patterns *p7``
``java -jar sfinder.jar cover --tetfu v115@vhFRQJUGJKJJvMJTNJGBJ v115@vhFRQJPGJKJJGMJTNJ0BJ --patterns *p7``


入力フォーマット
Expand Down Expand Up @@ -174,7 +172,7 @@ v115のテト譜データにのみ対応。
* harddrop: ハードドロップのみ


``-o``, ``--output-base`` [default: output/seq.csv]
``-o``, ``--output-base`` [default: output/cover.csv]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

出力結果を保存するファイルのパスを指定する。
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ solution-finderは、探索ツールとして次の特徴を持っています

* spin: ある地形からTスピンできる手順を列挙する

* sequence: 指定したミノの置き場所通りに置くことができるミノ順をすべて列挙する
* cover: 指定したミノの置き場所通りに置くことができるミノ順をすべて列挙する

* util: solution-finderの機能を補助するユーティリティ
- fig: テト譜をもとに画像を生成
Expand Down Expand Up @@ -107,7 +107,7 @@ solution-finderを操作しやすくするGUIを `@kitsune_fuchi (twitter) <http
contents/setup/main
contents/ren/main
contents/spin/main
contents/sequence/main
contents/cover/main
contents/util/main
contents/caution
contents/contact
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/entry/EntryPointMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import entry.ren.RenOptions;
import entry.ren.RenSettingParser;
import entry.ren.RenSettings;
import entry.sequence.SequenceEntryPoint;
import entry.sequence.SequenceOptions;
import entry.sequence.SequenceSettingParser;
import entry.sequence.SequenceSettings;
import entry.cover.CoverEntryPoint;
import entry.cover.CoverOptions;
import entry.cover.CoverSettingParser;
import entry.cover.CoverSettings;
import entry.setup.SetupEntryPoint;
import entry.setup.SetupOptions;
import entry.setup.SetupSettingParser;
Expand Down Expand Up @@ -53,6 +53,7 @@ public class EntryPointMain {
"combo",
"move",
"spin",
"cover",
"util fig",
};

Expand Down Expand Up @@ -208,9 +209,8 @@ private static Optional<EntryPoint> createEntryPoint(String type, List<String> c
case "ren":
case "combo":
return getRenEntryPoint(commands);
case "seq":
case "sequence":
return getSequenceEntryPoint(commands);
case "cover":
return getCoverEntryPoint(commands);
case "dev":
return getDevEntryPoint(commands);
case "spin":
Expand Down Expand Up @@ -246,16 +246,16 @@ private static Optional<EntryPoint> getPathEntryPoint(List<String> commands) thr
}
}

private static Optional<EntryPoint> getSequenceEntryPoint(
private static Optional<EntryPoint> getCoverEntryPoint(
List<String> commands
) throws FinderInitializeException, FinderParseException {
Options options = SequenceOptions.create();
Options options = CoverOptions.create();
CommandLineParser parser = new DefaultParser();
SequenceSettingParser settingParser = new SequenceSettingParser(options, parser);
Optional<SequenceSettings> settingsOptional = settingParser.parse(commands);
CoverSettingParser settingParser = new CoverSettingParser(options, parser);
Optional<CoverSettings> settingsOptional = settingParser.parse(commands);
if (settingsOptional.isPresent()) {
SequenceSettings settings = settingsOptional.get();
return Optional.of(new SequenceEntryPoint(settings));
CoverSettings settings = settingsOptional.get();
return Optional.of(new CoverEntryPoint(settings));
} else {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package entry.sequence;
package entry.cover;

import common.SyntaxException;
import common.buildup.BuildUp;
Expand Down Expand Up @@ -41,13 +41,13 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class SequenceEntryPoint implements EntryPoint {
public class CoverEntryPoint implements EntryPoint {
private static final String LINE_SEPARATOR = System.lineSeparator();

private final SequenceSettings settings;
private final CoverSettings settings;
private final BufferedWriter logWriter;

public SequenceEntryPoint(SequenceSettings settings) throws FinderInitializeException {
public CoverEntryPoint(CoverSettings settings) throws FinderInitializeException {
this.settings = settings;

// ログファイルの出力先を整備
Expand All @@ -70,11 +70,11 @@ public void run() throws FinderException {

ColorConverter colorConverter = new ColorConverter();

List<SequenceParameter> parameters = settings.getParameters();
List<CoverParameter> parameters = settings.getParameters();

output("# Setup Field");

for (SequenceParameter parameter : parameters) {
for (CoverParameter parameter : parameters) {
// Setup field
Field field = parameter.getField();
Verify.field(field);
Expand Down Expand Up @@ -144,7 +144,7 @@ public void run() throws FinderException {
List<Piece> pieceList = pieces.blockStream().collect(Collectors.toList());

for (int index = 0; index < parameterSize; index++) {
SequenceParameter parameter = parameters.get(index);
CoverParameter parameter = parameters.get(index);
List<MinoOperationWithKey> operations = parameter.getOperationList();
Field field = parameter.getField();

Expand Down Expand Up @@ -210,7 +210,7 @@ public void run() throws FinderException {
int all = piecesList.size();
for (int index = 0; index < successCounters.size(); index++) {
AtomicInteger counter = successCounters.get(index);
SequenceParameter parameter = parameters.get(index);
CoverParameter parameter = parameters.get(index);

int success = counter.get();
output(String.format("%.2f %% [%d/%d]: http://fumen.zui.jp/?v115@%s#%d:%d",
Expand Down Expand Up @@ -238,7 +238,7 @@ public void run() throws FinderException {
// Header
bw.write("sequence,");
bw.write(
parameters.stream().map(SequenceParameter::getData).collect(Collectors.joining(","))
parameters.stream().map(CoverParameter::getData).collect(Collectors.joining(","))
);
bw.newLine();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package entry.sequence;
package entry.cover;

import entry.common.option.ListArgOption;
import entry.common.option.NoArgOption;
Expand All @@ -7,7 +7,7 @@
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;

public enum SequenceOptions {
public enum CoverOptions {
Help(NoArgOption.full("h", "help", "Usage")),
Fumen(ListArgOption.fullSpace("t", "tetfu", "v115@~", "Specify tetfu data for s-finder settings")),
Patterns(SingleArgOption.full("p", "patterns", "definition", "Specify pattern definition, directly")),
Expand All @@ -20,7 +20,7 @@ public enum SequenceOptions {

private final OptionBuilder optionBuilder;

SequenceOptions(OptionBuilder optionBuilder) {
CoverOptions(OptionBuilder optionBuilder) {
this.optionBuilder = optionBuilder;
}

Expand All @@ -31,7 +31,7 @@ public String optName() {
public static Options create() {
Options allOptions = new Options();

for (SequenceOptions options : SequenceOptions.values()) {
for (CoverOptions options : CoverOptions.values()) {
Option option = options.optionBuilder.toOption();
allOptions.addOption(option);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package entry.sequence;
package entry.cover;

import common.datastore.MinoOperationWithKey;
import core.field.Field;

import java.util.Collections;
import java.util.List;

public class SequenceParameter {
public class CoverParameter {
private final String input;
private final String data;
private final Field field;
private final List<MinoOperationWithKey> operationList;
private final int start;
private final int end;

SequenceParameter(
CoverParameter(
String input, String data, Field field, List<MinoOperationWithKey> operationList, int start, int end
) {
this.input = input;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package entry.sequence;
package entry.cover;

import common.datastore.MinoOperationWithKey;
import common.datastore.Operations;
Expand All @@ -17,8 +17,6 @@
import entry.CommandLineWrapper;
import entry.common.Loader;
import entry.common.SettingParser;
import entry.path.PathOptions;
import entry.ren.RenOptions;
import exceptions.FinderParseException;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.Options;
Expand All @@ -35,28 +33,28 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class SequenceSettingParser extends SettingParser<SequenceSettings> {
public class CoverSettingParser extends SettingParser<CoverSettings> {
private static final String CHARSET_NAME = "utf-8";
private static final String DEFAULT_PATTERNS_TXT = "input/patterns.txt";
private static final String DEFAULT_FIELD_TXT = "input/field.txt";
private static final String PATTERN_DELIMITER = ";";

public SequenceSettingParser(Options options, CommandLineParser parser) {
public CoverSettingParser(Options options, CommandLineParser parser) {
super(options, parser);
}

@Override
protected Optional<SequenceSettings> parse(CommandLineWrapper wrapper) throws FinderParseException {
SequenceSettings settings = new SequenceSettings();
protected Optional<CoverSettings> parse(CommandLineWrapper wrapper) throws FinderParseException {
CoverSettings settings = new CoverSettings();

MinoFactory minoFactory = new MinoFactory();
ColorConverter colorConverter = new ColorConverter();

// テト譜の読み込み
List<String> fumens = loadFumenData(
wrapper,
SequenceOptions.Fumen.optName(),
SequenceOptions.FieldPath.optName(),
CoverOptions.Fumen.optName(),
CoverOptions.FieldPath.optName(),
DEFAULT_FIELD_TXT,
Charset.forName(CHARSET_NAME)
).stream()
Expand All @@ -69,7 +67,7 @@ protected Optional<SequenceSettings> parse(CommandLineWrapper wrapper) throws Fi
throw new FinderParseException("Cannot load fumen" + fumens);
}

ArrayList<SequenceParameter> parameters = new ArrayList<>();
ArrayList<CoverParameter> parameters = new ArrayList<>();

for (String input : fumens) {
int start = 1;
Expand Down Expand Up @@ -136,24 +134,24 @@ protected Optional<SequenceSettings> parse(CommandLineWrapper wrapper) throws Fi
field, new Operations(operationList), minoFactory, height
);

parameters.add(new SequenceParameter(input, data, field, operationsWithKey, start, end));
parameters.add(new CoverParameter(input, data, field, operationsWithKey, start, end));
}

settings.setParameters(parameters);

// パターンの読み込み
List<String> patterns = Loader.loadPatterns(
wrapper,
SequenceOptions.Patterns.optName(),
CoverOptions.Patterns.optName(),
PATTERN_DELIMITER,
SequenceOptions.PatternsPath.optName(),
CoverOptions.PatternsPath.optName(),
DEFAULT_PATTERNS_TXT,
Charset.forName(CHARSET_NAME)
);
settings.setPatterns(patterns);

// ドロップの設定
Optional<String> dropType = wrapper.getStringOption(SequenceOptions.Drop.optName());
Optional<String> dropType = wrapper.getStringOption(CoverOptions.Drop.optName());
try {
dropType.ifPresent(type -> {
String key = dropType.orElse("softdrop");
Expand All @@ -168,15 +166,15 @@ field, new Operations(operationList), minoFactory, height
}

// ホールドの設定
Optional<Boolean> isUsingHold = wrapper.getBoolOption(SequenceOptions.Hold.optName());
Optional<Boolean> isUsingHold = wrapper.getBoolOption(CoverOptions.Hold.optName());
isUsingHold.ifPresent(settings::setUsingHold);

// ログファイルの設定
Optional<String> logFilePath = wrapper.getStringOption(SequenceOptions.LogPath.optName());
Optional<String> logFilePath = wrapper.getStringOption(CoverOptions.LogPath.optName());
logFilePath.ifPresent(settings::setLogFilePath);

// アウトプットファイルの設定
Optional<String> outputBaseFilePath = wrapper.getStringOption(SequenceOptions.OutputBase.optName());
Optional<String> outputBaseFilePath = wrapper.getStringOption(CoverOptions.OutputBase.optName());
outputBaseFilePath.ifPresent(settings::setOutputBaseFilePath);

return Optional.of(settings);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package entry.sequence;
package entry.cover;

import entry.DropType;
import exceptions.FinderParseException;

import java.util.Collections;
import java.util.List;

public class SequenceSettings {
public class CoverSettings {
private static final String DEFAULT_LOG_FILE_PATH = "output/last_output.txt";
private static final String DEFAULT_OUTPUT_BASE_FILE_PATH = "output/seq.csv";

private String logFilePath = DEFAULT_LOG_FILE_PATH;
private String outputBaseFilePath = DEFAULT_OUTPUT_BASE_FILE_PATH;
private List<String> patterns = Collections.emptyList();
private List<SequenceParameter> parameters;
private List<CoverParameter> parameters;
private DropType dropType = DropType.Softdrop;
private boolean isUsingHold = true;

Expand All @@ -22,7 +22,7 @@ boolean isUsingHold() {
return isUsingHold;
}

List<SequenceParameter> getParameters() {
List<CoverParameter> getParameters() {
return parameters;
}

Expand Down Expand Up @@ -63,7 +63,7 @@ boolean isOutputToConsole() {
return true;
}

public void setParameters(List<SequenceParameter> parameters) {
public void setParameters(List<CoverParameter> parameters) {
this.parameters = parameters;
}

Expand Down
Loading

0 comments on commit 3661158

Please sign in to comment.