Skip to content

Commit

Permalink
Completely reworked cmdline argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
12345ieee committed Feb 15, 2020
1 parent 595ed4d commit 3b15ed0
Show file tree
Hide file tree
Showing 40 changed files with 1,283 additions and 1,845 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gemforce
========

Gem combining program for [Gemcraft 2: Chasing Shadows](http://gameinabottle.com/).
Gem combining program for [Gemcraft 2: Chasing Shadows](https://store.steampowered.com/app/296490/GemCraft__Chasing_Shadows/).


### Table of contents:
Expand Down Expand Up @@ -56,7 +56,7 @@ How to do this greatly depends on the operative system you are using:
everything you typically need will be placed in `bin/`

* **manual compilation:**
`gcc -std=gnu11 -O3 -flto -fwhole-program -I "include" -lm file.c -o output`
`gcc -std=gnu++17 -O3 -flto -fwhole-program -I "include" -lm file.c -o output`
You'll then need to copy the gem tables to the directory you built the executables in.

* **Windows (tested and working from XP to 8.1):**
Expand All @@ -68,7 +68,7 @@ How to do this greatly depends on the operative system you are using:

* **manual compilation:**
Works on Windows too, but it's a bit more difficult to get hold of a compiler there.
Any modern C compiler is ok, remember to include the `include` directory, as the example below:
A modern C++ compiler is required, remember to include the `include` directory, as the example below:
`somecompiler -O3 -I "include" -lm file.c -o output`


Expand Down Expand Up @@ -102,7 +102,7 @@ where the flags are:
* `t` - print best gem tree formula
* `e` - print best gem equations formula
* `c` - print best gems table (for each value best gem power)
* `i` - info
* `v` - verbose, give it twice for more info
* `q` - quiet & fast, compute only necessary combinations and print only final gem
* `u` - upto, at the end consider the best gem up to N, not the Nth
* `r` - adds red to the best gem, then consider the new gem
Expand All @@ -118,27 +118,27 @@ if `number` is `100`, then:
The `query-ngems` and `query-amps` programs support some additional flags and an extended `-f` pattern:

* `f "path_spec,path_amps"` - change table files, if any is empty it'll use the default path
* `N number` - specify how many amps you want to use (default: 6/8) `[0-8]`
* `Q number` - specify how many amps per gem (default: 6/8) `[0-8]`
* `G number` - specify how many gem are seen by each amps on average (default: 1) `[0-8]`
* `T number` - give your True Colors skill for better amps fitting `(default: 120) [0-999]`

The `query-omnia` and `query-setup` programs support an extra flag and a second number:
`./*query-omnia -[flags] number1 number2`

* `f "path_spec,path_comb,path_amps"` - change table files, if any is empty it'll use the default path
* `G number` - get the final power at a given equivalent grade (default: `30`) `[1-999]`

`number1` - speccing value (mandatory)
`number2` - combine value (can be omitted, default: `16`)

Debug flags/options (you should not need these):
Tuning flags/options (you should not need these):

* `d` - prints debug text, depending on program
* `g number` - for `query-amps` give custom growth value (default: `16c` for that gem)
* `l number` - for `query-ngems` give custom hard gem limit (default: minimum between len and table len)
* `F number` - for `query-omnia` and `query-setup` get the final power at a given equivalent grade (default: `30`) `[1-999]`

**examples:**
`./file -pet 32`
`./filequery-alone -ipf "path/to/table" 128c`
`./filequery-alone -vpf "path/to/table" 128c`
`./filequery-omnia -pq 32 16`

When in doubt about which flags are supported check with `-h`.
Expand Down
6 changes: 3 additions & 3 deletions include/build_utils_2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <algorithm>
#include <numeric>

template<unsigned int ACC, class gem>
template<int ACC, class gem>
inline void compression_2D(gem** pool_out_p, int* pool_length_out_p, gem* temp_pool, int pool_length_in)
{
gem_sort(temp_pool, pool_length_in, AS_LAMBDA(gem_12_less<ACC>));
Expand Down Expand Up @@ -38,7 +38,7 @@ inline void compression_2D(gem** pool_out_p, int* pool_length_out_p, gem* temp_p
std::copy_if(temp_pool, temp_pool + pool_length_in, *pool_out_p, [](gem g) {return g.grade != 0;});
}

template<unsigned int ACC, class gem>
template<int ACC, class gem>
static inline void merge_subpool(gem** subpool_p, int* subpool_length_p, const gem* temp_pool, int temp_length)
{
int full_length = temp_length + *subpool_length_p;
Expand All @@ -54,7 +54,7 @@ static inline void merge_subpool(gem** subpool_p, int* subpool_length_p, const g
free(full_array); // free
}

template<unsigned int SIZE, unsigned int ACC, class gem>
template<int SIZE, int ACC, class gem>
inline int fill_pool_2D(gem** pool, int* pool_length, int i)
{
const int eoc=(i+1)/ (1+1); // end of combining
Expand Down
8 changes: 4 additions & 4 deletions include/build_utils_3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "interval_tree.h"

template<unsigned int ACC, unsigned int ACC_TR, class gem>
template<int ACC, int ACC_TR, class gem>
static inline void merge_subpool(gem** subpool_p, int* subpool_length_p, const gem* temp_pool, int temp_length)
{
int full_length = temp_length + *subpool_length_p;
Expand Down Expand Up @@ -38,12 +38,12 @@ static inline void merge_subpool(gem** subpool_p, int* subpool_length_p, const g

gem_sort(full_array, full_length, AS_LAMBDA((gem_132_less<ACC, gem>)));

int tree_length = 1 << (int)ceil(log2(tree_cells)); // this is pow(2, ceil()) bitwise for speed improvement
int tree_length = 1u << (int)ceil(log2(tree_cells)); // this is pow(2, ceil()) bitwise for speed improvement

second_t* tree = (second_t*)malloc((tree_length + tree_cells + 1) * sizeof(second_t));
std::fill_n(tree, tree_length + tree_cells + 1, -1); // init also tree[0], it's faster

for (int l = full_length - 1; l >= 0; --l) { // start from large z
for (int l = full_length - 1; l >= 0; --l) { // start from large z
gem& r_gem = full_array[l];
if (tree_check_after(tree, tree_length, get_place(r_gem), get_third(r_gem))) {
tree_add_element(tree, tree_length, get_place(r_gem), get_third(r_gem));
Expand Down Expand Up @@ -92,7 +92,7 @@ static inline void merge_subpool(gem** subpool_p, int* subpool_length_p, const g
free(full_array); // free
}

template<unsigned int SIZE, unsigned int ACC, unsigned int ACC_TR, class gem>
template<unsigned int SIZE, int ACC, int ACC_TR, class gem>
inline int fill_pool_3D(gem** pool, int* pool_length, int i)
{
const int eoc = (i + 1) / (1 + 1); // end of combining
Expand Down
Loading

0 comments on commit 3b15ed0

Please sign in to comment.