Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Free Will

Author
Message
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 3rd Sep 2004 19:40 Edited at: 3rd Sep 2004 19:48
Is it possible to program free will into A.I NPC'S as I just bought a Game A.I for Developers book yesterday , a lot if it is writtern in C++ so would need to be adapted for Dark Basic but I was wondering as I wish to do my Cybergod gamehttp://forum.thegamecreators.com/?m=forum_view&t=37853&b=9and I was wondering whether it would be possible to do that so that they can choose to be good or bad ?

Is that possible as alsmost everything else seems to be possible as I think you can make A.I eat, sleep, go to the toilet ,have a bit of nookie so why not program them with frre will I think you might have to program them with personality to get the free will but I would just like to kknow if that is possible?
JeBuS
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 3rd Sep 2004 20:17
If you program it, it's possible.


High quality models and graphics, low prices. Graphics for the rest of us.
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 4th Sep 2004 06:51
Rnd() is your friend.
(And so is Randomize Timer())
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 4th Sep 2004 09:03
I see and how would I use that for personality or free will as I thought I would have to make some type of probability type of function.

Would rnd(0 and RandomiseTimer help me with this Ilya?
Skeletor
20
Years of Service
User Offline
Joined: 21st Jun 2004
Location: florida
Posted: 4th Sep 2004 09:24 Edited at: 4th Sep 2004 09:25


This code will not compile... but its just to show you what the logic is behind rnd()


http://www.angelfire.com/games5/db_games/
Sir Spaghetti Code
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location: Just left of Hell
Posted: 4th Sep 2004 09:28
What you are alluding to is very complex. You would have to be a genius to create "true" free will with DB, C++, or any other conventional language (might be easier with something the public can't touch or know about yet!).

What you can do is create the illusion of free will, and that is all game programming is!

Zero Blitzt
21
Years of Service
User Offline
Joined: 18th Jan 2004
Location: Different Stages
Posted: 4th Sep 2004 09:30
Freewill = Good song by Rush


Come to #coding. We promise we wont kick you!
DISCLAIMER: Promises may not actually be upheld.
JerBil
21
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 4th Sep 2004 10:58
If you make them do it, it's not free will.

-JerBil
ArcAngel
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 4th Sep 2004 11:49
Yes it is, Not technically but it still is. I think that in order for your A.I. to be A.I., not only do there actions need to be random, but need to have some consistency. An NPC that s cats will not like cats now or sometime in the future. Once you randomize it's personality {thus it's decision making too} you would prolly need to save those variables.

"There's a glitch in the Matrix"
"Attack life, your going to die anyway."
"Visit my website! www.freewebs.com/stradigos"
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Sep 2004 15:11
You need to start your AI out with a core set of principles, responses for different situations. Based on input from the user you will need to constantly store information in his "brain" and he will constantly be taking information out of that to make decisions based on the problems the user gives him. By collecting data he will be given a "personality" on which to base his judgements.

It might be impossible to program true free will though, read Isaac Asimov's I, Robot (not the movie) and you'll find out that even their "free will" is really based on a set of rules that are being interpreted differently, but still generally being followed by each robot.

Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 4th Sep 2004 20:21 Edited at: 5th Sep 2004 03:53
I was thinking that if the desicisions are 50% random but in an organisied manner than that could be "free will" , something like Skeletors code but it would have the chioce of either being good or bad depending on it'spersonality and it's likes or dislikes

Eating, Drinking going to the toilet could be programmed into it, even sexual desire I think could be programmed although, ifwe try to make it like us then that also would have to be based on likes or dislikes.

Learning could also be programmed into it I think but the descions I think could be randomised but as I am still relearning BASIC it would be fairly difficult I think I would have to try and translate alot of C++ code into Dark Basic Code
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 4th Sep 2004 20:31 Edited at: 5th Sep 2004 06:10
The thing is how could I possess an NPC as well? would it be similiar to getting in and out of vehicles? and how would I disable it's brain so I can control it? then reasonable it once return control to it?
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 5th Sep 2004 05:29
To simulate different aspects of personality you can use a random range cheker, such as the following;

Actions Possible;
1. kill
2. burn
3. pillage
4. have a drink
5. give a tythe
6. help someone
7. heal someone
8. rescue someone
...etc.

Alignment = random(4) ; half the actions.

choice made = random(4) + alignment.

That way, between the range of good an evil actions, the NPC's alignment shifts them up or down the scale of what is good or evil activity. If this was built with a greater complexity, you wouls simulate free will in an aligned fashion.
S.

Any truly great code should be indisguishable from magic.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 5th Sep 2004 22:34
I really will have to look into that Sndrs, thanks anyway that would help me create my game "Cybegods" if I could get to understand it better
Sir Spaghetti Code
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location: Just left of Hell
Posted: 6th Sep 2004 09:08
Quote: "The thing is how could I possess an NPC as well? would it be similiar to getting in and out of vehicles? and how would I disable it's brain so I can control it? then reasonable it once return control to it? "


Any way you program it.


"What is a game if not illusions stacked upon illusions?"
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 7th Sep 2004 01:04
Well, my thinking is similar to that of NPCs in TSR games, where the character's alignment caused the use of a different table for their basic decisions. Take for example a good aligned person, chances are they were more likely to "team up" with another character for the mutual benefit of the team, while a more evil aligned one would only do so for whatever he could get out of the deal.

If all such actions were listed on a table or in case statement, then a random choice was made and added to a value of the character's alignment, the character would be more likely to pick "the good actions" at the bottom of the table (higher numbers) than "the bad" ones at the top (lower numbers) of the list.

How much the alignment influences the characters depends on how you set up the random values, say like having the choice section pick a number between 1 and 6 instead of 1 to 4 on the example I gave. This means that to be "really good" or "really bad" would wrap around the table simulating those occasional acts of either in a character.

Anyway, that's the theory, right out of TSR's D&D material.
S.

Any truly great code should be indisguishable from magic.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 7th Sep 2004 08:05
That somes very good SandraD, TSR games hmmmmmmmm? what does the intial 's stand for(just incase its a game company or game I have heard about but at the moment my mind is blank)
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 7th Sep 2004 13:06 Edited at: 7th Sep 2004 13:12
TSR was the original distributor of Dungeons & Dragons (the pen/paper game). They also put out games like Eye of the Beholder, Menzoberranzan, Dungeon Hack, and many many other D&D adventure adaptations for DOS.

[EDIT]
Elaborating on SandraDs shtick on TSR and their NPCs. The way it worked was that there were several alignments:



True Good-goody goody pretty boy

Neutral Good-good at heart, but only helped out when it benefitted them

Chaotic Good-good at heart, but sometimes bad actions with good intentions

True Neutral-.....true neutrality, a mercenary

Orderly Evil-evil with a sense or morality, kind of like those movies with the intelligent bad guys who don't want to hurt people, just steal their money

Neutral Evil-bad attitude, keep to themselves unless provoked

Pure Evil-go far out of their way to be bad


With AI you always have to define a core set of principles. That's how we function as humans. As we grew up our parents raised us to live by certain principles and taught us the basic reactions to different situations. As we grew our experiences were tested against our principles, and if there was a confliction, our principles changed slightly and we evolved as a person.

Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 7th Sep 2004 22:00
I see, that might well be the answer, that could make the A.I similiar to us
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Sep 2004 05:20
TSR = Tactical Studies Rule, and yes, they had several "flavors" of alignment possible for NPCs, which is why I proposed the random range check operation using numeric values. That way, you can build the AI decision tree as deeply or large as required for your game without running into catagory limitations.
S.

Any truly great code should be indisguishable from magic.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 8th Sep 2004 06:28
OK but that in Dark Basic would problably mean variables? I think I don't know I am relearning BASIC at the moment after wasting time with 3D RAD
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 8th Sep 2004 15:45
Everything needs variables.

Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 8th Sep 2004 20:09
I see, then , as I have been coming to grips with DBC 's variables it might not be as hard as I thought
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 9th Sep 2004 04:44
Well, yes, two variables per NPC I would suspect, in addition to the other qualities of say, hit points, species, strength and so on. The first "extra" variable would be the NPCs alignment (unlikely to change but still stored with them) and the second would be their current action selection. (The random event total.) the rest would be just one big case selection tree, with an optional limiting or wrap-around of the values to fit on the table. DBC shouldn't have too many problems with this, since most of the character data would be an array anywho.
S.

Any truly great code should be indisguishable from magic.
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 9th Sep 2004 07:50
Only a few variables are needed for standard AI like SandraD says, but if you're wanting some killer AI you probably need to use an array and store several values.

Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 9th Sep 2004 12:28 Edited at: 9th Sep 2004 12:28
Yes array's not really my strong point and I have a little bit of self doubt over them
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 9th Sep 2004 14:15
Think of them like a spreadsheet.

dim myarray(x,y)

Of course the x and y are actual values, think of the x as the letters going across the top, and y as the numbers going down on the left. Then by using each coordinate you can specify which cell to put data into. You can also pull it up. Arrays are useful because you can easily access many elements inside them using for..next loops.

Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 9th Sep 2004 23:00 Edited at: 10th Sep 2004 20:28
I see can I use them to help me get objects into and out of other objects like vehicles as I want to make all the vehicles capable of being used by both friendly and enemy A.I


I have been told I would need arrays for multiple vehicles like this, as I wll also be having vehicles in Cybergods do I use a 2d array or a 3d array?

And I can get access in all the elements would that be like globals then?
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 10th Sep 2004 03:41
Yes and Yes. Arrays are automatically global in DBC, such that I often use the command DIM A(0) to make a global variable of A for example.

As to the size and style of the array, 2 or 3 dimensions and such, that depends on the limits required by your data. For access, just use the offsets as needed. One note however, I have had problems with sub-accessing arrays at times, as in;

dim a(0)
dim b(100)
dim mycar(100, 100)

a(0) = 75
b(99) = 5

if mycar(a(0), b(99)) > 75 ..

Doesn't work, or worse and more difficult;

dim world(a(0), b(99))

messes up completely. (It can't figure out the size of the local array.) So I have found you sometimes have to use "temp variables" to carry the numbers from one statement to the next;

x=a(0) : y = b(99)
dim world(x,y)

And so on...

This is especially true with READ and WRITE file commands, which my experiece suggests that they can't handle the extra parsing depth produced by multiple array variables.

good luck!
S.

Any truly great code should be indisguishable from magic.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 10th Sep 2004 20:27 Edited at: 11th Sep 2004 00:17
I see, because I have several vehicles that I want the player to get in and out of as I have

VTOL Air/spaceplanes (2 versions)
Conventional Aircraft (2 Versions)
Car
Wheeled Tank
Hovertank
Hovercraft Tank
Tracked Tank
Walker/Mech (which will be like a human only slower but can straffe, kneel , crawl, walk and run, the Walker is half done as it can't kneel yet, I will need to work that our or get help in how to do it)

So if that is the case at least two other games I have in mind would be virtually nearly finished. With Cybergods if the player wants to start from the beginning I think there could be a problem with chariots, horses , mules, and donkeys with getting the player and Aa.i to mount the animals , I might be wrong that might just a very minor promlem but I can see it happening with me

You say you have had problems accessing the sub arrays, I was wondering if it is the parenthesis brackets that could be the problem or if it is simply a bug ?

As you know what you are talking about more than I do I would just agree with you

Thanks anyway Sandra D, your help have been invaluble
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 12th Sep 2004 03:58
Yeah, it's possible there's a bug in parenthesis code, or too limited a recursion allowed in the formula analysis. Whatever the cause, it can mess ya up from time to time.

For the multiple vehicle thing and the capabilities, just plce the list into an array such that tank1 = 1, tank2 = 2 and so on, along with their saved options;

Data;
-----move?---shoot?---guns?---rockects?---radio?
tank1 no-----yes-------no--------no---------yes
tank2 yes----yes-------no--------no---------yes
tank3 yes----yes------yes--------no---------no

array; tank(4,5)
tank1 --> tank(1,1)=0 : tank(1,2)=1 : tank(1,3)=0 : tank(1,4)=0 : tank(1,5)=1
tank2 --> tank(2,1)=1 : tank(2,2)=1 : tank(2,3)=0 : tank(2,4)=0 : tank(2,5)=1
tank3 --> tank(3,1)=1 : tank(3,2)=1 : tank(3,3)=1: tank(3,4)=0 : tank(3,5)=0
and so on...

remember, it's like a spread sheet which can be as wide or high as you need, such that the vehicle type can change what the values mean in addition to the carrying the options for each device. What you really need to do is decide is what is the object with the largest list of options, and use that for the maximum size of your array list.

good luck,
s.

Any truly great code should be indisguishable from magic.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 12th Sep 2004 04:40 Edited at: 12th Sep 2004 10:10
I see and can I then use this to allow a.i players as well as the plaer to get into one tank? I suppose I would have to if I want all the fighting vehicles to be able to be used by both enemy or friendly, although I wouldn't want he enemy to get into a friendly four man tank without the a.i trying to kill the enemy a.i I think it would be best to put a conditon so that couldn't happen on either side

And thanks for your help SandraD, I needed it
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 13th Sep 2004 05:08
Hehehe.. well I suppose you could allow opposing sides to share the same vehicles, though it might be a short-lived game if the player sat down with three baddies in a cab.

But yeah, arrays are useful for many things so having a working knowledge is a good thing.
S.

Any truly great code should be indisguishable from magic.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 13th Sep 2004 07:51
LOL actually I moght do that in a later version, allow oppsite sides to get into a tank and they fight it out with each other and only when it is either full or one of the sides has the weapons and the other side is a little far away trying to get into the tank then it would be difficult for the other side, after all that would happen in real life if the tank is disabled but still had use of the weapons
and the enemy and friendly had their weapons. That also might come in hany for people to fight on a space cruiser

Login to post a reply

Server time is: 2025-05-24 17:07:44
Your offset time is: 2025-05-24 17:07:44