Switch Theme:

AI Design sans If-Then trees  [RSS] Share on facebook Share on Twitter Submit to Reddit
»
Author Message
Advert


Forum adverts like this one are shown to any user who is not logged in. Join us by filling out a tiny 3 field form and you will get your own, free, dakka user account which gives a good range of benefits to you:
  • No adverts like this in the forums anymore.
  • Times and dates in your local timezone.
  • Full tracking of what you have read so you can skip to your first unread post, easily see what has changed since you last logged in, and easily see what is new at a glance.
  • Email notifications for threads you want to watch closely.
  • Being a part of the oldest wargaming community on the net.
If you are already a member then feel free to login now.




Made in ca
Decrepit Dakkanaut





I'm currently working on solo-play and cooperative play for TITANOMACHINA because why not. It gives me something to consider outside of my comfort zone (solo-play and cooperative are apparently big things in board games these days) as I have previously had little to no interest in these things. I'm approaching the solo play first with the notion that cooperative play is just solo play with other people at the table. Possibly wrong, but it's a direction.

I've gotten a randomised way to set up buildings, where they've been redesigned as tiles, instead of players choosing with limits on how many friendly buildings they can be beside. Titans start in corners, or as close to, and facing the central square of the board.

I've got personality-specific system configurations for Titans as a cheap and easy way to settle on stuff sorted by drafting and army building in the player-vs-player version. Each Titan also has a specific order to their deck, to suit their personalities, rather than player's choice. The initiative can remain the same as in drafting, where players just roll and re-roll ties.

Activation of systems is simplified so that instead of drawing a hand of 5 cards, the AI flips over the top card on the Titan's deck and plays it by paying the next few cards from the deck as charge cost, or passing if doing so puts them over the 5-cards-paid/played-per-round limit (8 on the first round). When they pass they can flip over that unplayable card and use it to pay the charge value of the next card to be activated. This achieves mostly what the player-vs-player hand does in playing, paying, and passing, while taking the choice of which card to activate it out of the equation. Cards that have been played or paid go back into the bottom of the deck in the order specified for the deck during setup, instead of player's choice. It works whether the Titan has the initiative or not.

So relatively simple and straightforward.

Once a system is activated, however, there's again the matter of taking player choice out of the procedure. Most systems give the player a choice. Limbs require the player to choose whether they're attacking and/or moving, as well as what they'll attack and where they'll move. Weapons require the player to choose what they'll attack. Jump Jets move the Titan directly forward, but it's the player's choice how far only restricted by how far their effect roll takes them, and where the can land (not on buildings). Sensors are a choice between increasing the player's initiative and moving building sections around. Crew can move between squares on a Titan's system diagram and apply their repairs. Shields require a choice of where to place or move shield tokens.

Extra Armour does nothing unless the Titan is attacked, and Capacitors are basically a mulligan, which means they would need to re-jigged since they work specifically with allowing a player to draw extra cards to their hand of cards and the AI doesn't have hands of cards. Turrets just increase the Titan's arcs that round, so they're easy.

Weapons - Choose Targets within range, line of sight, arc.
Limbs - Choose Move and/or Attack; how to path, choose targets?
Jump Jets - Choose Move's ending square.
Sensors - Choose increase initiative or move building sections.
Crew - Choose new square, choose which damaged systems to repair if repair effect roll doesn't cover everything in that square.
Capacitor - Bonus to charging played systems?

I'm trying to think of a way of not using If-then trees. Any ideas? It would be good to tie it into the Personalities. Rapacious tries to destroy buildings for bonus VPs, Gracious tries to preserve buildings for bonus VPs, Pugnacious gets bonus VPs for destroying enemy systems, Sagacious get bonus VPs for non-destroyed systems; all at the end of the game.
   
Made in de
Regular Dakkanaut




Phew, that's a challenge...

Are you thinking of avoiding ANY if-statements or just the over usage?

The problem of avoiding IFs is that every reaction requires an if-statement. So if you avoid the IFs your "AI" acts completely random... so, not like an AI is supposed to work.

There are several alternatives to the classic "hit the player hard with a wall of text and a bunch of written down if-statements" kinda approach.

The AI-Deck from Kingdom Death is a great example.

But you might be interested in this:
https://www.youtube.com/watch?v=R9c-_neaxeU

It's about machine learning matchboxes... so very much an analog game AI, that model is from the 60s... and a first example of developing an AI.

This message was edited 1 time. Last update was at 2019/05/22 21:56:29


 
   
Made in us
Battlefield Tourist




MN (Currently in WY)

Man, i was just going to start a topic on AI design too! Nice work Nurglitch!

Support Blood and Spectacles Publishing:
https://www.patreon.com/Bloodandspectaclespublishing 
   
Made in de
Regular Dakkanaut




Another two cents that came to my mind:

I would consider not using the same cards for an AI.
Player cards are all about combination (a huge bunch of IFs) to challenge the players to take decisions. So playing a random card would resemble a total noob.
But a game AI should never act randomly or unpredictable. You want the players to be challenged and have fun by interacting with the AI. You don't want a crazy MF that jumps out of the shadows to stab you or a moron that "clips" into the wall.

If you want to minimize the IFs (I don't think that you can't avoid them entirely... if so I'd be glad to hear about it) you proparbly need at least one card deck to resemble the possible actions.

Each Card should have at least two possible effects (one for If the NPC is engaged in combat and one for if it's not).

If you add "personalities" you would need a card deck each. So for example: An "agressive" model always draws from the aggressive deck, while a "sneaky" model always draws from the deck with the mean stuff in it.

And if you count the IFs I used in this text, it should become clear that avoid IFs is a pretty darn hard job.

Edit: With respect to the huge ammount of cards you need for this... did you consider using a software for that?

This message was edited 1 time. Last update was at 2019/05/22 22:21:34


 
   
Made in us
Decrepit Dakkanaut






SoCal, USA!

Without "If-Then" logic, your robots are going to be dumb as rocks.

That works fine for mindless Zombies and Hordes, but poorly for sentient enemies. Even BFG Tyranid "Instinctive Behavior" had If-Then logic.

This message was edited 1 time. Last update was at 2019/05/23 05:37:09


   
Made in gb
Longtime Dakkanaut






I would suggest designing the if-then tree, and then seeing if it can be simplified into something like a table.

EG, if you find that the key decider on what to do is distance to desired target, then you can have the distance along the top of the table, and the different cards down the side of the table, with a result for each on the table. It can probably be put into groups to make more space for the details. Then, have a single table for each of your personalities.

Alternatively, have an AI section of your cards, and have the resulting action for each personality listed on each card. Then you can simply select the top card on the deck, and it will tell you what your AI is doing, and is linked to this card.

12,300 points of Orks
9th W/D/L with Orks, 4/0/2
I am Thoruk, the Barbarian, Slayer of Ducks, and This is my blog!

I'm Selling Infinity, 40k, dystopian wars, UK based!

I also make designs for t-shirts and mugs and such on Redbubble! 
   
Made in it
Perfect Shot Dark Angels Predator Pilot





Sesto San Giovanni, Italy

Well, there are two separate question here:
- can you program an AI without "If-Then-Else" structure AT ALL? The short answer is "no". You can build some deep learning algorithm but honestly it's not worth the effort (and it's a "black box" so we can't effectively prove what it does... but in the end there are very strong motivations to support the case that this still works under an if->then->else structure, even if hidden).
- can you program an AI without "If-Then-Else" TREES?
Of course! There are a lot of strategies, many well known, other relatively obscure. But almost all of them involve an "if->then" structure, managed slightly differently.

Both of the consideration above depend directly from the fact that this is how we (as human) understand causality.


In your case, I think a system based on fuzzy logic is the best. Structurally, it's like a "if-Then-Else" structure, but instead of having all possible behaviors with indention on a single tree, you have to split the possible action into simultaneous check on different "branches", independent one from another.

For example:
[Movement] - flee if under 20% damage ->ELSE-> towards enemy is a smellar size -> ELSE whatever
[Weapon] -> enemy attacking if possess specific gun -> ELSE -> nearest enemy -> Else whatever.
[Other systems] .... ok, you understood I think.

NOTE- You can also remove the "ELSE" if you can map all the different outcome of an action, effectively creating a table of action and reaction independent one from another. Of course, you have to check that there are no logical paradox in the different possible states.

This perfectly fit with your ideas of different "personalities", because you can compose the different possibilities freely, creating Titan with aggressive movement and conservative shooting... or whatever.

(Just to be clear, fuzzy logic is the one in a standard air conditioner system, if you want to study a practical easy example).



Another option (honestly don't know if it is easily programmable or already used outside of scientific experimentation and clinical trials) is a Bayesian system.

You determine specifics actions, and "how much" (in %) this action (and its logical opposite action) influences a specific parameter. This parameter has one (or more) threshold that enable a specific behaviors. The relationship between the event "y" and the final scoring is exactly by the Bayes' Theorem (the score is the final P(x|y))

So, for example, you may have a "Panic" state that activates when a Titan suffer continuous damage from an enemy it can't attack OR/AND when reduced under a X% of its Health,
OR/AND whatever.

The advantage of this system is that is not immediately recognizable as a causation chain, so it provides a much better illusion of a "real" AI. In other terms, to the event Y does not always follow automatically the behavior X. Y is repeated is enough to trigger X, but X can be triggered alternatively (or simultaneously) by any other Y events that you want to check.


P.S: much of the possible option you may use depends on the practical support. Into a videogame or an App, you can use either. With a boardgame, it's all a matter of complexity of the final table/product to the player. Maybe usability trumps realism or sophistication, in the end.
P.P.S: those of course are a couple of methods to implement an action-reaction behavior, that IMHO means "create and AI". Depending on the game, maybe you simply have meaningful random actions selected on different criteria, and for the final player the difference is unnoticeable (this is a If->Then->Else chain with a randomly determined output, but works anyway).

This message was edited 2 times. Last update was at 2019/05/23 13:19:58


I can't condone a place where abusers and abused are threated the same: it's destined to doom, so there is no reason to participate in it. 
   
Made in de
Regular Dakkanaut




Tables always tend to get very bulky. Because you'd need a table for each reasonable type of action. That's a bunch of additional reference sheets on the table.
You could add a behaviour table on the NPCs' cards but then you're very limited in complexity.
I would go with AI-decks with different effects on each card for different if-states or even different decks for each state.

First of all you have to define those states... for example:
1) engaged in melee combat
2) in range of an enemy
3) not in range

Depending on other partly non-combat based factors I would consider adding the following behaviour influencing properties:
1) not in cover
2) in cover
3) in contact/movement range of an objective
4) pinned/on the flight/broken morale etc.

Now you create 4 property decks with 3 state effects on each card. Since a model can fall into mutliple property categories at the same time you add a priorising value (personality) to each model. So for example: a model with the personality resilient would never choose a pinned action, while a survivalist will always choose the cover action if the model is in cover AND in contact with an objective and/or pinned.

Edit: All what @Cybtroll wrote.

This message was edited 1 time. Last update was at 2019/05/23 13:29:32


 
   
Made in ca
Decrepit Dakkanaut





@JohnHwangDD: The general idea was to avoid a long, convoluted program that players would have to follow, not avoid conditionals entirely (although, doing it entirely with disjuncts is possible...).

@Lord Royal: So yes, trying to avoid over-use. The easier to use the better. The Kingdom Death card deck is one neat way of doing it, and as it stands I'm going with the usual player-vs-player deck for activating systems in a similar way as described. But once they're activated I'm trying to think of a way to automate the decisions a player would otherwise make.

So there's a complication in that there's a similar set of decisions made at both levels. The first level is activation, where you essentially make a bet. A weapon system, for example, should have some targets within range, line of sight, and arc. Depending on the Titan's position in the initiative order that set of targets may change by the time it gets to resolve that activation.

There's also the additional issue of choosing a system on called shots. Maybe it's just a question of parsing it?

For example:
Weapon Systems
Activation: If target available (range, line of sight, arc) then activate, if not then pass.
Resolution: Attack target that, if destroyed, scores the most Victory Points. If targets are tied, choose building for Rapacious and Sagacious, Titan for Pugnacious and Gracious.

@some bloke: Having some AI text on the cards seems like a good idea. I'm toying with the idea of removing the art entirely, so there's a fair bit of space available.

This message was edited 1 time. Last update was at 2019/05/23 13:41:00


 
   
Made in gb
Longtime Dakkanaut






I would start by listing out all the available actions, and for each one listing why you would and wouldn't do it.

You could quite simply have a rank for each action, which would be defined by the models personality. you could list these as a symbol next to a number at the bottom of the card, to take up little space. Then, draw 3 cards, and pick the one with the highest number relating to the AI's personality.

some could include HP statistics (I've still not gotten around to reading your rules so don't know the ins and outs) where it becomes more or less likely as you lose health. if HP lost is "N", then you might have:
Attack: 10-N
fall back: 1 + N

that sort of thing.

Give weapon systems a value, which is independent of range, and the titan would use the "best" weapon they have which is in range. If there are defences which reduce the effectiveness of specific groups of weapons (EG laser weapons) then the defence will state that it reduces the rank of laser weapons by 1.

You could have an oversize card to represent AI titans or their pilots, which features their own statistics, personalities and have a table on the back to define what they will do. This would feature more characteristics than your user-controlled variety, as it will be to reflect the AI player.

I would have stats like:

Aggression
Control
Intelligence
Experience
Bravery

Which, coupled with personality, will give you logical choices when presented with "what to do" questions.

How does the game usually run with 2 players? It sounds like the players get 5 cards in a secret hand, and that they get to play 1 and pay with up to 4 (7 on round 1) to do so. The best way to emulate this with AI is to have the AI draw 5 cards, and then use some sort of ranking table to select the most useful one, and pay with the other 4. This means they play with an open hand, but never have a hand for you to anticipate.

Steps would be:

Draw 5 cards
Exclude any which cannot be afforded with the remaining 4 (EG, if you had 1 card which needed you to pay 5 points of card, but the other 4 were 1 point each, then it can't be used, so must be ignored).
Select from the personality/statistic table which card is ranked highest for this pilot and play that one.
If attacking, select highest ranking weapon which is in range of the target.


So, a pilot with high aggression will always rank attack cards & getting in range as highest. A pilot with high control will have a more balanced approach.

Thinking about it, you could simply have a value for each action, with personality dictating the target choices. Have the value modified by HP loss. Experience and bravery will reduce how much HP loss affects them. How much HP does a titan have? can you have a horizontal oversize card for AI titans, with a table with HP remaining on the top and the different actions down the side, with their priority order on each HP level to show how the pilot reacts as they receive more damage. This way they have a random element of receiving 5 cards, and a logical element of picking the best one they can afford, with a deciding element which changes as the game goes on.

You could also have an "AI Psychology" deck, of about 20 cards, which are dealt at milestones of the AI losing HP, and which adjust the priority of certain things. This would keep an element of interest, and reduce predictability of the AI through the game. EG, an AI might get halfway through, and get dealt a card which changes their personality to attack titans instead of buildings - whilst the player may have anticipated them focussing on buildings, and now be in a bad position.

Hope this helps!

Another thought, for positioning purposes - you could have an AI line on actions which defines if it's moving toward, away from or strafing left or right relating to the nearest enemy. These cards would be individually ranked for different personalities, and the AI line would mean nothing to the players who use the card, they can decide which way they move.

This message was edited 1 time. Last update was at 2019/05/23 15:33:01


12,300 points of Orks
9th W/D/L with Orks, 4/0/2
I am Thoruk, the Barbarian, Slayer of Ducks, and This is my blog!

I'm Selling Infinity, 40k, dystopian wars, UK based!

I also make designs for t-shirts and mugs and such on Redbubble! 
   
Made in gb
Fixture of Dakka






Have you looked at the Hostile activation tables for Blackstone Fortress?

Look along the columns for the first that applies, then roll a d20 to see what happens. If you want, you can replace the die roll with a different criterion; morale status, perhaps.
[Thumb - s-l1600.jpg]
Blackstone Fortress Hostiles cards

   
Made in ca
Decrepit Dakkanaut





@AndrewGPaul: I haven't but thank you for the picture. It doesn't really fit into the framework I established for player-vs-player, but I'll note that tables are a pretty compact way of writing an if-then tree. The reviews I've read for it tend to put the game-play as boring and grindy, although that's most solo or cooperative games I've played. I'd put that down to the need to randomise behaviour. Plus there's the hassle of that extra roll.

Following on from the Weapon system AI that some bloke inspired, I think, it's worth having that Personality's ordering of its Titan Deck do double-duty as an order of preference for internal processes, and scoring as an order of preference for stuff happening on the board:

Weapon Systems
Activation: If target available (range, line of sight, arc) then activate, if not then pass.
Resolution: Attack target that, if destroyed, scores the most Victory Points. If targets are tied, choose building for Rapacious and Sagacious, Titan for Pugnacious and Gracious.

Crew
Activation: If any systems are damaged (light, heavy) then activate, if not then pass.
Resolution: Move crew token to the System Diagram Square with damaged tokens on the highest systems in the priority of its Titan Deck.

Limbs
Activation:
Resolution:

Shields
Activation:
Resolution

Sensors
Activation:
Resolution:

Turret
Activation:
Resolution:

Capacitor
Activation:
Resolution:

Jump Jets
Activation:
Resolution:

Extra Armour
Activation:
Resolution:
   
Made in ca
Decrepit Dakkanaut





I realised that if I'm going to the kind of "Simplified keyword then Action A, else Action B" sort of thing I need to define a glossary of those keywords like 'target'

Example
Target: Building or Titan within range, line of sight, and arc of a Weapon or Limb

Also, I'm going to need to define a Titan's orientation, I think, or at least name the squares in the System diagram so that it's easier to orient the Titan relative to the board.

What the Capacitors would key off I'm not sure since in pvp it's a matter of whether the player wants a mulligan on five cards in their hand.
   
Made in de
Regular Dakkanaut




You don't need to define orientation. Movement and orientation should depend on if-statements. For example: If an enemy is in range, face that enemy... else if alerted move towards closest enemy (and face it) else move in a random direction (that's easily done by a scatter roll unless stated otherwise. It's pretty much analog game coding... mhm... maybe it could be inspiring to watch some Brackeys Tutorials (Youtuber for Unity3D and C#). In C# a simple 2D enemy AI works like this (Caution extremely simplyfied in pseudo code):
1) the model has some kind of detection sensors (Raycasts) that work like laser beams and measure the distance to certain objects (the distance to the next opponent for example or an obstacle), this way you define the states InAttackRange, InAggroRange, InMelee etc.
2) Having the states you can declare some if statements to trigger a certain behaviour...
for example if (InAttackRange && not InMelee){AttackWithRangedWeapon();}
3) Last thing you gotta do is to specify the behaviour sth like this:
AttackWithRangedWeapon: if(rangedWeaponEquipped){Shoot}else{Textlog enemy "Enemy out of range!"; move closer;}

If you want more individual behaviours try to find similarities and store everything else in model variables... I'm a lil bit uncreative right now... ask me later for an example. ;P

And you don't need a gloassary if you use cards with clear layout... besides imho it's much more fun to draw a card than to roll on a table.

This message was edited 1 time. Last update was at 2019/05/24 16:24:57


 
   
Made in ca
Decrepit Dakkanaut





Orientation kind of matters when much of the game is about the arcs of various systems on the Titan in relation to its position on the board. How shield tokens are placed, for example, if giving me fits because there isn't an easy way (yet) to define the optimal move in placing them.

Mind you, this is just design. So long as I have a starting point on paper for development it'll get figured out.
   
Made in us
Decrepit Dakkanaut






SoCal, USA!

Thinking about what you're trying to do, honestly, I think you're setting yourself up for failure.

Your game is has (relatively) complex units that are supposed to be managed by a competitive opponent who is capable of both strategic and tactical planning. Each turn should have tactical movement and action that support strategic positioning for subsequent turns to maximize future payoff. You just can't do that with a "simple" AI. And a complex AI is the sort of thing that you'd use a computer for, as opposed to a board game.

Counterpoint with Zombicide, where Zombies mindlessly move by the closest path, without any cleverness involved. They can be penned into a corner and manipulated by the players. The difference is that Zombicide was designed from the ground up as a co-op and dedicates a fair portion of the core rules to the AI.

Other games with "good" AI (e.g. Kingdom Death) or pure co-op design (e.g. Gloomhaven, Robinson Crusoe) are similarly designed ground-up to deliver a powerful co-op experience. In your case, you would need to deliver the sort of AI that Kingdom Death has, but even then, the typical Monster doesn't have as many options as your Titans.

IMO, your game really shouldn't be co-op, and trying to be all things to all people is a huge mistake. That's what Soda Pop Miniatures did with Super Dungeon Explore, grafting on a clunky "Arcade" co-op mode and watering down the primary PvP mode, compounded by the notion to tack on a RPG-eqsue campaign engine compatible with both play styles, when the core game engine and reward payoffs were simply not designed for any of that.

Sorry, but I think you should reconsider what game experience you want to deliver, and whether co-op is really what you should be working on. I get that there are big fans of co-op games right now, but this just might not be the right game for that.

   
Made in ca
Decrepit Dakkanaut





You know, at first I was going to point out that this was idle hobbying, but I have noticed recently I've been setting myself up for failure and should just quit now. Good point, John.
   
Made in us
Decrepit Dakkanaut






SoCal, USA!

Cool. Good luck with it.

   
 
Forum Index » Game Design
Go to: