be_ai_weight.h 2.8 KB

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