-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Configuration file. Improve performances.
- Loading branch information
1 parent
2c2d2da
commit b3831d5
Showing
9 changed files
with
192 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
package com.contracyclix.chuckchess; | ||
|
||
import com.contracyclix.chuckchess.ai.NoAIClassException; | ||
import com.contracyclix.chuckchess.benchmark.Benchmarks; | ||
import com.contracyclix.chuckchess.config.Config; | ||
import com.contracyclix.chuckchess.ui.NoUIClassException; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
|
||
public class MainApp { | ||
private static final String configOption = "--config.location="; | ||
|
||
public static void main(String... args) throws NoUIClassException, NoAIClassException { | ||
new ChessApp().run(); | ||
public static void main(String... args) throws NoUIClassException, NoAIClassException, RunnerException { | ||
if (args.length > 0 && "benchmark".equals(args[0])) { | ||
Benchmarks.main(args); | ||
} else { | ||
if (args.length > 0 && args[0].startsWith(configOption)) { | ||
Config.setConfigFileName(args[0].split(configOption)[1]); | ||
} | ||
new ChessApp().run(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/contracyclix/chuckchess/benchmark/AlphaBetaBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.contracyclix.chuckchess.benchmark; | ||
|
||
import com.contracyclix.chuckchess.minmax.AlphaBeta; | ||
import com.github.bhlangonijr.chesslib.Board; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
|
||
public class AlphaBetaBenchmark { | ||
|
||
@Benchmark | ||
public void alphaBeta() { | ||
AlphaBeta alphaBeta = new AlphaBeta(3, true, 3); | ||
|
||
alphaBeta.alphaBeta(new Board(), 0, Long.MIN_VALUE, Long.MAX_VALUE, true); | ||
} | ||
|
||
@Benchmark | ||
public void negaMax() { | ||
AlphaBeta alphaBeta = new AlphaBeta(3, true, 3); | ||
|
||
alphaBeta.negaMax(new Board(), Long.MIN_VALUE, 0); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/contracyclix/chuckchess/benchmark/Benchmarks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.contracyclix.chuckchess.benchmark; | ||
|
||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
|
||
public class Benchmarks { | ||
public static void main(String[]args) throws RunnerException { | ||
Options opt = new OptionsBuilder() | ||
.include(AlphaBetaBenchmark.class.getSimpleName()) | ||
.forks(1) | ||
.build(); | ||
|
||
new Runner(opt).run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.