MgAl2O4 / FFTriadBuddy

FF14 Triple Triad helper
MIT License
129 stars 17 forks source link

Red starts bug #4

Closed Jayzucri closed 5 years ago

Jayzucri commented 5 years ago

Hey there! This app is wonderful, thanks for sharing!

I used it a lot on NPC, and encountered some issues while playing. If the player starts (blue), everything seems to be OK, but when the CPU starts, some rules can be broken, the chances to win seems to stay at 100% (to 0% if the game is lost), and it usually wants me to play impossible moves.

For the broken rules, the Chaos one doesn't let me choose a card when red plays first, making it impossible to follow as only one card can be played in Chaos. Only for screenshot play, the reverse rule makes it use unlogical plays, leading to a loss no matter what.

For example, I am currently playing against Gyorei in Yanxia, the screenshot play doesn't work for Reverse and Chaos rules, while the Simulation play only works when I play blue, and is usually broken when red starts (placing a card where the CPU just played).

Thanks for your time!

MgAl2O4 commented 5 years ago

First and most important thing (sorry if obvious, but it's really important): screenshot scan is quite fragile. If you scan during red turn, when cards are animating, when board is grayed out due to rules animation or sometimes even when board lost focus and is semi transparent - stuff is likely to break. Always scan on blue turn, when board on screen is in stable state.

Broken rules: either couldn't parse rules correctly or rule handling is broken. First one can be confirmed by checking Details box in overlay, will list all active rules on left panel. Second sounds bad, I haven't encountered that yet.

If list of rules in details is not matching, can you grab a screenshot for me to test on? There's also "super secret" debug mode for them - go to Play:Simulate tab, press F12 and press Apply rule ( cached image option unchecked) - this will save screenshot-markup.png next to executable with some extra markings about detected screen contents.

Chaos rule: which mode doesn't allow you to select active blue card? Screenshot should auto detect grayed out cards. In simulate, you can click on blue card (vertical blue deck view next to board) to switch active one. I assume it's about screenshot detection? If so, can you please send me a bugged out screenshot to work on?

Reverse rule: didn't see any issues myself, will investigate.

Jayzucri commented 5 years ago

About screenshot vs. simulation mode, both indicate the same most of the time, but in some situations I encountered.

First, in Simulate mode, here is a screenshot of what I encounter every time red starts, if red card is played here. image Game is stuck, win chance is 100%, and nothing can be done about it. I don't have a screenshot for in game, but the solution provided would be the same - a blue card will be highlighted, to be placed on red card plyed that turn. Note that it can happen any other turn, always on last red card placed, as showed on this screenshot. image On top of this, I can't choose another card to be played by clicking on blue cards on the left, only when red starts - it runs as it should when blue starts. Also, but I believe it is another face of the same problem, blue seems to play lots of wrong calls when red starts. I sometimes try to use the soft, but can play other things allowing victory when the game is supposed to be lost - red square.

About rule parsing, two things:

Thank again for your time.

MgAl2O4 commented 5 years ago

Huh, bugs in simulate mode are bizzare, this is supposed to be fool proof mode. Apparently it's not. Just tried doing exactly the same deck on exactly the same npc - no issues. image

Can you try running program with -log command line argument added? This will create debugLog.txt file next to executable with some additional information.

For example, game session on screenshot:

Game reset. Npc:'Seika', rules:'Reverse, Chaos', blue:[197:Shinryu], [211:Koja], [155:Colibri], [255:Lord and Lady Chai], [203:mossling], power:3
Solver win:59.95% (draw:28.65%), blue:Placed: 0, Available: [197:Shinryu], [211:Koja], [155:Colibri], [255:Lord and Lady Chai], [203:mossling], red:Placed: 0, Available: [107:Poroggo], [106:Crawler], [117:Roundrox], [18:Sahagin], [15:Ixal], [14:Amalj'aa], [17:Kobold]
Red> [3] Sahagin
Solver win:68.15% (draw:25.15%), blue:Placed: 0, Available: [197:Shinryu], [211:Koja], [155:Colibri], [255:Lord and Lady Chai], [203:mossling], red:Placed: 1, Available: [107:Poroggo], [106:Crawler], [117:Roundrox], [15:Ixal], [14:Amalj'aa], [17:Kobold]
Blue> [4] Shinryu, win 68.15%
>>  [3] Sahagin => Blue

Maybe solver doesn't see correct cards, I hope there will be something useful in log.

As for rule parsing: good to hear that screen -> rule is mostly working. It's supposed to refresh on scans, but if it stay the same afterwards it probably failed to find rule text on image and I'd need to check game screenshot.

Marking grayed out cards to play - yeah, definitely something bad with overlay. If you can make a screenshot when it happens, I'll check what broke there.

Jayzucri commented 5 years ago

Game reset. Npc:'Seika', rules:'Reverse, Chaos', blue:[197:Shinryu], [211:Koja], [155:Colibri], [255:Lord and Lady Chai], [203:mossling], power:3 Solver win:59.95 % (draw:28.65 %), blue:Placed: 0, Available: [197:Shinryu], [211:Koja], [155:Colibri], [255:Lord and Lady Chai], [203:mossling], red:Placed: 0, Available: [107:Poroggo], [106:Crawler], [117:Roundrox], [18:Sahagin], [15:Ixal], [14:Amalj'aa], [17:Kobold] Red> [3] Sahagin Blue> [3] Lord and Lady Chai, win 100.00 %

Here it is.

On rule parsing: Again, the rules are parsed and seen in Screenshot tab, just not updating on overlay. It still seems to be working well, just can't test well enough.

I'll make a screenshot for the greyed out card issue when I encounter it more.

MgAl2O4 commented 5 years ago

Log looks incomplete (missing solver line between Red and Blue card placements), but I can't find a reason for it in code. Pushed new version with even more logs around it (v20).

Can you try grabbing logs again please? Just so we're on the same page. expected test steps:

  1. update to v20, close, start again with -log (cmdline won't be saved during update's auto start)
  2. switch npc to Seika
  3. go to Simulate, place red Sahagin on same spot (middle row, left column, aka [3])
  4. confirm that program is still broken and close it
  5. send entire debugLog.txt file (should have just that single move + startup logs)
Jayzucri commented 5 years ago

After updating, the soft seems to work fine again, at least on said scenario. Here is the full log file: debugLog.txt

I'm going to test on actual NPCs to see if everything is OK.

Jayzucri commented 5 years ago

Everything seems OK, I can play with the good rules and the soft won't make me put any impossible move, but I encounter some new issues.

You can also see that the rules are not updated on the overlay, while it is in the Screenshot tab: image

Other weird thing I encountered with Simulate match: image That game didn't finish like that at all, I won, but as you can see in next screenshot, the game went wrong at some point. image

After I closed and opened the soft again, everything seems to work fine though. I played 5 straight games, some starting red and some blue, and won (or draw/lost from bad luck mostly). Issue seems to be changing sparring partner while keeping the soft open. I tested for both Screenshot and Simulate, with sometimes minor differences in played moves: image

To sum it up, everything seems to work fine now, but when I change partner during the session. I still have some points, and I tried to take as many screenshots as possible to show you. Just so you know, "Inversion" is "Reverse" in French, "Chaos" stays "Chaos", a non-English client works fine in Screenshot mode.

MgAl2O4 commented 5 years ago

Really appreciate detailed screenshots. Issues mentioned in last post:

  1. Missing refresh after npc change: fixed in code, will be in v22 (probably tomorrow, want to add cloud saves first). Unfortunately it does affect overlay solver.
  2. Wrong game flow in simulate: simulate window shows 3 rules (regional: Descention) while screenshot has just 2. I hope that was the cause of mismatch.
  3. Differences between steps taken in simulate and screenshot: it's ok, solver is affected by randomness to some degree. I'm using Monte Carlo algorithm (playing large amount of random games) instead of exploring all possibilities due to processing times.

This leaves just issue of hinting at grayed out card in Order or Chaos rules? If so, please try to grab a screenshot when it happens,

Jayzucri commented 5 years ago
  1. Nice, this is not an issue to close and reopen for every NPC, but it can be a problem for the Roulette rule, when a rule changes for each duel.
  2. Right, I didn't see it, rules must not have changed in Simulate mode after I changed NPC, making the game not working as intended
  3. On a game like this, would a min-max algorithm take much longer, as there are not a large amount of possible plays. It's working great right now, so it's just a question rather than a suggestion.

About greyed out cards, I played lots of games, including Chaos ones (and Roulette ones that were not parsed as Chaos), not encountering any issue with unplayable cards (but some times I had to click Capture again).

Waiting for v22 to test the rule refresh. Thank you very much for your time.

MgAl2O4 commented 5 years ago

Min max tree of game is pretty huge. Assuming best case scenario (all red cards are visible, red starts), we're talking about (5x8) x (4x7) x (4x6) x (3x5) x (3x4) x (2x3) x (2x2) x (1x1) ~= 1.1 10^8. starting with blue: 5.2 10^9, hiding red cards: too lazy to calculate, but way more.

I didn't give much thought on pruning tree, especially when all different rules are in play and can alter state of board dramatically (looking at you Combo...).

On the other hand, doing poor man's prediction with just 2k random games for each level 1 branch (worst case at blue start: 9 * 10^4) gives acceptable results and gets more accurate as game progresses.

Can it be better? Of course. Is it worth the effort? Not really, I don't mind if some games end up as losses or draws as long as most of them can be won.

MgAl2O4 commented 5 years ago

Closing for now (supposedly fixed), please open new issue if still running into problems.