---
warning Invalid argument supplied foreach() in .../game_ai.module on line 33
---

I can see that there is a way to set AI status to 1. Would be good (i.e. a feature request) to have an option to set a user account to be an AI, otherwise I have to go in and save a record in PHP.

Comments

Morbus Iff’s picture

Yeah, there will be a way to do so - the basic idea would be, eventually, that a user himself could set himself as an AI (given the proper permissions) for a certain battle, or for a vacations-length, etc. Very little of the UI is finished at the moment - the only real in-progress/relatively-ok stuff is under game/battle.

It has been a few weeks since I've reinstalled the module, so I'll take a look at 33. Tis odd.

Morbus Iff’s picture

Status: Active » Postponed (maintainer needs more info)

Hrm. I am unable to duplicate this... did you ever get the dsm() of "Game AIs have been created as Drupal user accounts. View active game AIs."?

Boris Mann’s picture

I got some errors on battles as well, but I think that's probably related to there not being any AI users.

I'm not sure if that message flashed up or not -- I'll re-run and see what I can find.

Morbus Iff’s picture

Yeah, battles would fail with no AI user. They require at least one, or at least one other human user.
The "one other human user" part doesn't have a UI to it yet, however.

Morbus Iff’s picture

Aaron Winborn reported something similar:


 <aaronwinborn> Fatal error: Call to undefined function game_state_save() in /home/aaronwin/domains/drupal-developer.org/public_html/sites/all/modules/game/game_ai/game_ai.install on line 26
 <aaronwinborn> should i post an issue, morbus?
 <aaronwinborn> ;)
 <aaronwinborn> looks good
 <aaronwinborn> the layout's messed up in zen fixed width
 <aaronwinborn> but i assume it's ok in garland
 <aaronwinborn> which is all that really matters
 <aaronwinborn> bunch of random errors during combat, but i know it's in devel
 <aaronwinborn> i never hit the opponent, either. plus after 2-3 rounds, the opponent gets a new blank party member
 <Morbus> aaronwinborn: that is all perplexing, and nothing i've ever been able to duplicate.
 <Morbus> aaronwinborn: so, yeah, i'd file reproducibble bugs, if possible. 
 <Morbus> aaronwinborn: there are no knonw bugs in the codebase, from my perspective.
 <Morbus> and i've been running it under E_ALL and E_STRICT, so there should be no devel errors either.
 <Morbus> i suspect all your errors are related to the game_state_save being missing.
 <Morbus> which is confusing - did you enable AI without Game, perhaps? OoOh, I wonder if, bootstrap wise, it ran AI before it ran Game...
 <Morbus> hrmm... that may be it... 
 <Morbus> if it enabled AI before it enabled Game (alphabetically), then i could see that error happening.
 <Morbus> and the game /requires/ AI right now - if the AI install failed, then things would blow up.
Boris Mann’s picture

Morbus -- I got the same blank party member.

Also, I checked, and there are 4 AI users in my users table. There where originally none (or rather, I got those errors ... but looking at UIDs, it looked like there are actually 4 auto-generated AI users).

Morbus Iff’s picture

Boris - yeah, it's starting to make some sense. My general feeling is:

* The AI installer ran first, before Game (because "A" comes before "G").
* The AI users were created cos I use user_save with no Game-specific code.
* The "flag these new users as AIs" FAILED, however, because I use game_state_save()...
* ... which doesn't yet exist because Game.module isn't installed.

So I've got to look into how to fix that.

Morbus Iff’s picture

I suspect this will work until I get things fixed in the code:

* I'll assume all five Game modules are enabled.
* Disable the AI module.
* Uninstall the AI module.
* Re-enable the AI module.

This will create three more AI users, but should properly flag them as AIs, since game_state_save() exists.

The reason I couldn't replicate this, at first, was because my system table had Game first, back from day 1, before the AI module existed. When I added the AI module, it was stored in the system table second, preventing me from reproducing the bug on a devel.module reinstall.

My current plan to fix this will be prefixes, I suspect: instead of Game/Core and AI, I'll have "Game Core" and "Game AI". I'm not entirely fond of that solution, but I like the other alternative even less: forcing two module page reloads (one to enable the Game.module, and then another to enable the AI module, which had previously been greyed out).

Boris Mann’s picture

Went to modules page, unchecked AI and saved.
Went to uninstall tab, no AI module listed there.
Went and deleted users previously created.
Went back to modules page and enabled AI.
No users created.

I'll leave this for a bit and test a future version. I also want to dig into the sample content you've created. I'm busy building out full CCK nodes for a campaign, and I want to understand nodes vs. ... funky stuff you're doing in modules.

The last time I did this 8 years ago, I was using XML files to load in content....

Morbus Iff’s picture

The rationale behind no-nodes is simple: lack of sharing, lack of dynamics. The rationale behind no-XML is similarly simple: no dynamics, no custom code (I don't think putting code in an XML file, and then running it via exec() is a good idea), and no hooks.

Boris Mann’s picture

Oh, I hear you. I'm thinking mainly about mass import of content ... or rather, import / export. As well as on site tools for creating new content that is outside of code.

Like I said, I'll dig in to code and think some more about this and stop polluting this thread :P

Morbus Iff’s picture

All content, in this particular design, will be created inside a .module file. To import it, you'd simply enable that file. See the README.txt for descriptions on how to create Mobs, for example. Anyways, pollute this ticket as much as you'd like (or create a new one, or start an email thread). I'd much rather talk about it then have it censored due to such vagaries as "off-topic" ;)

Morbus Iff’s picture

[Incidentally, I have no current plan for a build-your-own-mob creation toolkit. My goal is to always have game data sharable, and if it gets stored in the database, it immediately loses its capability to be easily shared (as soon as you start thinking about "bug fixes" for database content, things blow up). If a toolkit happened to create a fully functioning .module file, then I'd be a lot cooler with that, sure.]

Boris Mann’s picture

Issue tags: +AI
Morbus Iff’s picture

Status: Postponed (maintainer needs more info) » Fixed

I believe I have fixed this.

Get the new game_ai.install, disable/uninstall Game AI, reinstall Game AI.

Or, alternatively, just disable/uninstall everything you've got related to Game and try to start fresh again. I did a number of tests here, deleted my entries from the {system} table (which allowed me to reproduce the problem, etc.), and think I nailed it, thanks to nedjo's hack idea. Copious comments in the diff.

Boris Mann’s picture

Works!

Status: Fixed » Closed (fixed)
Issue tags: -AI

Automatically closed -- issue fixed for two weeks with no activity.