Thread Tools
Old December 6, 2001, 17:59   #1
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Utility Program for Keeping AI from Messing up with Production Released
First I'm sorry that I have never finished any announced projects in the past (I remember proposing 'Random Map Generator', 'Incremental Buying Automation', 'Oedo Year Alert', etc.) But this time I'm serious since I really see a good way for it to work!

First, I'm going to write a unitility program to KEEP AI FROM CHANGING YOUR CITY PRODUCTION.
Here's how it works: your city names can be as long as 15 characters, but you seldomly use all of them. Now, suppose you restrict your city name length to 10, then you have 4 positions to 'flag' your city information (the 11th place needs to be 00 so you only have 4 positions 12-15). The computer never bothers to clear the city names after a 00 so it is safe to do so. The program will copy the current production item of each city to the 15th position. Then, when your next turn comes, the production item recorded at the 15th position will be copied back to the city production byte. A flag will be set so this action will only take place once at the beginning of your turn.

Next, I'm going to expand the program to EFFECTIVELY GROUP YOUR CITIES TO PERFORM FUNCTIONS IN BATCHES.
Here's how it works: you go to the city screens and rename your cities to the 14th position, then rename them back if necessary (since some events depend on city names) so that the flags at positions 12-14 will be set. The Utility program then checks the flags to perform certain tasks for you. For example, suppose you want to hire all citizens as scientists in Moscow, Stalingrad, and 10 other cities. You go to each city and rename them so a flag 'a' is set at position 14. (Rename Moscow as Moscowaaaaaaaa, then rename it back to Moscow). Then run the utility program, and all the above cities will change all citizens to scientists (if city size >16 then the rest will be entertainers). Then you can do some adjustment of your own in each city. Similarly a flag 'b' at position 14 will hire all citizens as tax collectors; a flab '1' in position 13 will incremental buy a red guard for 100 golds automatically, and so on.

Last edited by Xin Yu; December 9, 2001 at 00:55.
Xin Yu is offline  
Old December 6, 2001, 21:27   #2
Goingonit
Warlord
 
Goingonit's Avatar
 
Local Time: 13:06
Local Date: October 31, 2010
Join Date: Apr 2001
Location: Toronto, Canada - AECCP member
Posts: 192
Here's my suggestion:

look for the 00. if the letter before the 00 is _, do something. This will make it easier for the user, as names can just be changed permanently rather than have "Moscowaaaaaaa" it will just be "MoscowA" or something. and is only 1 or 2 more lines.

check # of units in che city (I haven't looked at the hex-editing stiff in a while, is this possible?) if # of units < x, build a Red Guard (or something).

have prog change name back after function is complete
Goingonit is offline  
Old December 7, 2001, 01:49   #3
techumseh
Civilization II PBEMScenario League / Civ2-Creation
Emperor
 
techumseh's Avatar
 
Local Time: 12:06
Local Date: October 31, 2010
Join Date: Apr 1999
Location: of the frozen North.
Posts: 4,197
Sounds useful. I have an other idea for a utility, though I don't know it it's doable. Is it possible to have an event (in ToT preferably) which automatically triggers a batch file in the scenario directory?
techumseh is offline  
Old December 7, 2001, 02:41   #4
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
I need to know the starting byte for the city information block in memory. Angelo, Andrew Livings, anybody can help?

If the above information is not available I can ask the user to provide the name of his civ's first city, then search will start from here.

Goinonit: As I mentioned before some events depend on city names so changing Moscow to MoscowA may cause some events to fail. Checking number of units in a city involves more programming, but maybe doable.

Techumseh: if 'event' is programmed by you then I think it's doable; however if you meant extracting information from events.txt then there may be some technical difficulties.
Xin Yu is offline  
Old December 7, 2001, 07:53   #5
Goingonit
Warlord
 
Goingonit's Avatar
 
Local Time: 13:06
Local Date: October 31, 2010
Join Date: Apr 2001
Location: Toronto, Canada - AECCP member
Posts: 192
The byte where city info starts is not fixed.
Goingonit is offline  
Old December 7, 2001, 12:17   #6
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Quote:
Originally posted by Goingonit
The byte where city info starts is not fixed.
That's true, but Angelo's CSPL for TOT could extract city info, so I think there is a way to get around. I found that right before the city info block there is a string of repetitive 'FF 00 00's. Maybe we can use this to identify the start of city info block.
Xin Yu is offline  
Old December 8, 2001, 02:28   #7
techumseh
Civilization II PBEMScenario League / Civ2-Creation
Emperor
 
techumseh's Avatar
 
Local Time: 12:06
Local Date: October 31, 2010
Join Date: Apr 1999
Location: of the frozen North.
Posts: 4,197
What I have in mind is an automatic changing of BAT files, triggered by a pre-programmed event. For example, could you use an event, added to Capt. Nemo's Red Front, which automatically triggers the BAT file which changes the events, terrain, rules and units files every 6 months without having to save the game, run the BAT file and reload?
techumseh is offline  
Old December 8, 2001, 07:02   #8
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
LazyCiv Trial Version Released!
This utility is solely for keeping AI from messing up with your production. Works under WinME, civ2 MPE version. Should work under other Windows platforms. Does not work for TOT or FW.

Copy this file to your hard drive and make a shortcut for it on your desktop. Then, after MPE is running, click on the shortcut to run lazyciv.exe. You don't need to worry about AI changing your production in PBEM.

Very Important: If it is your first turn, launch Lazyciv AFTER you take control of your civ; however if you have already played a turn, then launch Lazyciv AFTER MPE IS RUNNING BUT BEFORE YOU TAKE CONTROL OF YOUR CIV (i.e., launch Lazyciv when you select your civ).
This is because the program saves your building queue in certain places, and before your first turn those places consist nothing but garbage. If you launch too early then your city productions will be replaced by those garbage. However if you launch too late in subsequent turns then the program will not have a chance to recover your building queue before you take control of your civ.

Any of your cities with names longer than 12 characters will be truncated for storing building queue and shield progress information. To make sure the program works, change your first city and last city in your F1 or F4 screen to long names (>12), if the names immediately get truncated then the program does work; if not, then you need to restart MPE and Lazyciv -- the starting position for city info block sometimes change, however if you try a couple of times it will come back to its normal starting position then the program should work.
Attached Files:
File Type: zip lazyciv.zip (29.8 KB, 26 views)
Xin Yu is offline  
Old December 11, 2001, 15:03   #9
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Only one download so far. Come on guys, I need your help! Please download it and test it in your next PBEM game. Thanks!

Next step: I'm going to create a micro-manager, and the layout is like this:

CityName Size_ Improvements Food__ Trade__ Science_ Tax____ Production_ Rush
Location_ H/C/U Cost, Maintain Cur/Tot Net/Tot _______ _______ Progress__ Cost

[Kalinin]_ 10___ (church)_____ 70____ 20____ 10_____ 10_____ (Red Guard)
25,35___ 5/2/3_ 40,1 [Sell]___ 100___ 30____ [Xinning] [Xinning] 20/30____ [25]

() -- pull down list
[] -- button, click on it trigger action: Go to city, sell improvement, Xinning (means changing all citizens to scientists or tax men), and rush-buying incrementally.

Also, a color schema will be used to indicate different status of the city:

City name: red=riot, yellow=content, blue=celebrating
Size (indicating status of the next turn):red=riot, yellow=content, blue=celebrating
H/C/U (happy, content, unhappy citizens): different colors indicating wonders/improvements for happy/content effect, and units for unhappy effect. (Green color for H means one citizen made happy by wonders/improvements, etc.)
food: current: grey=none, blue=harbor, yellow=supermarket, red=both; total: grey=none, red=granary.
trade: net: Colossus and superhighways will be indicated; total: airport will be indicated.
science, tax: grey: none, blue: +50% (Library), yellow: +100%, red: +150%, Gold: +200% or up.
Production: grey: none=vet, red=vet (indicating the city has barracks, airport, etc. for corresponding types of units).
Progress: current: grey: none, blue: +50% (factory), yellow: +100%, red: +150%. Total: KRC, offshore platform will be indicated.

Last edited by Xin Yu; December 11, 2001 at 15:11.
Xin Yu is offline  
Old January 10, 2002, 01:45   #10
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Today I have a major breakthrough in my programming. Now I have a workable version of my civmanager utility, although it can only rename cities. More functions will be added to the utility in the near future. Eventually I'll be able to change almost all aspects of my cities without the need of opening city windows. The only thing I may not be able to do is to assign workers to different squares, since this does not rely solely on city information.
Xin Yu is offline  
Old January 10, 2002, 14:06   #11
Marko
Prince
 
Local Time: 18:06
Local Date: October 31, 2010
Join Date: Sep 1999
Location: Tartu, Estonia
Posts: 393
Looks like promising project, Xin Yu.
Marko is offline  
Old January 13, 2002, 22:22   #12
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Update: Now it is a fully functional utility and I have fixed some bugs so it is not likely to break down while running. I have also refined the interface:
Have made the utility window always on top, shrink after losing focus, and expand after gaining focus.
Have added hot keys for actions.

Now I can edit all aspects of my cities.

However, to make it work is one thing, to make it perfect is another.

I need to change some of the cells from editable fields to pull down menus so that the user cannot enter illegal entries. This will also require extracting information from rules.txt file, which I have no idea how to do it at this moment.

I also want to add a function to allow using keystrokes for scrolling up and down, but so far no success.
Xin Yu is offline  
Old January 17, 2002, 13:44   #13
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Update: successfully added pull-down combo boxes. Successfully activated scroll bar from keyboard.

To do:

Automatically retrieve rules.txt and extract information so that one combo box will only present units/improvements you can build, and (when playing scenarios) another combo box will use the custom names for improvements in your cities instead of the standard ones. Calculation for rush buying costs can also be carried out.

Add color schemas to the texts.
Xin Yu is offline  
Old January 17, 2002, 14:55   #14
Marko
Prince
 
Local Time: 18:06
Local Date: October 31, 2010
Join Date: Sep 1999
Location: Tartu, Estonia
Posts: 393
Do you plan to add the feature that player can sell certain improvement in all cities? It would save much playing time..
Marko is offline  
Old January 17, 2002, 15:42   #15
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Here's what will be implimented: group numbers can be assigned to cities. When a cell is highlighted, the user can use hot keys to perform the same task (which has been performed for that cell, for example sell a barracks or rush buy a knight) to either the same group or all cities, whereever possible.
I also plan to add another feature: assign rally numbers to cities. Any unit sensored inside a rally city will automatically goto the city with the next rally number, with appropriate number of move points deducted (activated by a hot key as well). But this one is not easy.
Xin Yu is offline  
Old January 21, 2002, 03:34   #16
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Update:

Found the starting position of units block. The program needs a minor overhaul to increase speed (searching for units supported by each city is very time consuming, so unit information needs to be stored somewhere). Still haven't figured out how to read rules.txt file automatically from appropriate directory.
Xin Yu is offline  
Old January 29, 2002, 17:12   #17
Marko
Prince
 
Local Time: 18:06
Local Date: October 31, 2010
Join Date: Sep 1999
Location: Tartu, Estonia
Posts: 393
Hi Xin! Do you have any idea why AI sometimes changes production orders in ALL cities and moves some units in PBEM even when player has ended his turn with Ctrl+N and no cities are taken? That has happened at least in two PBEM games and is really annoying.

With your utility it is hopefully possible to easily change the production orders back but what to do with side-problem reported by FMK (only +1 shield between turns)?
Marko is offline  
Old January 29, 2002, 17:38   #18
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Marko,

AI is more likely to change production when you lose a city. However when one of your cities is under siege and you lose a unit inside the city, production change may also happen. The AI cannot move units out of the city since it does not have control of your civ once you hit Ctr-N. The only situation this could happen is probably caused by the 'turn 1 effect': the starting civ of the scenario is not the white civ, so strange things happen when the white (or other civs before the starting civ) starts to play.

AI usually wants 3 or more defense units (i.e., units with AI role = 2 (?)) in a city. So if you have too few defense units the change will be likely. If you don't have any defense units in a city the AI may even rush buy for you.

My utility was a trial version. Since nobody gave any feedbacks I have already forgot about it. I'll look into it and see what happened. Besides FMK who else uses this program? Do they counter the same problem? If it's only him then maybe it's system related.

The program starts with a flag set to 1. Then it checks if the human player is currently playing. If yes, the information stored in the last 3 bytes of city names is copied to city production bytes and the flag is changed to 0. Once the flag is zeroed, information flow is reversed, i.e., city production items and shield productions are written to the last 3 byes of city names. When the human civ is not playing the flag is set to 1 again.

So the program should be loaded after civ2 is running but before the human civ takes control of his civ. If the human has already gained control (i.e., he has gone through reports and now can move units), then at this time loading the utility program will cause a turn's production to be lost. Or, if the system is superfast then civ2 may process city productions faster than the utility program, in this case production will also be lost.

Last edited by Xin Yu; January 29, 2002 at 17:53.
Xin Yu is offline  
Old January 31, 2002, 05:35   #19
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Update: after days of searching, finally found the address which stores unit stats info. Each unit occupies 20 bytes, in the following order:
1-2: 16 flags (see 2, etc.)
3-4:00, can change but no effect
5: expiration tech number (FF=none)
6: domain
7: move times road modifier
8: range (number of turns in air)
9: attack
10: defense
11: health time 10
12: fire power
13: cost (number of rows)
14: carry
15: AI role
16: prerequisite (FF=none)
17-18: encyclopedia entry address
19-20: 00 (change will cause crash)

Except the last two bytes, all number can be changed. Including: change move to a number which is not a multiple of the road modifier; change health to a number which is not a multiple of 10;

Last edited by Xin Yu; January 31, 2002 at 11:53.
Xin Yu is offline  
Old February 7, 2002, 16:25   #20
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Further updates will be in my 'preview' thread.

BTW, Marko, I found FMK's post about the +1 shield only thing. It had nothing to do with my utility program since the program did not exist when he complained.
Xin Yu is offline  
Old March 7, 2002, 22:54   #21
klesh
King
 
klesh's Avatar
 
Local Time: 14:06
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Massachusetts, USA
Posts: 2,048
Yes, that odd problem was without the use of this utility.
I will use this next time I am in a PBEM (which should be very soon with my new secret project being done) I am kinda intimidated by using it. I am not really sure why. I'll re-read the write up and make sure I have everything down pat.

-FMK.
__________________
It's a wonder that you still know how to breathe.
klesh is offline  
Old March 28, 2002, 19:18   #22
MagyarCrusader
Civilization II PBEM
Emperor
 
MagyarCrusader's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Fascist
Posts: 3,161
Why didn't lazyciv work? I just tried it as America in 2194 PBEM with Pap. On the first turn I rush built 9grand worth of ammunition plants. I ended up losing Pearl Harbor and so the AI changed production in all my cities to mobile inf. Lazy civ didn't work. I did the test on the city names over 12 characters and that worked, but my production queue wasn't saved. Anyone know why?
__________________
Re-elect Bush!
MagyarCrusader is offline  
Old March 28, 2002, 20:23   #23
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
I downloaded the saved files and opened them using a hex editor. I found that none of the production information were recorded. Did you use Lazyciv on turn 1? You must use it on turn 1 in order for the information to be recorded, then on turn 2 you can retrieve them.

Last edited by Xin Yu; March 28, 2002 at 20:46.
Xin Yu is offline  
Old March 29, 2002, 00:34   #24
MagyarCrusader
Civilization II PBEM
Emperor
 
MagyarCrusader's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Fascist
Posts: 3,161
****... no I didn't.

Xin Yu, could you do me a really big favor? With the hex editor could you change the production queue for the American cities (except Midway) to Ammunition plant? That's what they were all building anyway.

Also for refrence, if I start using lazyciv now on turn 2 will it work for turn 3? Can I use lazyciv for other PBEMs or do I have to use it for one PBEM at a time?
__________________
Re-elect Bush!
MagyarCrusader is offline  
Old March 29, 2002, 02:53   #25
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
MagyarCrusader: I can change the production for you. However I don't want to do it for other civs of yours if they got messed up as well. Please check if you want your other civs' production be restored as well.

Yes if you do it on turn 2 you'll be able to see the result on turn 3. You can use the utility whenever you play PBEM, there's no restriction on which scenario to play, etc.

Since you are controlling more than one civ, I'm not sure if the utility will work properly. But you can always play as if you only control one civ -- i.e., save at the end of American's turn, then open the saved file and play as British, etc.
Xin Yu is offline  
Old March 29, 2002, 02:58   #26
MagyarCrusader
Civilization II PBEM
Emperor
 
MagyarCrusader's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Fascist
Posts: 3,161
Please, America will be just fine. They are the ones I spent over 9000 gold rush buying ammunition plants for. I don't believe I could continue the game with a realistic chance for victory after this. But for the British and USSR I'll just swallow my loses thusfar. I haven't rushbought much for them... yet. Anyway, thank you for answering my other questions as well. This is going to help me a lot.
__________________
Re-elect Bush!
MagyarCrusader is offline  
Old March 30, 2002, 04:24   #27
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
I accidentally broke my glasses. Now it is difficult for me to do hex editing. Please wait till Sunday.
Xin Yu is offline  
Old March 30, 2002, 14:24   #28
MagyarCrusader
Civilization II PBEM
Emperor
 
MagyarCrusader's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Fascist
Posts: 3,161
No problem. But thank-you very much for your help!
__________________
Re-elect Bush!
MagyarCrusader is offline  
Old March 31, 2002, 11:08   #29
Xin Yu
Apolytoners Hall of Fame
King
 
Xin Yu's Avatar
 
Local Time: 10:06
Local Date: October 31, 2010
Join Date: Dec 1969
Location: Emeryville, CA, USA
Posts: 1,658
Here you are. BTW I found a problem in the lazyciv utility program. I relied on the identification of 'human player' to initialize restoring of production but when another player was playing, the human player civ was reset to that player. Hence currently the lazyciv program will not work unless you hex edit the saved file to change the human player back to your civ. I have already given up the project so I'm not going to fix it now. It has to wait till I finish another project.
Attached Files:
File Type: net pap1.net (221.4 KB, 2 views)
Xin Yu is offline  
Old May 25, 2002, 18:46   #30
SlowThinker
GameLeagueApolytoners Hall of Fame
King
 
SlowThinker's Avatar
 
Local Time: 20:06
Local Date: October 31, 2010
Join Date: Jan 2000
Location: homeless, Praha, Czech Republic
Posts: 2,603
I consider the game beginning (where you have to go through many menus) tedious enough. Especially with PBEM repeated Enters are not very entertaining.

I imagine a tool that would be registered under Windows as the program that opens files with .sav, .hot, .net extensions. Then you could launch Civ2 files directly from the Explorer/WindowsCommander etc. by pressing the Enter key.
The Civ2 program writes the default menu choices (they are highlighted after the Civ2 launch) in the file Civ2.dat . The tool could remember appropriate Civ2.dat file for every savefile extension (.sav, .hot and .net). If asked to open a savefile it would rewrite the Civ2.dat file to the appropriate one, then send to the Civ2 program a necessary number of "Enter" keys and the full path of the savefile into the load file dialog.

I suppose the job is relatively easy: to start the Civ2.exe file as my subthread, to send "Enters" to the Civ2's message queue and to send the full filename into the open dialog (as individual characters or by the clipboard).
The problem is I am a poor programmer and besides I know almost nothing about Windows programming and so I would work on that a month. Xin, don't you want to do it?

Last edited by SlowThinker; May 25, 2002 at 20:11.
SlowThinker is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 14:06.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team