Monday, July 01, 2013

Gridiron Solitaire #61: AI and Boy That Text Stuff Is Annoying

With the new time scheme, there were issues with 4th quarter AI.

Everything but the 4th quarter can be heavily based on algorithms. The 4th quarter, though, has so many special situations related to scoring decisions and 4th down that it's impossible to drive it with formulas. It has to be handcrafted, and it's time consuming.

An example: there need to be individual decision trees for all of the following score groups.
<-21 p="">-21 to -18
-17 to -15
-14 to -11
-10 to -8

Why do there need to be individual decision trees? Because there are 4th down situations where the decision to kick a field goal or go for a touchdown (or go for it on 4th down) is heavily dependent on the exact score. Plus, the decisions change based on how much time is left, and those time-based decisions are different depending on score.

There's another entire set of trees for when the CPU is ahead.

I didn't understand this fully until this last round of revisions. And what I hope this means is that the new code will be much more dynamic. I've played quite a few games with the new version and it's been very, very solid.

I also added CPU kneel downs last week. Before, the CPU had to run a play in situations where they didn't need to. Example: 45 seconds left, and it's first down for the CPU. In real football, the quarterback would just kneel down twice and the game would be over, but in GS, the CPU had to call a regular running play, and if the human player had Big Play presses left, they could just spam the button and hope for a turnover.

That's bad.

Now, the CPU will run a kneel down play where appropriate. The max and min gains for a kneel down are zero yards, and the Big Play button isn't available. So time runs off, but the user can't spam a turnover.

There is, however, a 1/250 chance that the snap will cause a fumble.

I'll need to trap any errors that I unintentionally introduced, but this is the final foundation for the AI. It's as complete as I can make it, and it's very, very tough.

I also think I've come up with a way to handle text font size issues.

Until now, I've been tortured by font size issues. Even when a label will display properly on 99% of the systems, that last 1% (or 5%) have clipping issues. Arghhh.

I finally remembered, though, that Garret helped me with some excellent text sizing code for the newspaper headlines (actually, that's not fair--this is one of the two places in the program where he said "use this", and I did. And while it was only about ten lines, it was ten ultra-powerful, mega-quality lines).

What I realized is that where I have a group of controls (like on the Team History screen) that are the same width, if I find the widest possible content on any of those controls,
 and I can size the font for ALL of those controls at one time.

It works, and I'm very, very hopeful that it will take care of text display on any possible monitor. 

Site Meter