Contents:
        Contents
        Software Package
        Agreement
        What is BunInt
        Using BunInt (with usebun.h)
        Using BunInt Directly
        Registered Version Includes
        Debugging_and_Support

Software Package:

Bunos Compact Shareware Edition for Games  ('BunInt')
by David Kelton Copyright 1996 Patent Pending
Innovative QuteGames Technologies
1745 Broadview Ln #511  Ann Arbor MI  48105  (313)332-1762
Contact rabbits@he.net or rabitman@umich.edu for a registered version.

BunInt is not a game but a Non-Player Character
learning/Artificial-Intelligence
game development tool.
After extracting (run bunosc) files,
(You may wish not to extract example.c and usebun2.h.  These
are the only source code files in the package, and are not
source for bunint nor usebun.)
you can run BunInt.exe, a Terminate Stay Resident program,
for use in your game (see 'What is BunInt' and 'Using BunInt' below).
You can then test it with example.exe (or exampl94.exe), you should be able to tease the
'+' into chasing you (the '*', use cursor keys).
(It 'learns' to chase you.  See 'What is BunInt' below).

Agreement:

To use this software the user, programmer or otherwise, implicitly agrees to the 
terms of this agreement.  
The user may freely distribute this shareware product so long as all the following 
files are included and unmodified in any way:
        bunint.exe
        usebun.obj,  usebun.lib, usebun94.obj, usebun94.lib
        usebun.h
        example.exe, exampl94.exe
        bunint.txt or readme.doc (this document)
The files usebun2.h, example.c and \Top\bunint.iqt may also be included.
(usebun2.h and example.c are not the source code for bunint and
are the only source code provided by the bunint package.)  The user may not, however,
freely distribute this product for profit without the express consent of its creator, 
David H. Kelton.  The user may bundle this product with their own game and 
sell the first thousand copies free of charge so long as this product is used by the 
game, the game says so and all files are included.  If more than one thousand 
copies are sold or are expected to be sold, a royalty agreement must be arranged 
with David H. Kelton.  Innovative QuteGames Tech. disclaims all warranties as 
to this software, which works only insofar as it has been tested.  The user agrees 
not to pirate or in any way reverse engineer this product.

What is BunInt:

Bunos Compact Ed. for games, or BunInt, is a software package that is used in 
your programs at decision points.  It deciphers which Non-Player Character 
(NPC) behaviors best harm the player's character (or help the NPC).  Here a 
behavior consists of you passing BunInt a behavior code and it returning a 
number with in a given range.  The response starts out as random, but narrows 
down as it 'learns.'  Therefore you can use this function nearly anywhere you 
would use the random function to decide where to go, when to shoot, etc.
The registered version of BunInt then records the learned data to be used by 
your game or any game that supports the BunInt standard.

BunInt is a way to enhance your games.  Though a way to do your NPC thinking
for you, it is not a replacement for adding your
own heuristics, and though general may not always behave as expected.  
For example, if you know you want some NPCs to chase your 
player's character, you should use both your heuristic (always follow) in combination
with the BunInt response.  You could use averages to do this, or use BunInt as a 
random function to sometimes follow.  Or you could use the NPC_rnd function (see
Using BunInt section) to determine speed or acceleration.
It's all in how you use it for a given game.  Further, BunInt
sometimes tends to think the first things it learns are right, and can get in a rut.  
You can delete or rename the \Top\BunInt.iqt file, or set you own instance ID.s 
with NPC_rnd_ID (see Using BunInt, Debugging).  In the registered version, there 
is also a make_uncertain function, as well as a change delay function.

Using BunInt:

BunInt (Bunos Compact Edition) is a function that may be used in your 
programs at decision points.  For example,
if(NPC_rnd(chasing,0,100)>95) action();
The function NPC_rnd starts out as a random number generator.  
Then, based on events in your game communicated with other functions, it tries to
learn which choices make the game harder and, over time, begin making the same 
choices at a given point in your program.  In the registered version the learned data 
can then be saved for later use by or communication to another game.

To activate BunInt, run it at the DOS prompt before your game.  You can do this 
by appending it to autoexec.bat (not winstart.bat) 
upon install, or by calling it with a
system("bunint.exe")	
call within your startup program.  BunInt was originally designed for DOS programs
(should you have any problems, Windows or otherwise, please e-mail me at rabbits@he.net),
and may interfere with Windows Mouse drivers and other Int 11hex drivers.
To disable this, run BunInt on Int 94hex with:
BunInt 94
You can then test it with example.exe or exampl94.exe (see Software Package section).

If you are using a C or C++ compiler (this has not been tested with Watcom) 
with the Small memory model, you can use the included usebun.h code.
Remember to add the usebun.obj (or [94].lib) in your make file or project!
If you get 'Linker Error: Unable to Open File SLIBCE.LIB' e-mail me ASAP.
Otherwise, if this still won't work for you, see Using BunInt Directly,
which can often execute faster anyway.

The .h file contains the following functions:

unsigned NPC_rnd(unsigned action, int from, int to) 
unsigned NPC_rnd_ID(unsigned action, unsigned ID, int from, int to) 

unsigned PC_rnd(unsigned action, int from, int to) 
unsigned PC_rnd_sev(unsigned action, unsigned sev, int from, int to) 

unsigned NPC_rnd_xy (unsigned action, long ex, long ix, long ey, long iy,  int 
from, int to)
unsigned NPC_rnd_ID_xy (unsigned action, unsigned ID, long ex, long ix, long 
ey, long iy, int from, int to)

Here, action is one of 16 default values:
	 life_decrease, life_increase, points_decrease, points_increase, 
ammo_decrease, ammo_increase,
chasing, running_away, shooting, surrounding, reflecting, dodging,
decrease_armor, increase_armor, decrease_power, increase_power.

These values define the standard that allows BunInt to know what is going on 
and to store it in a consistent 
way.

Most often you will call an NPC or Non-Player Character function. 
These functions always return a value from 'from' to 'from+to'.  Note that 'to' is 
the difference between the 
start and end values, not the end value!

NPC_rnd is the simplest.  Note actions like shooting and dodging will cause 
different learning than decreases and increases.  In fact, NPC shooting, dodging, 
etc. start BunInt learning and are the only functions to start returning 
consistent (non-random) numbers. It is also important to let BunInt 
know when a player's character has been injured or helped, the assumption being 
that the NPC is NOT helping the player's character.  This is done by calling the 
PC_rnd function with the action occurring to the player, for instance:

PC_rnd(life_decrease, 0, 100)

If you know no near by NPC has done anything, try not to call this function with 
a decrease.
The severity of what has happened to the player may be modified (lowered) by 
calling

PC_rnd_sev(life_decrease, 180, 0, 100)

Here we're saying to consider this only 180/255 injury to the player's character.  
NOTE:  If you know no NPCs have done anything to affect the player's 
character, don't bother calling this function, it often has a tendency to motivate 
inactivity.  For example, if you know the near by NPCs haven't moved or fired in 
the past couple seconds, you may want to skip calling this function.

Each instance of NPC_rnd keeps it's identity by what line it's on (using the 
__line__ macro available with MicroSoft and compatible compilers).  This is it's way
of distinguishing one condition or option from another.  If you wish to have it 
identify it's options in a different way,  use NPC_rnd_ID.   The second argument 
is an integer identity you set, often identifying one NPC from another, or one 
behavioral or weighting class from another.  You can make the number as large as you want, 
but BunInt expects an integer less than 256.  If you want to make sure your 
program communicates with other Bunos compliant games, you can use logical 
default IDs, making sure a high NPC_rnd_ID value is expected as good.  These 
defaults are:
 And_ID, Or_ID, Xor_ID, Nand_ID, Nor_ID, Xnor_ID, Imp_ID, Is_ID, Eq_ID,  
NotEq_ID, IsNot_ID, GreaterThan_ID, LessThan_ID, GreaterOrEqualTo_ID, 
LessOrEqualTo_ID

Usually one of the Less-Than or Greater-Than is used since BunInt is not 
designed for returning in-between values.  For example, in
	if(NPC_rnd(chasing,0,100)>95) action();
Imp_ID+GreaterThan_ID	would be used as the ID.  This ID method is not often 
used because it can cause more overlap of decision points.  More often, 
individual NPC IDs are used to keep NPCs learning separately.

The more information you give BunInt, the better it works.  This is the idea 
behind NPC_rnd_xy.  It lets you give the player x location followed by the NPC 
x location, followed by the same for PC and NPC y locations.  (In the registered
version you can pass a map array for maze handling.)  These are assumed 
to be long variable types.  NPC_rnd_ID_xy follows suit by letting you 
give your own identifier as well.

Using BunInt Directly:

If you don't have a version of C or C++ that will accept usebun.obj and usebun.h, 
you can access BunInt directly.  It runs on Interrupt 11 and 94 hexidecimal (only 94
if you specify with 'BunInt 94,' and then chains to Interrupt 0x0B).
Service AL=20hex is NPC, AL=30hex is Player Character, and
in the regstered version AL=10hex is save data.  For Player Character, CH is severity 
(0=none, 255=severe). CL should be set to zero.  CL is used in the registered versions
of Bunos.

AH holds the option identifier.  Bit 5 (10hex) is set if either NPC x 
is greater than player x or NPC y is greater than player y.

BX holds the action type.  They are defined as:
	life_decrease           0x0001
	life_increase           0x0002
	points_decrease         0x0004
	points_increase         0x0008
	ammo_decrease           0x0010
	ammo_increase           0x0020
	chasing   		0x0040
	running_away            0x0080
	shooting 		0x0100
	surrounding		0x0200
	reflecting		0x0400
	dodging                 0x0800
	decrease_armor          0x1000
	increase_armor          0x2000
	decrease_power          0x4000
	increase_power          0x8000

Remember that only NPC chasing, running_away, shooting, surrounding, reflecting and
dodging are designed to start returning consistent (non-random) values.
Returned value is in bx (also cx and dx).

Registered Version includes:

	+A save_BunInt_Data(char ID[4]) function.  This saves all learned data and a program ID.
	+Last User function.  This checks the .iqt file for the last program ID.
	 That way your program can know who has saved learned data last.
	+Make Uncertain function.  This undoes BunInt learning for a given behavior ID.
	+Change Delay function.  BunInt waits 2 seconds after NPC action for an effect.
	 This function changes that delay.
	+Map handling NPC_rnd_xy function.  (Part of Usebun not BunInt)

Debugging and Support:

E-mail me with any and all problems (include your compiler name and version)
it's how we improve our products!  The main difference between the shareware
and registered versions is ability to save data (see Registered Version Includes
section), other than that I can write most modifications free of charge to suit your needs.

If BunInt behaves badly or counter-productively (in one place or several), 
1)  Make sure you are using the right actions with it and the player.
2)  Make sure you have bunint loaded.  To do this, run mem/c/p from the dos
    prompt.
3)  Make sure you don't have a conflict with interrupt 11hex.  If so,
    you may want to try   BunInt 94
4)  Make sure you're not rewarding your NPCs for not doing anything.
5)  Try renaming \Top\BunInt.iqt to a backup.  This is the record of the 'learned' 
    data.  Sometimes BunInt makes a bad initial choice and this gets recorded in the
    .iqt file.
6)  On line help available soon at http://www.he.net/~rabbits (e-mail me if not!)
7)  Contact me at rabbits@he.net or rabitman@umich.edu.  Don't be shy.  I like
    e-mail and am ready and willing to help.
