Qbasicnews.com
February 23, 2020, 07:25:35 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2] 3 4
  Print  
Author Topic: computer game AI  (Read 9972 times)
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #15 on: August 19, 2003, 02:16:54 AM »

Quote
But I don't think he's after an AI that can pass the whatever-you-call-it test. That's a technical term, BTW.


A turing test. Now if it could pass that, it would definately be hunting around for the power switch Tongue

Let's ignore the fact that we've "barely scratched the surface" of AI, and think about what's been done. We've all lost RTS's at some point, possibly because of the computer's good tactics, so it can be done.

RST's idea is a good one, but how would you set it up?

It all sounds like evolution, natural selection, biology to me.
Logged

RST
Wandering Guru
***
Posts: 326



« Reply #16 on: August 19, 2003, 09:00:48 PM »

Quote from: "oracle"

It all sounds like evolution, natural selection, biology to me.


Bingo. That's exactly what it (genetic programming) is - a computer simulation of natural selection. Think of the AIs as organisms, the code for the AI script as their genes, and their ability to kick one another's butt as fitness. Take the most fit, and have them "reproduce" for the next generation.

So you'll need some kind of parser for the AI scripts, but I assume you'd need that anyway.

Think of an If/Then in the AI script as a gene. Take two successful scripts, and create a new script by giving it random "genes" from each parent. Chromosomes and all that. You can even do mutations. Cheesy

You'd be surprised how effective this type of thing can be...

::EDIT::
Actually, it's essential that you have mutations. But worry about that later.
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #17 on: August 20, 2003, 08:40:50 AM »

Actually, it isn't. If your new population code allows for the entire range of combinations and a slightly random combination based on fitness of two (or more) organisms, you don't need it..
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
RST
Wandering Guru
***
Posts: 326



« Reply #18 on: August 20, 2003, 03:19:48 PM »

I beg to differ. During my first attempts at genetic programming, I had it so there was an n% chance an organism would undergo mutation. After playing around with this a bit, I changed it so there was an n% chance each individual "gene" would mutate. I found that the organisms could reach the optimal solution quicker if every single one had some mutation. The only problem was that the species as a whole did a lot worse, but if you only need one good solution...

And we've gone off on a tangent, especially since the original poster of the thread has shown absolutely no interest in all of this.

So to get back on topic...

Try dividing the map into a grid. The squares should be maybe about a quarter of the size of a typical base (you'll have to fool around with the exact size). Then before the AI takes its turn, count the number of units and buildings in each square, both hostile and friendly. Additionally, count the number of recent kills in each square. You can use these numbers to help the AI.

For example, you can have the AI place more defences on squares that have had high fatalities and are close to its base, so the AI will be able to adapt its defences to the most used attack routes. Also, if a unit detects recent friendly deaths in a nearby sqaure, it can respond and move to assist. Furthermore, if you record the type of unit that did the killing (e.g. flying or cloaked) you can have the AI respond with the appropriate counter (e.g., anti-aircraft or detection), both by moving it to the combat area and building more of them.

Perhaps if you described your game in a little more detail, we cold help more.
Logged
momoguru
Forum Regular
**
Posts: 131



« Reply #19 on: August 20, 2003, 04:07:46 PM »

wow RST, thats almost exactly what i did.



download beta version
http://masula.com/qb45/kingsland.zip

keep in mind its just a beta for AI tests. so far, the enemy is pretty dumb, but smart enough to kick your but.

they will move in on you, attack you, capture your building, and resupply themselves when they run low on food.

they dont BUILD anything, .... yet Wink
heres the build tree and stats

unit name,att,def,move,command 1-6,gold,wood,stone,ore,food costs

villager,1,2,1,move,work,house,farm,fort,none,0,0,0,0,10
soldier,3,3,1,move,combat,capture,none,none,none,2,0,0,2,15
archer,4,2,1,move,fire,none,none,none,none,5,10,0,2,75
bishop,2,3,1,move,heal,convert,none,none,none,25,0,0,10,50
pikeman,5,3,2,move,combat,none,none,none,none,40,50,0,5,50
knight,5,4,2,move,combat,charge,none,none,none,75,10,0,15,25
paladin,6,5,3,move,combat,convert,none,none,none,100,50,0,20,35
king,6,6,2,move,combat,none,none,none,none,0,0,0,0,10
catapult,7,2,1,move,fire,none,none,none,none,100,150,0,25,0


building,att,def,commands 1-6,gold,wood,stone,ore,food

farm,1,0,none,none,none,none,none,none,1,15,0,0,0
house,1,1,mill,none,none,none,none,none,1,5,0,0,5
mill,1,2,hall,none,none,none,none,none,25,55,0,0,15
hall,3,3,villager,library,none,none,none,none,50,25,15,0,15
library,6,6,temple,none,none,none,none,none,100,50,50,15,50
fort,4,4,soldier,tower,none,none,none,none,130,60,20,0,30
tower,4,5,soldier,archer,keep,none,none,none,80,50,50,5,50
keep,6,5,soldier,archer,pikeman,none,none,none,120,75,150,15,100
temple,6,6,bishop,paladin,castle,none,none,none,200,90,260,35,75
castle,6,6,knight,catapult,none,none,none,none,220,160,400,50,500

buildings cant really attack or defend , they only add bonus to att and def when units are present.

the terrain bonuses arent in yet, so dont worry about terrain positioning.

you cant capture enemy building yet, you can heal using bishops yet.

and a few other small things... once i finish the AI this or next week, ill build 5 campaigns and a campaign editor... and release it.
Logged

url]http://qb45.think-new.com[/url]
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #20 on: August 20, 2003, 09:47:59 PM »

Oooh! Need <table> tags! Wink

Your game looks very nice (as usual (starquest)). As for building stuff, just check the daily needs of certain things and if it outstrips supply then build, else save money or build something "extra" (like another barracks for more army).
Logged

relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #21 on: August 21, 2003, 02:33:18 AM »

Hey, the screenies look good!!! Great job!!!
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
RST
Wandering Guru
***
Posts: 326



« Reply #22 on: August 21, 2003, 05:23:52 PM »

Quote from: "momoguru"
wow RST, thats almost exactly what i did.


What can I say. Great minds think alike.  Cheesy
Looks great. Can't wait for the final release.
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #23 on: August 21, 2003, 05:40:03 PM »

Overall, good idea, but lots of bugs/command issues (tedious)... also, can't win even if i control everything...
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
momoguru
Forum Regular
**
Posts: 131



« Reply #24 on: August 21, 2003, 11:46:34 PM »

what bugs exactly?

and yes you can win Smiley you gotta play it smart
Logged

url]http://qb45.think-new.com[/url]
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #25 on: August 22, 2003, 02:53:10 AM »

Momo: 6 lines of code could really make the flicker go away.

Try to use SetvideoSeg. You don't need to use a LIB in fact your code would work fine. And you can hide the cursor and make some cool animated mouse pointers depending on your action.

overall,good game!!! Would be a great one if you use SetVideoSeg.

;*)
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
momoguru
Forum Regular
**
Posts: 131



« Reply #26 on: August 22, 2003, 05:09:58 AM »

yeah, all my shite has flicker...

whats the code i need, or where can i find info on it, thanx btw Smiley
Logged

url]http://qb45.think-new.com[/url]
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #27 on: August 22, 2003, 08:57:06 AM »

Rel, momoguru: Flicker is minimal and wasn't such a problem.. I hardly noticed it before now Smiley... but it should be fixed.

momoguru: I *did* play it smart and I wiped out the enemy, but I still was unable to win after taking over all the buildings.

Well, here are some problems:
1) You can't move down if the screen blocks the down arrow...
2) You can't move one unit on to another...
3) You can't select a building until there are no units over it...
4) You can't win.

Inconveniences:
1) The movement process is slow and difficult. Automatic/keyboard next unit/next military unit /next civilian unit selection is good. Also arrow key control from the keyboard and mouse target control is even better.
2) It's unclear that the work icon is for ALL work. There should be some way to be able to find out what the button is (right click??) and what it does (shift+right click/left click??) I didn't have a clue how to work the Knight speed icon thingie.. and half the other buttons, for a while.

Game problems:
1) You need a value (0 or 1) to say whether it satisfies victory/defeat conditions. Farms and houses, for instance, cannot satisfy since they do not provide a regenerating ability. (only Halls and military buildings do that)
2) Intra-year, the "report button" to the left of the ">>" doesn't seem to have a function, and screen looks strange when pressed.
3) Is the archer supposed to only be able attack in ONE direction; northeast? That doesn't make much sense.

But again, it's an otherwise interesting game. Smiley
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
momoguru
Forum Regular
**
Posts: 131



« Reply #28 on: August 22, 2003, 11:06:49 AM »

okay, let me explain some stuff i left out

the move arrow isnt supposed be displayed off screen

you cant move units on top of each other, only one unit can occupy a square, like chess this forces u to place your unit carefully.

if a unit occupies a building, the build becomes under marshall control, you cant preform any building upgrade or build until the building is cleared of units.  units get an att/def bonus when occupying a building

and once again, you can win Smiley

unit movement can be slow and repetative, however you can use the ALL WORK button to send all workers to work where ever they are. so once you get a worker where u want, u dont need to command him individually, just hit the all work button next to the END TURN.

the arrow keys scroll the screen, right click also scrolls the screen when you right click near the map edges

the archers only attack in x formation
solder , pikeman attack in cross formation
knights attack in both (that knight speed icon is the CHARGE command. a special attack that knights do that give a bonus against foot troops.)

the attack boxes appear ONLY when an enemy is present in that square to attack. so if your archer only could attack NE, thats because that was the only square he was close enough to attack that had an enemy unit in it.

the intra-year report is currently beign used as a save game state.

there are alot of little things i need to add so that things are more self explainitory. but a REAME.txt can also help to explain how the game works. but think of it more like chess. for example, each unit gets 1 action per day. so if i have a solder unit 2 squares away from an enemy unit, i have to be careful not to move within his attack range. i want to make him move close to me, so that I get the initial attack. the attack always has the advantage, unless the defender is fortified in a building. when the attack strikes, the dfender can only counterattack with the remain units (this way his roll and bonuses are calculated ONLY for the remaining units... NOT what he started with before he took damage) this invites another level of strategy that requires careful placement of your troops. this is even more true when arrange mixed units for combat. positioning archers on the angle with soldiers alowing them to diliver a hit without taking a direct hit, and having the soldiers there to soak up the first hit. yes... you will sustain loses, BUT if you keep the unit alive, you can heal him up on a building after the enemy unit dies. its all about shuffeling your troops on and off buildings, and trying to balance the use of the building half production, half for defense. there are alot of other things i want to add, but for the most part... its just about ready.
Logged

url]http://qb45.think-new.com[/url]
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #29 on: August 22, 2003, 11:19:09 AM »

No, you don't understand. I re-captured all the buildings....
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Pages: 1 [2] 3 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!