Bunch more SUGGESTIONs

Started by SSH, Mon 31/01/2005 20:54:53

Previous topic - Next topic

SSH

Here's an idea: all games imported into the version that first implements lazy eval have their scripts converted so that all && and || become &&& and ||| (maybe this could be optional, with a dialog saying Yes or No to that conmversion and that the user back-up their game so that if it doesnt work with lazy eval then they can restore it). Then && and || are changed to match their C behaviour of lazy eval, but &&& and ||| exist in case someone wants or needs to have the old behaviour...

That keeps compatibility, but also allows the best behaviour going forward. Lazy eval would also improve game performance a little, I guess, too...

And CJ, you didn't respond to my const, preprocessor and forum suggestions...  :'(

12

Scorpiorus

Yep, an option would be nice. I'm not sure if there is a real need to introduce "new operators" (though I'd find them handy for certain tasks) since I believe their current strict behaviour can be simulated (to a certain degree) with '+' and '*' operators, which I'm going to replace '&&' with in "several" places, to ensure the assertion-handling mechanism I implemented will be working properly when a script compiled with a future version of AGS. :)

strazer

Quote from: Pumaman on Tue 01/02/2005 20:37:35
Firstly, yes this whole issue is because AGS does not do lazy evaluation on && and ||. (while it's called lazy, it's actually more complicated since the compiler would need to check the first side and generate JUMP instructions depending on the result).

And yes, it's something I would like to fix to make it behave in common with C, especially as you point out, statements like this will become more common and should be valid:

if ((ptr != null) && (ptr.ID > 0))

Tracker'd: http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=509

Kweepa

Sorry to dig up this old thread... (well, kind of sorry). :=

Here's an example of some code that's incredibly ugly without lazy evaluation (found while writing ags3d...)

Code: ags

while (j > numToDrawUnsorted && ShouldSwapPrims(pzj, pzi))
{
  // blah blah
  j--;
}


The solution is:

Code: ags

bool swap = ShouldSwapPrims(pzj, pzi);
while (j > numToDrawUnsorted && swap)
{
  // blah blah
  j--;
  if (j > numToDrawUnsorted)
  {
    swap = ShouldSwapPrims(pzj, pzi);
  }
}


ShouldSwapPrims is a very expensive function that shouldn't be called more than is necessary...
Yuck!
Still waiting for Purity of the Surf II

Gilbert

Though that function is expensive, I think your solution calls that function more or less the same number of times compared to using lazy evaluation already (maybe once more sometimes I guess), and I don't find it ugly.

Maybe you can do this like below to even free if from that possibly extra call?

Code: ags

bool swap = true;
while (j > numToDrawUnsorted && swap)
{
Ã,  Ã,  swap = ShouldSwapPrims(pzj, pzi);
    //Something to update pzj, pzi here?
  Ã,  j--;
}
if (j==numToDrawUnsorted) swap = ShouldSwapPrims(pzj, pzi); //if you need to call this once more to get the correct index, otherwise not required


edmundito

You know I'm obsessed with UI and such, and I thought of these looks for AGS the other day:




Basically is for it to have more of an Outlook 2003 look where the lists are placed to the panel and also remove te frame that gives the name of the section and just have that section highlighted. This way there is a lot more "real state" around the working area....

Of course, I'd like to have things like general settings and the palette editor moved to actual dialog screens, but that's just a whole other suggestion.
The Tween Module now supports AGS 3.6.0!

Rui 'Trovatore' Pires

No offense, but... ugh. Me no likey that look at all.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Kweepa

#27
I could give or take the borders to the panels on the left. I think they look nice but they clash with the other buttons on the right.
I like the layout, but what happens when you run out of room for, err, rooms?
It's not like we're generally hurting for screen real estate anyway. I never run AGS maximised.
And what is wrong with the general settings the way they are? This way you can make a change and instantly press Ctrl-T. If you put it in a dialog you'd have to perform the additional step of accepting the changes.

Things I'd find useful:
- the room menu always available (so that Ctrl-I and Ctrl-E work from anywhere)
- a quicker way of starting to script interactions (perhaps an option on the right click menu to avoid the whole New Interaction/Run Script/Edit Script malarkey).
- also, a way to get straight to the script/header of a module under development would be good. Perhaps we could have a checkbox that marks the module as under development, and then some menu items and shortcut keys to go to the code.
Still waiting for Purity of the Surf II

That Guy

#28
Gents,

I would like to mention, although I'm not sure how much bearing it has on the topic at hand, that Java (and J2ME, which is what I'm currently working in) does not perform "lazy" evaluation, either.

I was reminded of it reading this because one of our junior programmers was having trouble reproducing a bug in his game and had it traced to a line that read;

Code: ags

while ((list != null) && (list [x] != "some value"))
Ã,  Ã, doSomething();


And when I pointed out to him that the second list-sub-x test was causing the NullPointerException error QA was reporting, he went off on a tirade about how "that sort of thing works in C, I know it does!", forcing me to tackle him to the carpet and beat him into submission with my coffee mug.Ã,  When he calmed down, I mentioned to him that whether it "works" or not is irrelevant, because it made little sense from a logical point of view; you have no business testing an item in an array if the array itself may be null.

I advised him to restructure his code as such;

Code: ags

if (list != null)
Ã,  Ã, if (list[x] != "some value")
Ã,  Ã,  Ã,  doSomething();


Which, of course, made it work.Ã,  As Java was designed to avoid some of the common pitfalls of C coding conventions, I thought it would be relevant to mention that it doesn't do "lazy" evals.

Regards,
TG

Kweepa

Java definitely has short circuit evaluation. I've written plenty of Java and I'd have run into problems if it didn't. See here:
http://java.sun.com/developer/JDCTechTips/2002/tt1105.html#2
As for J2ME, oh dear. That sucks.
Still waiting for Purity of the Surf II

That Guy

yikes.  good catch.  As J2ME deviates so little from Java I'd have expected them to be identical in this case.  I know it's an issue in J2ME, 'cause it's bit us in the butts several times over the last few years.  ;D

Never mind then, carry on.

edmundito

#31
This is just another random suggestion, so I didn't want to start a new topic...

Let's say I have 4 characters, and I want to change their names to Pepe. Well, currently it's a bit tricky on AGS to do that because if you go to character[5], apparently, it returns some sort of memory addres and I guess it goes up to AGS_MAX_CHARACTERS.

So my suggestion would be for a way to check for it to set anything after the last character to null, that way one can just do something like:

short count = 0;
while(character[count] != nulll) {
  character[count].Name = "Pepe";
  count++;
}

Is that too much to ask?  :-[

And while we're on the topic of array, make the arrays a little more object-esque, so you could do:

int myarray[5];
int count = 0;
while (count < myarray.length) {
  myarray[count] = 0;
  count++;
}

and so on.
The Tween Module now supports AGS 3.6.0!

GarageGothic

Can't you just check for GetGameParameter(GP_NUMCHARACTERS, 0, 0, 0)?

edmundito

I knew I should have looked under GetGameParamenter...  :=
The Tween Module now supports AGS 3.6.0!

Elliott Hird

Quote from: Edmundo on Sun 28/08/2005 17:26:08
You know I'm obsessed with UI and such, and I thought of these looks for AGS the other day:
I like this much more than the suggestion in another thread. I really like the "modular" look it goes for, fits the scripting language with object-orientated scripting and all that.

monkey0506

Well it's actually pretty much the same thing, only on a larger scale.

Elliott Hird

Quote from: monkey_05_06 on Sun 16/10/2005 20:37:24
Well it's actually pretty much the same thing, only on a larger scale.
Actually, it's VERY different. Take a look at both.

monkey0506

It's not necessary to quote the post directly above you just FYI.

I'm not saying it's exactly the same thing, but it's similar, just like I said, on a much larger scale.

Akumayo

OOOOO OOO OOO, I have a suggestion!

PLEASE O' PLEASE CJ, make the Random function expanded.Ã,  Having only a maximum requires "if" and "else" functions just to run the desired result, here's an example of what I mean:

Code: ags

SetGlobalInt(1, Random(2));
if (GetGlobalInt(1)==0) {
 AddInventory(13);
 }
if (GetGlobalInt(1)==1) {
 AddInventory(14);
 }
if (GetGlobalInt(1)==2) {
 AddInventory(15);
 }


BUT if the Random was expanded to include:
Code: ags

Random(int min, int max);


Then you could simply run
Code: ags

AddInventory(Random(13, 15));


And get the same effect!!!
"Power is not a means - it is an end."

edmundito

Oh, I'll fix that for you:

function RandomEx(int min, int max) {
  return Random(max - min) + min;
}


.. I think. Someone, please, confirm my idiocy.
The Tween Module now supports AGS 3.6.0!

SMF spam blocked by CleanTalk