/*
* This file is part of RuneOptimizer.
*
* RuneOptimizer is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* RuneOptimizer. If not, see
* -h | --min_hp N
* -a | --min_atk N
* -d | --min_def N
* -s | --min_spd N
* -c | --min_crr N
* -d | --min_crd N
* -r | --min_res N
* -f | --min_acc N
* -p | --min_ehp N
* -m | --min_dmg N
*
*/
Stats *min_stats;
/**
* Option to format the optput for the GUI.
*
* This is not intended to be used by the user. It changes the output format
* to be consumed by the GUI. To set it, the parameter -g or --gui must be
* passed (it takes no options).
*/
unsigned char gui;
/**
* Flag to use only unassigned runes.
*
* If this option is set to {@link TRUE}, only runes in storage (i.e. not
* assigned to any unit will be considered during optimization). Runes
* assigned to the unit being currently optimizad will of course be
* considered even with this option.
*
* The parameter to set this option is -o or --storage, and it takes no
* options.
*/
unsigned char storage;
/**
* List of teams to ignore during optimization.
*
* For every team indicated here, no rune of it's units will be considered
* during optimization. If the unit currently being optimized is in one of
* these teams, the unit's runes will still be considered.
*
* The parameter for this option is -x or --no-teams, followed by a comma
* separated list of team IDs (not names). If more teams that
* {@link MAX_EXCLUSIONS} are indicated, the last ones wil be ignored.
*/
unsigned char excluded_teams[MAX_EXCLUSIONS][TEAM_ID_LEN];
/**
* Indicates how many teams are excluded.
*
* This is not a configurable option, but a handy counter. The default value
* is 0, and will be set when {@link excluded_teams} is populated.
*/
unsigned char total_excluded_teams;
/**
* List of units to ignore during optimization.
*
* For every unit indicated here, it's units will be considered during
* optimization. If the unit currently being optimized is in the list, it's
* runes will still be considered.
*
* The parameter for this option is -u or --no-units, followed by a comma
* separated list of unit IDs (not names). If more units that
* {@link MAX_EXCLUSIONS} are indicated, the last ones wil be ignored. If is
* not enough, consider making a team and exclude with
* {@link excluded_teams}.
*/
unsigned char excluded_units[MAX_EXCLUSIONS][UNIT_ID_LEN];
/**
* Indicates how many units are excluded.
*
* This is not a configurable option, but a handy counter. The default value
* is 0, and will be set when {@link excluded_units} is populated.
*/
unsigned char total_excluded_units;
/**
* Option to enable broken sets.
*
* If {@link sets} doesn't amount for six runes, this option will discard
* any result that is not formed by complete sets. The default value is
* {@link FALSE}. To set it, use the parameter -k or --broken (it takes no
* options).
*/
unsigned char broken_sets;
/**
* Number of thread to be used during optimization.
*
* Calculation of rune combinations can be done in separateed threads. Each
* thread shares the same amount of work as the others, so the more threads,
* the faster the optimzation is! The default value is 1, and can be set
* passing the parameter -b or --threads, followed by a numeric value. No
* more than 8 threads can be used.
*/
unsigned char threads;
/**
* Weights for each stat.
*
* To calculate the rating of a results, different stats can be weighted
* differently. The higher the ponderation of a stat, the more effect will
* it have in the rating. Default values are 1 for every stat, and the value
* can be a float between 0 and 2.
*
* @todo Implement
* @todo Once implemented, document the argument ot use.
* @todo Once implemented, document here if EHP and DMG can be weighted.
*/
Stat_Ponderation ponderation;
/**
* Output mode for the optimization data.
*/
unsigned char output_mode;
} Optimizer_Filters;
/**
* Data package used by the optimizer.
*
* This is the data that {@link optimize_thread} takes. Each thread must have
* it's own data package.
*/
typedef struct Optimizer_Data {
/**
* Numeric ID of the thread.
*
* Usually, the spawing order.
*/
unsigned int thread_id;
/**
* List of runes.
*
* These are the runes to test during optimization. The 0 index is not used
* and can be empty or have garbage.
*/
Rune runes[RUNE_SLOTS + 1][LIMIT_RUNES_PER_SLOT];
/**
* Runes counter for each slot.
*
* Indicates the size of each {@link runes}. Index 0 is not used.
*/
unsigned int count[RUNE_SLOTS + 1];
/**
* List of results.
*
* The thread saves every succesfull combination here.
*/
Result results[MAX_RESULTS];
/**
* Number of results.
*
* The total number of results the thread has found.
*/
unsigned int total_results;
/**
* The options passed to the optimizer. *
*/
Optimizer_Options *options;
/**
* The filters passed to the optimizer.
*
* The threads also needs to know some of these options.
*/
Optimizer_Filters *filters;
/**
* The output options passed to the optimizer.
*
* The threads also needs to know some of these options.
*/
Optimizer_Output *output;
/**
* Max testable combinations.
*
* Not just for this thread, but the sum of combinations to test by every
* thread.
*/
unsigned long long max_combinations;
/**
* Tested combinations.
*
* Number of tested combinations at any given point in time.
*/
unsigned long long tested_combinations;
/**
* Set count calculated from the options passed to the optimizer.
*
* A set count to compare every rune combination against.
*/
Rune_Set_Count requested_set_count;
/**
* The optimized unit
*
* The unit being optimized, with all the info previously loaded.
*/
Unit *unit;
/**
* Optimization start time
*
* The time the optimization started in ISO format:
* YYYY-MM-DDTHH:MM:SS
*/
char start_time[20];
} Optimizer_Data;
/**
* Starts the optimization process.
*
* Validates the arguments, gets the neccessary runes and starts the
* optimization process. On error, it will print a message to stderr.
*
* @param[in] argc Number of argument passed to the optimizer command. As a
* rule, it must me two less than the argc received by the {@link main}
* function of the program.
* @param[in] argv Arguments passed to the optimizer. As a rule, they must be
* the same than the argv received by the {@link main} function of the program
* without the first two. The first of them must be a unit ID or name. Apart
* from that, only two of them are mandatory: --stats / -t and --sets / -e.
* @return {@link SUCCESS} if the optimization was done coreclty, or an error
* defined in {@link error.h} if there were problems with any of them.
*/
int optimize(int argc, char *argv[]);