| 1 | /* |
| 2 | =========================================================================== |
| 3 | Copyright (C) 1999-2005 Id Software, Inc. |
| 4 | |
| 5 | This file is part of Quake III Arena source code. |
| 6 | |
| 7 | Quake III Arena source code is free software; you can redistribute it |
| 8 | and/or modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation; either version 2 of the License, |
| 10 | or (at your option) any later version. |
| 11 | |
| 12 | Quake III Arena source code is distributed in the hope that it will be |
| 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with Quake III Arena source code; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | =========================================================================== |
| 21 | */ |
| 22 | |
| 23 | /***************************************************************************** |
| 24 | * name: be_ai_weight.h |
| 25 | * |
| 26 | * desc: fuzzy weights |
| 27 | * |
| 28 | * $Archive: /source/code/botlib/be_ai_weight.h $ |
| 29 | * |
| 30 | *****************************************************************************/ |
| 31 | |
| 32 | #define WT_BALANCE 1 |
| 33 | #define MAX_WEIGHTS 128 |
| 34 | |
| 35 | //fuzzy seperator |
| 36 | typedef struct fuzzyseperator_s |
| 37 | { |
| 38 | int index; |
| 39 | int value; |
| 40 | int type; |
| 41 | float weight; |
| 42 | float minweight; |
| 43 | float maxweight; |
| 44 | struct fuzzyseperator_s *child; |
| 45 | struct fuzzyseperator_s *next; |
| 46 | } fuzzyseperator_t; |
| 47 | |
| 48 | //fuzzy weight |
| 49 | typedef struct weight_s |
| 50 | { |
| 51 | char *name; |
| 52 | struct fuzzyseperator_s *firstseperator; |
| 53 | } weight_t; |
| 54 | |
| 55 | //weight configuration |
| 56 | typedef struct weightconfig_s |
| 57 | { |
| 58 | int numweights; |
| 59 | weight_t weights[MAX_WEIGHTS]; |
| 60 | char filename[MAX_QPATH]; |
| 61 | } weightconfig_t; |
| 62 | |
| 63 | //reads a weight configuration |
| 64 | weightconfig_t *ReadWeightConfig(char *filename); |
| 65 | //free a weight configuration |
| 66 | void FreeWeightConfig(weightconfig_t *config); |
| 67 | //writes a weight configuration, returns true if successful |
| 68 | qboolean WriteWeightConfig(char *filename, weightconfig_t *config); |
| 69 | //find the fuzzy weight with the given name |
| 70 | int FindFuzzyWeight(weightconfig_t *wc, char *name); |
| 71 | //returns the fuzzy weight for the given inventory and weight |
| 72 | float FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum); |
| 73 | float FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum); |
| 74 | //scales the weight with the given name |
| 75 | void ScaleWeight(weightconfig_t *config, char *name, float scale); |
| 76 | //scale the balance range |
| 77 | void ScaleBalanceRange(weightconfig_t *config, float scale); |
| 78 | //evolves the weight configuration |
| 79 | void EvolveWeightConfig(weightconfig_t *config); |
| 80 | //interbreed the weight configurations and stores the interbreeded one in configout |
| 81 | void InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2, weightconfig_t *configout); |
| 82 | //frees cached weight configurations |
| 83 | void BotShutdownWeights(void); |