Author Topic: Chart Function  (Read 6575 times)

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Chart Function
« on: August 08, 2011, 05:36:00 PM »


**********************UPDATE**************************

Here is a Charting Function for showing game statistics during the game.

Instructions for Installation:

Insert the Chartinit() command in the LevelSetup AFTER the map has been seeded.

Insert the Chart() command in the ScreenDraw function. If the map does not have a ScreenDraw function you will have to create one.

Place the function Chartinit() and the function Chart() anywhere you choose.

Instructions for Use:

When the game starts and the map is seeded, the Chart function will begin recording each Empire's number of asteroids owned  and also total seedlings at regular intervals.

Once two data points are recorded, a red Divider-marker will appear on the left edge of the screen. You can now activate the charts by placing the mouse cursor on the left side of the screen.

Placing the cursor in the top half will display Asteroids owned. Placing the cursor in the bottom half will dispay total seedlings.

The Player's Stats will be GREEN- Empire number One.

As more data points are accumulated, the chart will compress horizontally and vertically to fill the bottom half of the screen.

On the right of the screen are tick-marks. For the Asteroid Stats, each tick mark is an asteroid. For the Seedling Chart, each tick is an active Faction.

At the top left of the screen is a graphical representation of the current Factions who own at least one Asteroid, placed sequentially from left to right (0 to 11).

Unfortunately, the Faction colors in the game will only match the chart colors by coincidence, i.e. when pigs fly!

However, if an Empire appears anywhere on screen, the Empire Icon will be underlined and highlighted. This will enable you to correlate the Graph colors with the factions in the game.

Displaying the charts will significantly slow down the framerate, but otherwise will not affect game play.



Notes:

The default settings are 250 data points at 40 second/cycle intervals. This should be more than sufficient for most games. By adjusting these numbers you can increase the frequency resolution or extend the recording time (see code). I like using 20 second intervals but some longer games will then require more data points to complete. Sixty second intervals should be enough for practically any game! I am not sure how much CPU drain the data recording and other codes entail, but I haven't noticed any changes on my computer. However, activating and drawing the charts will significantly slow the framerate.

I have not encountered any maps that would not work with this function, and find it makes older maps I no longer play interesting again.

Updated Version 1.1: Empire Icons will now only appear when charts are activated. If a given Empire appears on screen, the Icon will brighten and be underlined. Those Empires on screen will also be highlighted in the Graphing area, making it easier to identify individual Factions.

Updated Version 1.2: Found a small error where tickmarks were not displaying properly in the Seedling Graph. Faction total was doubling. Removed offending line of code.

Any problems to report, glitches, suggestions, or comments are welcome!

Lost Seedling

« Last Edit: August 29, 2011, 08:33:18 AM by Lost Seedling »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Chart Function
« Reply #1 on: August 08, 2011, 07:47:32 PM »
Wow, awesome :>
This will be very handy for monitoring AI vs AI battles...

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Chart Function
« Reply #2 on: August 09, 2011, 02:46:41 AM »
That's precisely what inspired me to make it- just so I could monitor the AI wars better! I have a stripped-down version that runs continuously and monitors other stats, too- quite fascinating to watch. It's made me see things I never thought about before and actually made me a better player (I finally defeated Epic Empire the other day after a Zillion or so tries- something I thought was impossible, although I did have to cheat and expand my field of view). I was wondering, though, about something you said. You said that Infected does not work as well under accelerated conditions. Why would that be? Does the acceleration skip CPU cycles or something? I just can't understand why that would be. If the answer is too technical just aim me in the right direction.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Chart Function
« Reply #3 on: August 09, 2011, 08:17:41 AM »
It's because LevelLogic() operates at 60 frames per second regardless of the game speed.  When the game speed is increased, IAI is still making decisions at 60fps even though seedlings fly around at lightning speed, trees get built almost instantly, etc.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Chart Function
« Reply #4 on: August 09, 2011, 04:35:27 PM »
So...theoretically, running IAI, or for that matter any AI, in ScreenDraw() or LevelDraw() could speed it up, provided that any FPS lag wasn't too bad?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Chart Function
« Reply #5 on: August 09, 2011, 05:21:49 PM »
As far as I know they run at 60FPS too, irrespective of game speed.


IAI seems to have particular problems running at increased game speed, far more so than other pieces of code... perhaps owing to its complexity/inefficiency.

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Chart Function
« Reply #6 on: August 09, 2011, 06:15:27 PM »
As usual, your answers solve other mysteries I've been wondering about. It's all starting to make sense now.... :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Chart Function
« Reply #7 on: August 09, 2011, 06:21:51 PM »
Let me correct, all looped functions updates 60 times a second, ALL! :)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Chart Function
« Reply #8 on: August 09, 2011, 08:41:12 PM »
The screen draw function is called EVERY time the screen is drawn. If that is >60fps, then it would be faster, surely?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Chart Function
« Reply #9 on: August 10, 2011, 12:14:44 AM »
Well, as far as I know, the only thing speeding up when running the game faster is the GameTime...

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Chart Function
« Reply #10 on: August 10, 2011, 08:36:08 PM »
I uploaded a revised version which I think is much, much better. I was very dissatisfied with the confusion caused by the chart colors not matching the in-game faction colors. Now, if a faction appears on the screen, the Icons will light up and be underlined. The chart lines of that faction will also be highlighted. I also changed the Empire Icons to only appear when the charts are activated, improving game-performance slightly.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Chart Function
« Reply #11 on: August 10, 2011, 10:00:25 PM »
The screen draw function is called EVERY time the screen is drawn. If that is >60fps, then it would be faster, surely?

I think it will probably be limited to 60fps max.