Thread

Gesture problems (Sdk)

Gesture problems // Sdk

1  2  |  

edward sumerfield

Dec 14, 1998, 2:11am
The following source is supposed to initiate a gesture every time it hears
some chat message. However, it only does it once after the program starts and
never again. What am I doing wrong?

#include <stdio.h>
#include <stdlib.h>
#include <aw.h>

void avatar_chat() {
int rc;
printf("chatting\n");
aw_int_set (AW_MY_GESTURE, 5);
if (rc = aw_state_change ()) {
printf ("Unable to change state (reason %d)\n", rc);
exit (1);
}
}

main (int argc, char *argv[]) {

int instance = 0;
int rc;
int finished;

printf("Gesture\n");

/* check command line */
if (argc < 3) {
printf ("Usage: %s number password\n", argv[0]);
exit (1);
}

/* initialize Active Worlds API */
if (rc = aw_init (AW_BUILD)) {
printf ("Unable to initialize API (reason %d)\n", rc);
exit (1);
}

/* install handler for avatar_add event */
aw_event_set (AW_EVENT_CHAT, avatar_chat);

/* create bot instance */
if (rc = aw_create (0, 0, 0)) {
printf ("Unable to create bot instance (reason %d)\n", rc);
exit (1);
}

/* log bot into the universe */
aw_int_set (AW_LOGIN_OWNER, atoi (argv[1]));
aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, argv[2]);
aw_string_set (AW_LOGIN_APPLICATION, "SDK Sample Application #1");
aw_string_set (AW_LOGIN_NAME, "GreeterBot");
if (rc = aw_login ()) {
printf ("Unable to login (reason %d)\n", rc);
exit (1);
}

/* log bot into the world called "beta" */
if (rc = aw_enter ("Beta", 0)) {
printf ("Unable to enter world (reason %d)\n", rc);
exit (1);
}

/* announce our position in the world */
aw_int_set (AW_MY_TYPE, 12); // choose Aaron
aw_int_set (AW_MY_X, 100000);
aw_int_set (AW_MY_Z, 100000);
aw_int_set (AW_MY_Y, 0);
aw_int_set (AW_MY_YAW, 1800);
if (rc = aw_state_change ()) {
printf ("Unable to change state (reason %d)\n", rc);
exit (1);
}

aw_wait(-1);

/* close everything down */
aw_destroy ();
aw_term ();
return 0;
}

Edward Sumerfield

josh

Dec 14, 1998, 2:19am
Mmm... wheres the part that plays the gesture? :) all this is ok, jsut don't see
the part that plays the gesture :)

[View Quote] > The following source is supposed to initiate a gesture every time it hears
> some chat message. However, it only does it once after the program starts and
> never again. What am I doing wrong?
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <aw.h>
>
> void avatar_chat() {
> int rc;
> printf("chatting\n");
> aw_int_set (AW_MY_GESTURE, 5);
> if (rc = aw_state_change ()) {
> printf ("Unable to change state (reason %d)\n", rc);
> exit (1);
> }
> }
>
> main (int argc, char *argv[]) {
>
> int instance = 0;
> int rc;
> int finished;
>
> printf("Gesture\n");
>
> /* check command line */
> if (argc < 3) {
> printf ("Usage: %s number password\n", argv[0]);
> exit (1);
> }
>
> /* initialize Active Worlds API */
> if (rc = aw_init (AW_BUILD)) {
> printf ("Unable to initialize API (reason %d)\n", rc);
> exit (1);
> }
>
> /* install handler for avatar_add event */
> aw_event_set (AW_EVENT_CHAT, avatar_chat);
>
> /* create bot instance */
> if (rc = aw_create (0, 0, 0)) {
> printf ("Unable to create bot instance (reason %d)\n", rc);
> exit (1);
> }
>
> /* log bot into the universe */
> aw_int_set (AW_LOGIN_OWNER, atoi (argv[1]));
> aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, argv[2]);
> aw_string_set (AW_LOGIN_APPLICATION, "SDK Sample Application #1");
> aw_string_set (AW_LOGIN_NAME, "GreeterBot");
> if (rc = aw_login ()) {
> printf ("Unable to login (reason %d)\n", rc);
> exit (1);
> }
>
> /* log bot into the world called "beta" */
> if (rc = aw_enter ("Beta", 0)) {
> printf ("Unable to enter world (reason %d)\n", rc);
> exit (1);
> }
>
> /* announce our position in the world */
> aw_int_set (AW_MY_TYPE, 12); // choose Aaron
> aw_int_set (AW_MY_X, 100000);
> aw_int_set (AW_MY_Z, 100000);
> aw_int_set (AW_MY_Y, 0);
> aw_int_set (AW_MY_YAW, 1800);
> if (rc = aw_state_change ()) {
> printf ("Unable to change state (reason %d)\n", rc);
> exit (1);
> }
>
> aw_wait(-1);
>
> /* close everything down */
> aw_destroy ();
> aw_term ();
> return 0;
> }
>
> Edward Sumerfield

canopus

Dec 14, 1998, 5:36am
People seem to have more success if there is an explicit loop around aw_wait, and
the 'while aw_wait' loop includes the AW_MY_GESTURE instead of the CHAT event
handler. A global flag can be set in the CHAT event handler, and the loop can
respond to the flag with the GESTURE. At least this worked better for us with
AVATAR_CHANGE events and aw_say responses. (As if the "context" for the response
to the event wasn't the event itself.)

[View Quote] > The following source is supposed to initiate a gesture every time it hears
> some chat message. However, it only does it once after the program starts and
> never again. What am I doing wrong?
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <aw.h>
>
> void avatar_chat() {
> int rc;
> printf("chatting\n");
> aw_int_set (AW_MY_GESTURE, 5);
> if (rc = aw_state_change ()) {
> printf ("Unable to change state (reason %d)\n", rc);
> exit (1);
> }
> }
>
> main (int argc, char *argv[]) {
>
> int instance = 0;
> int rc;
> int finished;
>
> printf("Gesture\n");
>
> /* check command line */
> if (argc < 3) {
> printf ("Usage: %s number password\n", argv[0]);
> exit (1);
> }
>
> /* initialize Active Worlds API */
> if (rc = aw_init (AW_BUILD)) {
> printf ("Unable to initialize API (reason %d)\n", rc);
> exit (1);
> }
>
> /* install handler for avatar_add event */
> aw_event_set (AW_EVENT_CHAT, avatar_chat);
>
> /* create bot instance */
> if (rc = aw_create (0, 0, 0)) {
> printf ("Unable to create bot instance (reason %d)\n", rc);
> exit (1);
> }
>
> /* log bot into the universe */
> aw_int_set (AW_LOGIN_OWNER, atoi (argv[1]));
> aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, argv[2]);
> aw_string_set (AW_LOGIN_APPLICATION, "SDK Sample Application #1");
> aw_string_set (AW_LOGIN_NAME, "GreeterBot");
> if (rc = aw_login ()) {
> printf ("Unable to login (reason %d)\n", rc);
> exit (1);
> }
>
> /* log bot into the world called "beta" */
> if (rc = aw_enter ("Beta", 0)) {
> printf ("Unable to enter world (reason %d)\n", rc);
> exit (1);
> }
>
> /* announce our position in the world */
> aw_int_set (AW_MY_TYPE, 12); // choose Aaron
> aw_int_set (AW_MY_X, 100000);
> aw_int_set (AW_MY_Z, 100000);
> aw_int_set (AW_MY_Y, 0);
> aw_int_set (AW_MY_YAW, 1800);
> if (rc = aw_state_change ()) {
> printf ("Unable to change state (reason %d)\n", rc);
> exit (1);
> }
>
> aw_wait(-1);
>
> /* close everything down */
> aw_destroy ();
> aw_term ();
> return 0;
> }
>
> Edward Sumerfield

edward sumerfield

Dec 14, 1998, 11:31am
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Its in the avatar_chat function. Specifically, the following two lines.
<p>&nbsp;&nbsp; aw_int_set (AW_MY_GESTURE, 5);
<br>&nbsp;&nbsp; if (rc = aw_state_change ()) {
[View Quote]

walter knupe

Dec 14, 1998, 4:11pm
You have to reset the gesture to 0 and then back to 5 to have the others
pick it up again. The resetting to 0 is done automatically by the awbrowser
after you clicked on a gesture begin

Walter


Edward Sumerfield schrieb in Nachricht <36748FD4.84162BA5 at poboxes.com>...
>The following source is supposed to initiate a gesture every time it hears
>some chat message. However, it only does it once after the program starts
and
>never again. What am I doing wrong?


>void avatar_chat() {
> int rc;
> printf("chatting\n");
> aw_int_set (AW_MY_GESTURE, 5);
> if (rc = aw_state_change ()) {
> printf ("Unable to change state (reason %d)\n", rc);
> exit (1);
> }
>}
>

edward sumerfield

Dec 14, 1998, 5:01pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Cool. So If I do
<p>&nbsp;&nbsp;&nbsp; aw_int_set(AW_MY_GESTURE, 0);
<br>&nbsp;&nbsp;&nbsp; aw_state_change();
<br>&nbsp;&nbsp;&nbsp; aw_int_set(AW_MY_GESTURE, 5);
<br>&nbsp;&nbsp;&nbsp; aw_state_change();
<p>It will work every time?
[View Quote]

roland vilett

Dec 14, 1998, 6:19pm
This is a multi-part message in MIME format.

------=_NextPart_000_0019_01BE275C.0A2F5060
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

No, this won't work. In order for the gesture to be reset, the other =
browsers have to see the change. Remember that multiple calls to =
aw_state_change() are not propagated out to other clients more than once =
per second. Your code will simply change your state in the server, and =
then immediately change it back to the way it was before. To everyone =
else in the area, you will appear to have maintained gesture #5 all =
along.

The correct way to do this is to add code to your bot to always change =
the gesture back to 0 again a few seconds after it was changed to 5. =
The easiest way to do this is to note the current time when you set the =
gesture to 5 (the Windows system call GetTickCount() returns a handy =
time value in milliseconds), and then in your main event loop =
periodically check this saved value against the current time. You will =
need to modify your current call to aw_wait() since your program now =
needs to take action in addition to simply responding to events.

The relevant code changes could look something like this:

#define FIVE_SECONDS 5000

unsigned long reset_gesture;

void avatar_chat() {
int rc;
printf("chatting\n");
aw_int_set (AW_MY_GESTURE, 5);
if (rc =3D aw_state_change ()) {
printf ("Unable to change state (reason %d)\n", rc);
exit (1);
}
reset_gesture =3D GetTickCount() + FIVE_SECONDS;
}


/* replace aw_wait(-1) with this: */

while (!aw_wait (1000))
if (reset_gesture && reset_gesture < GetTickCount ()) {
/* time to set our gesture back to 0 again */
aw_int_set (AW_MY_GESTURE, 0);
aw_state_change ();
reset_gesture =3D 0;
}


[View Quote] It will work every time?=20

[View Quote] You have to reset the gesture to 0 and then back to 5 to have =
the others=20
pick it up again. The resetting to 0 is done automatically by =
the awbrowser=20
after you clicked on a gesture begin=20
Walter=20

Edward Sumerfield schrieb in Nachricht =
<36748FD4.84162BA5 at poboxes.com>...=20
>The following source is supposed to initiate a gesture every =
time it hears=20
>some chat message. However, it only does it once after the =
program starts=20
and=20
>never again. What am I doing wrong?=20

>void avatar_chat() {=20
> int rc;=20
> printf("chatting\n");=20
> aw_int_set (AW_MY_GESTURE, 5);=20
> if (rc =3D aw_state_change ()) {=20
> printf ("Unable to change state (reason %d)\n", rc);=20
> exit (1);=20
> }=20
>}=20
>


------=_NextPart_000_0019_01BE275C.0A2F5060
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type><!doctype html public "-//w3c//dtd html 4.0 =
transitional//en">
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>No, this won't work.&nbsp; In order =
for the=20
gesture to be reset, the other browsers have to see the change.&nbsp; =
Remember=20
that multiple calls to aw_state_change() are not propagated out to other =
clients=20
more than once per second.&nbsp; Your code will simply change your state =
in the=20
server, and then immediately change it back to the way it was =
before.&nbsp; To=20
everyone else in the area, you will appear to have maintained gesture #5 =
all=20
along.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The correct way to do this is to add code to your =
bot to=20
always change the gesture back to 0 again a few seconds after it was =
changed to=20
5.&nbsp; The easiest way to do this is to note the current time when you =
set the=20
gesture to 5 (the Windows system call GetTickCount() returns a handy =
time value=20
in milliseconds), and then in your main event loop periodically check =
this saved=20
value against the current time.&nbsp; You will need to modify your =
current call=20
to aw_wait() since your program now needs to take action in addition to =
simply=20
responding to events.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>The relevant code changes could look =
something=20
like this:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>#define =
FIVE_SECONDS&nbsp;&nbsp;&nbsp;=20
5000</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>unsigned long reset_gesture;</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>void avatar_chat() {<BR>&nbsp; int rc;<BR>&nbsp;=20
printf(&quot;chatting\n&quot;);<BR>&nbsp; aw_int_set (AW_MY_GESTURE,=20
5);<BR>&nbsp; if (rc =3D aw_state_change ()) {<BR>&nbsp;&nbsp;&nbsp; =
printf=20
(&quot;Unable to change state (reason %d)\n&quot;, =
rc);<BR>&nbsp;&nbsp;&nbsp;=20
exit (1);<BR>&nbsp; }</DIV>
<DIV>&nbsp; reset_gesture =3D GetTickCount() + FIVE_SECONDS;</DIV>
<DIV>}<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>/* replace aw_wait(-1) with this:=20
*/</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>while (!aw_wait (1000))</FONT></DIV>
<DIV><FONT size=3D2>&nbsp; if (reset_gesture &amp;&amp; reset_gesture =
&lt;=20
GetTickCount ()) {</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp; /* time to set our gesture back to 0 =
again=20
*/</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp; aw_int_set (AW_MY_GESTURE, =
0);</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp; aw_state_change ();</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp; reset_gesture =3D 0;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp; }</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
[View Quote] ------=_NextPart_000_0019_01BE275C.0A2F5060--

edward sumerfield

Dec 14, 1998, 6:35pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
I see. Its a perspective change from me. I keep making the mistake of see
actions as changes in the server but really they are changes in other browsers
propagated by a 1 second polling server.
<p>You know this means I am going to have to rethink my class library infrastructure
again. Doh.
<p>A performance question for you. You say that the server updates the
browsers every second. Is there any kind of propagation delay noticed as
the number of browsers increases or does the max logins per world keep
this to a minimum.
<p>You recommend resetting the gesture after 5 seconds. A gesture sequence
takes a certain amount of time to run in a browser. If I set to gesture
to 5 and reset to 0 in two seconds will it stop the currently running sequence?
<p>Is there some timing advantage to noting long gesture sequence compared
to short sequences and varying the reset time interval appropriately?
[View Quote] </body>
</html>

canopus

Dec 15, 1998, 1:10am
The need to separate state_changes by a timed lapse of 1-5 seconds
should be in the documentation. It came up earlier in connection with
bot movements (MY_X, MY_Y, MY_Z, MY_YAW); now it comes up again in
connection with bot gestures (MY_GESTURE). The example given would be
appropriate, since it also shows that there are (still undocumented) two
state_changes needed in certain cases, such as gestures. New programmers
are reluctant to read through over 1000 newsgroup messages looking for
solutions.

[View Quote] > Part 1.1 Type: Plain Text (text/plain)
> Encoding: quoted-printable

roland vilett

Dec 15, 1998, 1:17am
This is a multi-part message in MIME format.

------=_NextPart_000_0009_01BE2796.6F0AA9A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Whether or not their would be increased lag due to an increased number =
of users would depend on the outgoing bandwidth of the server. Servers =
with a high user load and low bandwidth would experience poor response =
time for all transactions, position updates included, as you would =
expect. If the server has adequate bandwidth available, though, I don't =
think you would ever notice a difference in propagation delay whether =
there was 1 user or 100 users in the world.

I chose 5 seconds because that's what the AW browser does...5 seconds =
after signaling a gesture, it returns to 0. I'm actually not sure =
whether a shorter timeout would cause the gesture to terminate =
prematurely or not...my suspicion is not, since gestures can overlap =
(e.g. you can start a wave before completing the angry sequence, and the =
animation code will attempt to do both at the same time.) To know for =
sure I'd have to dive deep into the avatar animation code, which is not =
something I particularly relish (it isn't my code.) A simple experiment =
with a bot though would say for sure...

-Roland

[View Quote] A performance question for you. You say that the server updates the =
browsers every second. Is there any kind of propagation delay noticed as =
the number of browsers increases or does the max logins per world keep =
this to a minimum.=20

You recommend resetting the gesture after 5 seconds. A gesture =
sequence takes a certain amount of time to run in a browser. If I set to =
gesture to 5 and reset to 0 in two seconds will it stop the currently =
running sequence?=20

Is there some timing advantage to noting long gesture sequence =
compared to short sequences and varying the reset time interval =
appropriately?=20

[View Quote] No, this won't work. In order for the gesture to be reset, the =
other browsers have to see the change. Remember that multiple calls to =
aw_state_change() are not propagated out to other clients more than once =
per second. Your code will simply change your state in the server, and =
then immediately change it back to the way it was before. To everyone =
else in the area, you will appear to have maintained gesture #5 all =
along. The correct way to do this is to add code to your bot to always =
change the gesture back to 0 again a few seconds after it was changed to =
5. The easiest way to do this is to note the current time when you set =
the gesture to 5 (the Windows system call GetTickCount() returns a handy =
time value in milliseconds), and then in your main event loop =
periodically check this saved value against the current time. You will =
need to modify your current call to aw_wait() since your program now =
needs to take action in addition to simply responding to events. The =
relevant code changes could look something like this: #define =
FIVE_SECONDS 5000 unsigned long reset_gesture; void avatar_chat() {=20
int rc;=20
printf("chatting\n");=20
aw_int_set (AW_MY_GESTURE, 5);=20
if (rc =3D aw_state_change ()) {=20
printf ("Unable to change state (reason %d)\n", rc);=20
exit (1);=20
} reset_gesture =3D GetTickCount() + FIVE_SECONDS;} /* =
replace aw_wait(-1) with this: */ while (!aw_wait (1000)) if =
(reset_gesture && reset_gesture < GetTickCount ()) { /* time to set =
our gesture back to 0 again */ aw_int_set (AW_MY_GESTURE, 0); =
aw_state_change (); reset_gesture =3D 0; } Edward Sumerfield wrote =
in message <36756086.CBC209DB at poboxes.com>...=20
Cool. So If I do=20
aw_int_set(AW_MY_GESTURE, 0);=20
aw_state_change();=20
aw_int_set(AW_MY_GESTURE, 5);=20
aw_state_change();=20

It will work every time?=20

[View Quote] You have to reset the gesture to 0 and then back to 5 to =
have the others=20
pick it up again. The resetting to 0 is done =
automatically by the awbrowser=20
after you clicked on a gesture begin=20
Walter=20

Edward Sumerfield schrieb in Nachricht =
<36748FD4.84162BA5 at poboxes.com>...=20
>The following source is supposed to initiate a gesture =
every time it hears=20
>some chat message. However, it only does it once after =
the program starts=20
and=20
>never again. What am I doing wrong?=20

>void avatar_chat() {=20
> int rc;=20
> printf("chatting\n");=20
> aw_int_set (AW_MY_GESTURE, 5);=20
> if (rc =3D aw_state_change ()) {=20
> printf ("Unable to change state (reason %d)\n", =
rc);=20
> exit (1);=20
> }=20
>}=20
>


------=_NextPart_000_0009_01BE2796.6F0AA9A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type><!doctype html public "-//w3c//dtd html 4.0 =
transitional//en">
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>Whether or not their would be =
increased lag due=20
to an increased number of users would depend on the outgoing bandwidth =
of the=20
server.&nbsp; Servers with a high user load and low bandwidth would =
experience=20
poor response time for all transactions, position updates included, as =
you would=20
expect.&nbsp; If the server has adequate bandwidth available, though, I =
don't=20
think you would ever notice a difference in propagation delay whether =
there was=20
1 user or 100 users in the world.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>I chose 5 seconds because that's =
what the AW=20
browser does...5 seconds after signaling a gesture, it returns to 0. I'm =

actually not sure whether a shorter timeout would cause the gesture to =
terminate=20
prematurely or not...my suspicion is not, since gestures can overlap =
(e.g. you=20
can start a wave before completing the angry sequence, and the animation =
code=20
will attempt to do both at the same time.) To know for sure I'd have to =
dive=20
deep into the avatar animation code, which is not something I =
particularly=20
relish (it isn't my code.)&nbsp; A simple experiment with a bot though =
would say=20
for sure...</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>-Roland</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
[View Quote] =
href=3D"mailto:367576AC.18445D02 at poboxes.com">367576AC.18445D02 at poboxes.c=
om</A>&gt;...</DIV>I=20
see. Its a perspective change from me. I keep making the mistake of =
see=20
actions as changes in the server but really they are changes in =
other=20
browsers propagated by a 1 second polling server.=20
<P>You know this means I am going to have to rethink my class =
library=20
infrastructure again. Doh.=20
<P>A performance question for you. You say that the server updates =
the=20
browsers every second. Is there any kind of propagation delay =
noticed as the=20
number of browsers increases or does the max logins per world keep =
this to a=20
minimum.=20
<P>You recommend resetting the gesture after 5 seconds. A gesture =
sequence=20
takes a certain amount of time to run in a browser. If I set to =
gesture to 5=20
and reset to 0 in two seconds will it stop the currently running =
sequence?=20
<P>Is there some timing advantage to noting long gesture sequence =
compared=20
to short sequences and varying the reset time interval =
appropriately?=20
[View Quote] milliseconds), and then in your main event loop periodically =
check this=20
saved value against the current time.&nbsp; You will need to =
modify your=20
current call to aw_wait() since your program now needs to take =
action in=20
addition to simply responding to events.</FONT>&nbsp;<FONT=20
color=3D#000000><FONT size=3D-1>The relevant code changes could =
look=20
something like this:</FONT></FONT>&nbsp;<FONT =
color=3D#000000><FONT=20
size=3D-1>#define FIVE_SECONDS&nbsp;&nbsp;&nbsp;=20
5000</FONT></FONT>&nbsp;<FONT size=3D-1>unsigned long=20
reset_gesture;</FONT>&nbsp;void avatar_chat() { <BR>&nbsp; int =
rc;=20
<BR>&nbsp; printf(&quot;chatting\n&quot;); <BR>&nbsp; aw_int_set =

(AW_MY_GESTURE, 5); <BR>&nbsp; if (rc =3D aw_state_change ()) {=20
<BR>&nbsp;&nbsp;&nbsp; printf (&quot;Unable to change state =
(reason=20
%d)\n&quot;, rc); <BR>&nbsp;&nbsp;&nbsp; exit (1); <BR>&nbsp; =
}&nbsp;=20
reset_gesture =3D GetTickCount() + FIVE_SECONDS;}&nbsp;<FONT=20
color=3D#000000><FONT size=3D-1>/* replace aw_wait(-1) with =
this:=20
*/</FONT></FONT>&nbsp;<FONT size=3D-1>while (!aw_wait =
(1000))</FONT><FONT=20
size=3D-1>&nbsp; if (reset_gesture &amp;&amp; reset_gesture &lt; =

GetTickCount ()) {</FONT><FONT size=3D-1>&nbsp;&nbsp; /* time to =
set our=20
gesture back to 0 again */</FONT><FONT size=3D-1>&nbsp;&nbsp; =
aw_int_set=20
(AW_MY_GESTURE, 0);</FONT><FONT size=3D-1>&nbsp;&nbsp; =
aw_state_change=20
();</FONT><FONT size=3D-1>&nbsp;&nbsp; reset_gesture =3D =
0;</FONT><FONT=20
size=3D-1>&nbsp; }</FONT>&nbsp;&nbsp;Edward=20
[View Quote] aw_state_change ()) { <BR>&gt;&nbsp;&nbsp;&nbsp; printf=20
(&quot;Unable to change state (reason %d)\n&quot;, rc);=20
<BR>&gt;&nbsp;&nbsp;&nbsp; exit (1); <BR>&gt;&nbsp; } =
<BR>&gt;}=20
=
<BR>&gt;</P></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></=
HTML>

------=_NextPart_000_0009_01BE2796.6F0AA9A0--

canopus

Dec 15, 1998, 2:29am
Doing AW_MY_GESTURE apparently involves requesting the special gesture and then
requesting the default gesture, with a pause of a few seconds between them. In a
multibot program it may be easier to post a flag in the CHAT event handler, and to do
both the special gesture and the default gesture in the main program loop (with the
few second pause between them). The order in which the bot instances are notified of
the CHAT event is somewhat unpredictable. Putting everything in the main loop
simplifies your interpretation of the timer signals. (I tried out this arrangement,
and it seems to work well; it also gives you more control over your bot's action
sequence.) Admittedly, with one bot, it may be simpler to request the special gesture
in the CHAT event handler, and request the default gesture, after a timed pause, in
the main program loop. But I notice you are also interested in the general case.

[View Quote] > People seem to have more success if there is an explicit loop around aw_wait, and
> the 'while aw_wait' loop includes the AW_MY_GESTURE instead of the CHAT event
> handler. A global flag can be set in the CHAT event handler, and the loop can
> respond to the flag with the GESTURE. At least this worked better for us with
> AVATAR_CHANGE events and aw_say responses. (As if the "context" for the response
> to the event wasn't the event itself.)
>
[View Quote]

edward sumerfield

Dec 15, 1998, 9:55am
This is a multi-part message in MIME format.
--------------93595C1ECE15049462C600F0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Here is my solution for the gesture reset issue.

There is an OO pattern for a timer that involves two classes

static class Timer

static array of objects.
int start(int ticks, TimerIF *);
stop(int timer_id);
check();

pure virtual TimerIF

void popped();

So you can write a program like this.

class A : public TimerIF {
void popped() {
// reset the gesture back to 0.
}
}
void avatar_chat() {
//set gesture to 5.
Timer::start(5, new A());
}
main() {
aw_event_set(AW_MY_GESTURE, avatar_chat);
while (aw_wait(1000)) {
Timer::check();
}
}

So when the program starts it installs the chat event handler. The main loop contains the
checking of the timer but as there are no timer started at this point this does nothing.
Once a chat is seen then a gesture is started and a 5 tick timer is started. No wach time
the main loop checks the timer a tick is decremented from this timer. Once it reaches
zero the popped method on object A is called which reset the gesture.

The use of ticks instead of seconds makes timing much simpler if not as accurate. The
main loop cycling around every seconds allows us to count approximate seconds the
inaccuracy comes in depending on how long the loop takes to run. So to total tick time is
actually 1 second plus the loop cycle time. this inaccuracy is of no consequence for this
program.

The beauty of this approach is that once you have started a timer you don't have to worry
about it any more. You can of coarse have multiple timers running in parallel each
started with a different number of ticks.

My next release of AWCPP will have the official version of the Timer class but I have
attached it here if there are any C++ developers interested.

Thanks for your help everyone, I will have my deer grazing and bucking any day now.

Edward Sumerfield

[View Quote] > Doing AW_MY_GESTURE apparently involves requesting the special gesture and then
> requesting the default gesture, with a pause of a few seconds between them. In a
> multibot program it may be easier to post a flag in the CHAT event handler, and to do
> both the special gesture and the default gesture in the main program loop (with the
> few second pause between them). The order in which the bot instances are notified of
> the CHAT event is somewhat unpredictable. Putting everything in the main loop
> simplifies your interpretation of the timer signals. (I tried out this arrangement,
> and it seems to work well; it also gives you more control over your bot's action
> sequence.) Admittedly, with one bot, it may be simpler to request the special gesture
> in the CHAT event handler, and request the default gesture, after a timed pause, in
> the main program loop. But I notice you are also interested in the general case.
>
[View Quote] --------------93595C1ECE15049462C600F0
Content-Type: application/x-unknown-content-type-hpp_auto_file;
name="TimerStore.hpp"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="TimerStore.hpp"

I2lmbmRlZiBUSU1FUlNUT1JFX0hQUA0KI2RlZmluZSBUSU1FU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dXJlIHN0b3JlZCBvciB6ZXJvIGlmIGl0IGlzIGVtcHR5Lg0KICAgKi8NCiAgVGltZXJJ
bmZvKiBmaXJzdCgpOw0KDQogIC8qISBcYnJpZWYgR2V0IHRoZSBuZXh0IFRpbWVySW5mbyBz
dHJ1Y3Z0dXJlIGluIHRoZSBWZWN0b3IuDQogICAqICBccmV0dXJuIHRoZSBuZXh0IFRpbWVy
SW5mbyBzdHJ1Y3R1cmUgc3RvcmVkIG9yIHplcm8gaWYgdGhlcmUgYXJlIG5vIG1vcmUuDQog
ICAqLw0KICBUaW1lckluZm8qIG5leHQoKTsNCg0KICBmcmllbmQgb3N0cmVhbSYgb3BlcmF0
b3I8PChvc3RyZWFtJiBvcywgVGltZXJTdG9yZSYgc3RvcmUpOw0KfTsNCg0KI2VuZGlmIFRJ
TUVSU1RPUkVfSFBQDQo=
--------------93595C1ECE15049462C600F0
Content-Type: application/x-unknown-content-type-hpp_auto_file;
name="Timer.hpp"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="Timer.hpp"

I2lmbmRlZiBUSU1FUl9IUFANCiNkZWZpbmUgVElNRVJfSFBQDQoNCi8qISBcY2xhc3MgVGlt
ZXINCiAqICBcYXV0aG9yIEVkd2FyZCBTdW1lcmZpZWxkDQogKiAgXHZlcnNpb24gMC4zDQog
KiAgXGRhdGUgMTEvNS85OA0KICoNCiAqICBcYnJpZWYgQSBiYXNpYyAiY2xpY2siIHRpbWVy
IHRvIHRyYWNrIGFzeW5jaHJvbm91cyB3YWl0IHRpbWVzLg0KICoNCiAqICBUaGUgVGltZXIg
Y2xhc3MgYWxsb3dzIHlvdSB0byBzdGFydCBhIHRpbWVyIGJhc2VkIG9uIGEgbnVtYmVyIG9m
DQogKiAgImNsaWNrcyIuIEEgY2xpY2sgcmVwcmVzZW50cyBhbiBpbnRlcmF0aW9uIG9mIHlv
dXIgcHJvZ3JhbS4gSWYgeW91DQogKiAgY2FsbCB0aGUgVGltZXIuY2hlY2sgbWV0aG9k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UgY3VycmVudGx5IHJ1bm5pbmcuDQogICAqICBc
cmV0dXJuIG51bWJlciBvZiB0aW1lcnMuDQogICAqLw0KICBzdGF0aWMgaW50IHNpemUoKTsN
Cg0KICAvKiogXGJyaWVmIERlYWxsb2NhdGUgYWxsIHN0YXRpYyBzdG9yYWdlIGFzaWduZWQg
YnkgdGhpcyBjbGFzcy4NCiAgICovDQogIHN0YXRpYyB2b2lkIGRlc3Ryb3koKTsNCn07DQoN
CiNlbmRpZiBUSU1FUl9IUFANCg0K
--------------93595C1ECE15049462C600F0
Content-Type: application/x-unknown-content-type-hpp_auto_file;
name="TimerIF.hpp"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="TimerIF.hpp"

I2lmbmRlZiBUSU1FUklGX0hQUA0KI2RlZmluZSBUSU1FUklGX0hQUA0KDQovKiEgXGNsYXNz
IFRpbWVySUYNCiAqICBcYXV0aG9yIEVkd2FyZCBTdW1lcmZpZWxkDQogKiAgXHZlcnNpb24g
MC4zDQogKiAgXGRhdGUgMTEvNS85OA0KICoNCiAqICBcYnJpZWYgVGhpcyBpbnRlcmZhY2Ug
aXMgdXNlZCBieSB0aGUgVGltZXIgY2xhc3MuDQogKi8NCg0KY2xhc3MgVGltZXJJRiB7DQoN
CnB1YmxpYzoNCg0KICAvKiEgXGJyaWVmIENhbGxlZCBieSB0aGUgVGltZXIgY2xhc3Mgd2hl
biB0aGUgdGltZXIgaGFzIGV4cGlyZWQuDQogICAqDQogICAqICBUaGUgdGltZXIgc3RhcnRz
IHdpdGggYSBudW1iZXIgb2YgImNsaWNrcyIuIEVhY2ggdGltZSB0aGUgVGltZXIuY2hlY2sN
CiAgICogIG1ldGhvZCBpcyBjYWxsZWQgdGhlc2UgY2xpY2tzIGFyZSBkZWNyZW1lbnRlZCBi
eSBvbmUuIFdoZW4gdGhlIG51bWJlcg0KICAgKiAgb2YgY2xpY2tzIHJlYWNoZXMgemVybyB0
aGUgdGltZXIgaXMgc2FpZCB0byBoYXZlIHBvcHBlZCBhbmQgdGhpcyANCiAgICogIG1ldGhv
ZCBpcyBjYWxsZWQuDQogICAqLw0KICB2aXJ0dWFsIHZvaWQgcG9wcGVkKCkgPSAwOw0KfTsN
Cg0KI2VuZGlmIFRJTUVSSUZfSFBQDQoNCg0K
--------------93595C1ECE15049462C600F0
Content-Type: application/x-unknown-content-type-c_auto_file;
name="TimerStore.C"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="TimerStore.C"

LyohIFxmaWxlIFRpbWVyU3RvcmUuQw0KICoNCiAqICBUaGUgVGltZXJTdG9yZSBjbGFzcyBt
YW5hZ2VzIFRpbWVySW5mbyBzdHJ1Y3R1cmVzLg0KICovDQoNCiNpbmNsdWRlIDxpb3N0cmVh
bS5oPg0KI2luY2x1ZGUgPERlYnVnLmhwcD4NCg0KI2luY2x1ZGUgPFRpbWVySUYuaHBwPg0K
I2luY2x1ZGUgPFRpbWVyU3RvcmUuaHBwPg0KDQpUaW1lclN0b3JlOjpUaW1lclN0b3JlKCkg
ew0KDQogIEVOVEVSKCJUaW1lclN0b3JlOjpUaW1lclN0b3JlIik7DQoNCiAgY3VycmVudF90
aW1lcl9pZCA9IChUaW1lclN0b3JhZ2U6Oml0ZXJhdG9yKTA7DQogIHRpbWVyX2lkID0gMDsN
Cn0NCg0KaW50DQpUaW1lclN0b3JlOjpzaXplKCkgew0KDQogIHJldHVybiB0aW1lcl9zdG9y
YWdlLnNpemUoKTsNCn0NCg0KaW50DQpUaW1lclN0b3JlOjphZGQoVGltZXJJbmZvICp0aW1l
cl9pbmZvKSB7DQoNCiAgRU5URVIoIlRpbWVyU3RvcmU6OmFkZCIpOw0KDQogIC8vIFN0b3Jl
IHRoZSBsYXRlc3QgdGltZXIgaWQgaW50byB0aGUgc3RydWN0dXJlIGFuZCBpbmNyZW1lbnQg
dGhlIA0KICAvLyB0aW1lciBpZCByZWFkeSBmb3IgdGhlIG5leHQgYWRkLg0KDQogIERFQlVH
KCJBZGRpbmcgdGltZXIgIiA8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KSB7DQoN
CiAgICB0aW1lcl9pbmZvID0gKmN1cnJlbnRfdGltZXJfaWQ7DQogIH0NCg0KICByZXR1cm4g
dGltZXJfaW5mbzsNCn0NCg0Kb3N0cmVhbSYgb3BlcmF0b3I8PChvc3RyZWFtJiBvcywgVGlt
ZXJTdG9yZSYgc3RvcmUpIHsNCg0KICBvcyA8PCAiVGltZVN0b3JlICIgPDwgc3RvcmUuc2l6
ZSgpOw0KfQ0KDQpvc3RyZWFtJiBvcGVyYXRvcjw8KG9zdHJlYW0mIG9zLCBUaW1lckluZm8m
IHRpbWVyaW5mbykgew0KDQogIG9zIDw8ICJUaW1lSW5mbyAiIDw8IGRlYyA8PCB0aW1lcmlu
Zm8udGltZXJfaWQNCiAgICAgPDwgIiBoYXMgIiA8PCB0aW1lcmluZm8uY2xpY2tzIDw8ICIg
cmVtYWluaW5nLiI7DQp9DQoNCg==
--------------93595C1ECE15049462C600F0
Content-Type: application/x-unknown-content-type-c_auto_file;
name="Timer.C"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="Timer.C"

LyohIFxmaWxlIFRpbWVyLkMNCiAqDQogKiAgVGltZXIgY2xhc3MgbWFuYWdlcyBhIHNldCBv
ZiBzaW1wbGUgY2xpY2sgdGltZXJzLg0KICovDQoNCiNpbmNsdWRlIDxpb3N0cmVhbS5oPg0K
I2luY2x1ZGUgPERlYnVnLmhwcD4NCg0KI2luY2x1ZGUgPFRpbWVySUYuaHBwPg0KI2luY2x1
ZGUgPFRpbWVyLmhwcD4NCiNpbmNsdWRlIDxUaW1lclN0b3JlLmhwcD4NCg0KVGltZXJTdG9y
ZSAqVGltZXI6OnRpbWVyX3N0b3JlOw0KDQp2b2lkDQpUaW1lcjo6aW5pdCgpIHsNCg0KICBF
TlRFUigiVGltZXI6OmluaXQiKTsNCg0KICB0aW1lcl9zdG9yZSA9IG5ldyBUaW1lclN0b3Jl
KCk7DQp9DQoNCnZvaWQgKg0KVGltZXI6OnN0YXJ0KFRpbWVySUYg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mFsaWRhdGUgdGhlIGl0ZXJhdG9yLg0KICAgKi8N
Cg0KICBUaW1lckluZm8gKnRpbWVyID0gdGltZXJfc3RvcmUtPmZpcnN0KCk7DQogIHdoaWxl
ICh0aW1lcikgew0KDQogICAgdGltZXItPmNsaWNrcy0tOw0KDQogICAgaWYgKHRpbWVyLT5j
bGlja3MgPT0gMCkgew0KDQogICAgICB0aW1lci0+dGltZXJpZi0+cG9wcGVkKCk7DQogICAg
ICB0aW1lcl9zdG9yZS0+ZXJhc2UoKTsNCiAgICB9DQoNCiAgICBERUJVRygqdGltZXIpOw0K
DQogICAgdGltZXIgPSB0aW1lcl9zdG9yZS0+bmV4dCgpOw0KICB9DQp9DQoNCmludA0KVGlt
ZXI6OnNpemUoKSB7DQoNCiAgcmV0dXJuIHRpbWVyX3N0b3JlLT5zaXplKCk7DQp9DQoNCnZv
aWQNClRpbWVyOjpkZXN0cm95KCkgew0KDQogIEVOVEVSKCJUaW1lcjo6ZGVzdHJveSIpOw0K
DQogIGRlbGV0ZSB0aW1lcl9zdG9yZTsNCn0NCg==
--------------93595C1ECE15049462C600F0
Content-Type: application/x-unknown-content-type-c_auto_file;
name="TimerTest.C"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="TimerTest.C"

I2luY2x1ZGUgPGlvc3RyZWFtLmg+DQojaW5jbHVkZSA8QVdDUFAuaHBwPg0KDQpjbGFzcyBU
aW1lclRlc3QgOiBwdWJsaWMgVGltZXJJRiB7DQoNCnByaXZhdGU6DQoNCiAgY2hhciB0ZXh0
WzMyXTsNCg0KcHVibGljOg0KDQogIFRpbWVyVGVzdCgpIHsNCiAgfQ0KDQogIFRpbWVyVGVz
dChjaGFyICphX3RleHQpIHsNCiAgICBzdHJjcHkodGV4dCwgYV90ZXh0KTsNCiAgfQ0KDQog
IHZvaWQgcG9wcGVkKCkgew0KDQogICAgY291dCA8PCAiVGltZXIgcG9wcGVkICIgPDwgdGV4
dCA8PCBlbmRsOw0KICB9DQp9Ow0KDQ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l9pZHNbaV0gPSBUaW1lcjo6c3RhcnQobmV3IFRpbWVyVGVzdCgpLCAxMDAw
KTsNCiAgfQ0KDQogIFRpbWVyOjpjaGVjaygpOw0KDQogIGZvciAoaW50IGkgPSAwOyBpIDwg
TlVNX1RJTUVSUzsgaSsrKSB7DQoNCiAgICBUaW1lcjo6c3RvcCh0aW1lcl9pZHNbaV0pOw0K
ICB9ICAgIA0KDQogIGNvdXQgPDwgIkZpbmFsIHNpemUgb2YgdGhlIHRpbWVyIHN0b3JlIGlz
ICIgPDwgVGltZXI6OnNpemUoKSA8PCBlbmRsOw0KDQogIFRpbWVyOjpkZXN0cm95KCk7DQp9
DQo=
--------------93595C1ECE15049462C600F0--

walter knupe

Dec 15, 1998, 3:10pm
Wouldn't the Timer Class have to store or pass down any kind of bot instance
? or should the class A implement it on the side ?

My implementation currently has a list of bots. each bot does have all bot
properties, including gestures. mainloop checks that list and asks each
object to reset it if time's up.

my 2 cents......

Walter

Edward Sumerfield schrieb in Nachricht <36764E2D.4565835F at poboxes.com>...
>There is an OO pattern for a timer that involves two classes
>
>static class Timer
>
> static array of objects.
> int start(int ticks, TimerIF *);
> stop(int timer_id);
> check();
>
>pure virtual TimerIF
>
> void popped();
>
>So you can write a program like this.
>
> class A : public TimerIF {
> void popped() {
> // reset the gesture back to 0.
> }
> }
> void avatar_chat() {
> //set gesture to 5.
> Timer::start(5, new A());
> }
> main() {
> aw_event_set(AW_MY_GESTURE, avatar_chat);
> while (aw_wait(1000)) {
> Timer::check();
> }
> }
>

edward sumerfield

Dec 15, 1998, 3:47pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
In this example I would put it in class A. Assuming A is your Avatar class
then it already has the instance and gesture in it. So implementing the
TimerIF interface to create the popped() method is not an issue.
<p>The draw back I thought of with this is an Avatar requirement to run
multiple timers. With a single Avatar object has one popped method so there
would be no way of knowing for which timer it is being called.
<p>class A : public TimerIF {
<br>&nbsp;&nbsp;&nbsp; void popped() {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // ?????? what do I do
<br>&nbsp;&nbsp;&nbsp; }
<br>}
<br>main() {
<br>&nbsp;&nbsp;&nbsp; A a;
<br>&nbsp;&nbsp;&nbsp; Timer::start(&amp;a, 5);&nbsp;&nbsp;&nbsp; // Gesture
rest maybe
<br>&nbsp;&nbsp;&nbsp; Timer::start(&amp;a, 2);&nbsp;&nbsp;&nbsp; // Say
something randomly maybe.
<br>&nbsp;&nbsp;&nbsp; while (1) { Timer::check() }
<br>}
<p>The next version of Timer will solve this by adding a void * to the
start() method and changing callback to popped(void *). This way you can
start a timer and specify some arbitrary number that is passed back to
your popped method when a timer pops.
<p>class A : public TimerIF {
<br>&nbsp;&nbsp;&nbsp; void popped(void *number) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((int)number == 1) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Reset gesture
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Say something
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; }
<br>}
<br>main() {
<br>&nbsp;&nbsp;&nbsp; A a;
<br>&nbsp;&nbsp;&nbsp; Timer::start(&amp;a, 5, 1);&nbsp; // Action 1 identifies
Gesture reset.
<br>&nbsp;&nbsp;&nbsp; Timer::start(&amp;a, 2, 2);&nbsp; // Action 2 identifies
say something.
<br>&nbsp;&nbsp;&nbsp; while (1) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Timer::check();
<br>&nbsp;&nbsp;&nbsp; }
<br>}
<p>It is hard to know what the ideal OO pattern is to model this problem.
Another solution is to use a set of callback classes for each occurrence.
<p>class A {
<br>&nbsp;&nbsp;&nbsp; Avatar *a;
<br>&nbsp;&nbsp;&nbsp; A(Avatar *a_a) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a = a_a;
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; void popped() {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.doA();
<br>&nbsp;&nbsp;&nbsp; }
<br>}
<br>class B {
<br>&nbsp;&nbsp;&nbsp; Avatar *a;
<br>&nbsp;&nbsp;&nbsp; A(Avatar *a_a) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a = a_a;
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; void popped() {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a->doB();
<br>&nbsp;&nbsp;&nbsp; }
<br>}
<br>class Avatar {
<br>&nbsp;&nbsp;&nbsp; void doA() {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Reset gesture
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; void doB() {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Say something
<br>&nbsp;&nbsp;&nbsp; }
<br>}
<br>main() {
<br>&nbsp;&nbsp;&nbsp; Avatar a;
<br>&nbsp;&nbsp;&nbsp; Timer::start(new A(&amp;a));
<br>&nbsp;&nbsp;&nbsp; Timer::start(new B(&amp;a));
<br>&nbsp;&nbsp;&nbsp; while (1) { Timer::check() }
<br>}
<p>This creates a number of event type classes? I am not sure if this just
confuses the design or makes things easier.
<p>Any thoughts welcome.
<p>Edward Sumerfield, struggling OO programmer.
[View Quote]

canopus

Dec 15, 1998, 5:05pm
Also the documentation for aw_state_change might mention that if you leave
out an attribute for AW_MY, the server gives you a default. If you leave
them all out on your first aw_state_change, your bot will be a Tourist
located at GZ doing nothing special (all zeroes).

[View Quote] > The need to separate state_changes by a timed lapse of 1-5 seconds
> should be in the documentation. It came up earlier in connection with
> bot movements (MY_X, MY_Y, MY_Z, MY_YAW); now it comes up again in
> connection with bot gestures (MY_GESTURE). The example given would be
> appropriate, since it also shows that there are (still undocumented) two
> state_changes needed in certain cases, such as gestures. New programmers
> are reluctant to read through over 1000 newsgroup messages looking for
> solutions.
>
[View Quote]

edward sumerfield

Dec 15, 1998, 5:49pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
Just one more question for you Roland.
<p>The browser is deciding on the gesture to initiate if the number from
the world server is different from the gesture it just performed?
<p>We have said that we need to reset the gesture to zero 5 seconds after
the initial gesture is sent. Could that rule be rephrased as "to initiate
a sequence of gestures, each successive gesture must be DIFFERENT from
the last."
<p>The difference between these statements is of coarse that instead of
zero we could set gesture 4, then 5 seconds later, set gesture 3, then
5 seconds later back to gesture 4 again. Would this sequence cause the
browser to correctly initiate each sequence?
[View Quote] </body>
</html>

andras sarkozy

Dec 15, 1998, 6:37pm
--------------69DB172A1C767FFE506C3C7E
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

I tested this case - to change to a different than zero gesture will init=
iate properly the new gesture, while resetting to zero will not cause cha=
nge in the avatar movement. It is needed only for the SAME gesture than t=
he last one..


[View Quote] > Just one more question for you Roland.
>
> The browser is deciding on the gesture to initiate if the number from t=
he world server is different from the gesture it just performed?
>
> We have said that we need to reset the gesture to zero 5 seconds after =
the initial gesture is sent. Could that rule be rephrased as "to initiate=
a sequence of gestures, each successive gesture must be DIFFERENT from t=
he last."
>
> The difference between these statements is of coarse that instead of ze=
ro we could set gesture 4, then 5 seconds later, set gesture 3, then 5 se=
conds later back to gesture 4 again. Would this sequence cause the browse=
r to correctly initiate each sequence?
>
[View Quote] --------------69DB172A1C767FFE506C3C7E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
I tested this case - to change to a different than zero gesture will initiate
properly the new gesture, while resetting to zero will not cause change
in the avatar movement. It is needed only for the SAME gesture than the
last one..
<br>&nbsp;
[View Quote] </body>
</html>

--------------69DB172A1C767FFE506C3C7E--

edward sumerfield

Dec 15, 1998, 8:14pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
You De Man Andras.
<p>So this is a documentation point to Roland then to clarify that that
it is not the change to zero but the CHANGE of the gesture that is important.
[View Quote] </body>
</html>

roland vilett

Dec 15, 1998, 9:21pm
This is a multi-part message in MIME format.

------=_NextPart_000_004A_01BE283E.A7FB4BE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Yes, but with the caveat that changing to a different gesture before the =
previous one completes will not replace the previous gesture but rather =
overlap the two.

-Roland

[View Quote] [View Quote] I tested this case - to change to a different than zero gesture =
will initiate properly the new gesture, while resetting to zero will not =
cause change in the avatar movement. It is needed only for the SAME =
gesture than the last one..=20
=20
[View Quote] Just one more question for you Roland.=20
The browser is deciding on the gesture to initiate if the =
number from the world server is different from the gesture it just =
performed?=20

We have said that we need to reset the gesture to zero 5 =
seconds after the initial gesture is sent. Could that rule be rephrased =
as "to initiate a sequence of gestures, each successive gesture must be =
DIFFERENT from the last."=20

The difference between these statements is of coarse that =
instead of zero we could set gesture 4, then 5 seconds later, set =
gesture 3, then 5 seconds later back to gesture 4 again. Would this =
sequence cause the browser to correctly initiate each sequence?=20

[View Quote] Whether or not their would be increased lag due to an =
increased number of users would depend on the outgoing bandwidth of the =
server. Servers with a high user load and low bandwidth would =
experience poor response time for all transactions, position updates =
included, as you would expect. If the server has adequate bandwidth =
available, though, I don't think you would ever notice a difference in =
propagation delay whether there was 1 user or 100 users in the world. I =
chose 5 seconds because that's what the AW browser does...5 seconds =
after signaling a gesture, it returns to 0. I'm actually not sure =
whether a shorter timeout would cause the gesture to terminate =
prematurely or not...my suspicion is not, since gestures can overlap =
(e.g. you can start a wave before completing the angry sequence, and the =
animation code will attempt to do both at the same time.) To know for =
sure I'd have to dive deep into the avatar animation code, which is not =
something I particularly relish (it isn't my code.) A simple experiment =
with a bot though would say for sure...-Roland=20
[View Quote] A performance question for you. You say that the =
server updates the browsers every second. Is there any kind of =
propagation delay noticed as the number of browsers increases or does =
the max logins per world keep this to a minimum.=20

You recommend resetting the gesture after 5 seconds. =
A gesture sequence takes a certain amount of time to run in a browser. =
If I set to gesture to 5 and reset to 0 in two seconds will it stop the =
currently running sequence?=20

Is there some timing advantage to noting long =
gesture sequence compared to short sequences and varying the reset time =
interval appropriately?=20

[View Quote] No, this won't work. In order for the gesture =
to be reset, the other browsers have to see the change. Remember that =
multiple calls to aw_state_change() are not propagated out to other =
clients more than once per second. Your code will simply change your =
state in the server, and then immediately change it back to the way it =
was before. To everyone else in the area, you will appear to have =
maintained gesture #5 all along.The correct way to do this is to add =
code to your bot to always change the gesture back to 0 again a few =
seconds after it was changed to 5. The easiest way to do this is to =
note the current time when you set the gesture to 5 (the Windows system =
call GetTickCount() returns a handy time value in milliseconds), and =
then in your main event loop periodically check this saved value against =
the current time. You will need to modify your current call to =
aw_wait() since your program now needs to take action in addition to =
simply responding to events. The relevant code changes could look =
something like this: #define FIVE_SECONDS 5000 unsigned long =
reset_gesture; void avatar_chat() {=20
int rc;=20
printf("chatting\n");=20
aw_int_set (AW_MY_GESTURE, 5);=20
if (rc =3D aw_state_change ()) {=20
printf ("Unable to change state (reason =
%d)\n", rc);=20
exit (1);=20
} reset_gesture =3D GetTickCount() + =
FIVE_SECONDS;} /* replace aw_wait(-1) with this: */ while (!aw_wait =
(1000)) if (reset_gesture ?? reset_gesture ? GetTickCount ()) { /* =
time to set our gesture back to 0 again */ aw_int_set (AW_MY_GESTURE, =
0); aw_state_change (); reset_gesture =3D 0; } Edward Sumerfield =
[View Quote] It will work every time?=20

[View Quote] You have to reset the gesture to 0 and =
then back to 5 to have the others=20
pick it up again. The resetting to 0 is =
done automatically by the awbrowser=20
after you clicked on a gesture begin=20
Walter=20

Edward Sumerfield schrieb in Nachricht =
?36748FD4.84162BA5 at poboxes.com>...=20
>The following source is supposed to =
initiate a gesture every time it hears=20
>some chat message. However, it only =
does it once after the program starts=20
and=20
>never again. What am I doing wrong?=20

>void avatar_chat() {=20
> int rc;=20
> printf("chatting\n");=20
> aw_int_set (AW_MY_GESTURE, 5);=20
> if (rc =3D aw_state_change ()) {=20
> printf ("Unable to change state =
(reason %d)\n", rc);=20
> exit (1);=20
> }=20
>}=20
>


------=_NextPart_000_004A_01BE283E.A7FB4BE0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type><!doctype html public "-//w3c//dtd html 4.0 =
transitional//en">
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>Yes, but with the caveat that =
changing to a=20
different gesture before the previous one completes will not replace the =

previous gesture but rather overlap the two.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>-Roland</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
[View Quote] =
href=3D"mailto:3676DF62.65421F6D at poboxes.com">3676DF62.65421F6D at poboxes.c=
om</A>&gt;...</DIV>You=20
De Man Andras.=20
<P>So this is a documentation point to Roland then to clarify that =
that it=20
is not the change to zero but the CHANGE of the gesture that is =
important.=20
[View Quote] <P>The browser is deciding on the gesture to initiate if the =
number=20
from the world server is different from the gesture it just=20
performed?=20
<P>We have said that we need to reset the gesture to zero 5 =
seconds=20
after the initial gesture is sent. Could that rule be =
rephrased as=20
&quot;to initiate a sequence of gestures, each successive =
gesture=20
must be DIFFERENT from the last.&quot;=20
<P>The difference between these statements is of coarse that =
instead=20
of zero we could set gesture 4, then 5 seconds later, set =
gesture 3,=20
then 5 seconds later back to gesture 4 again. Would this =
sequence=20
cause the browser to correctly initiate each sequence?=20
[View Quote] <P>Is there some timing advantage to noting long =
gesture=20
sequence compared to short sequences and varying the =
reset=20
time interval appropriately?=20
[View Quote] immediately change it back to the way it was=20
before.&nbsp; To everyone else in the area, you =
will=20
appear to have maintained gesture #5 all=20
along.</FONT>The correct way to do this is to =
add code=20
to your bot to always change the gesture back to =
0 again=20
a few seconds after it was changed to 5.&nbsp; =
The=20
easiest way to do this is to note the current =
time when=20
you set the gesture to 5 (the Windows system =
call=20
GetTickCount() returns a handy time value in=20
milliseconds), and then in your main event loop=20
periodically check this saved value against the =
current=20
time.&nbsp; You will need to modify your current =
call to=20
aw_wait() since your program now needs to take =
action in=20
addition to simply responding to events.</FONT> =
<FONT=20
color=3D#000000><FONT size=3D-1>The relevant =
code changes=20
could look something like this:</FONT></FONT> =
<FONT=20
color=3D#000000><FONT size=3D-1>#define=20
FIVE_SECONDS&nbsp;&nbsp;&nbsp; =
5000</FONT></FONT> <FONT=20
size=3D-1>unsigned long reset_gesture;</FONT> =
void=20
avatar_chat() { <BR>&nbsp; int rc; <BR>&nbsp;=20
printf(&quot;chatting\n&quot;); <BR>&nbsp; =
aw_int_set=20
(AW_MY_GESTURE, 5); <BR>&nbsp; if (rc =3D =
aw_state_change=20
()) { <BR>&nbsp;&nbsp;&nbsp; printf =
(&quot;Unable to=20
change state (reason %d)\n&quot;, rc);=20
<BR>&nbsp;&nbsp;&nbsp; exit (1); <BR>&nbsp; =
}&nbsp;=20
reset_gesture =3D GetTickCount() + =
FIVE_SECONDS;} <FONT=20
color=3D#000000><FONT size=3D-1>/* replace =
aw_wait(-1) with=20
this: */</FONT></FONT> <FONT size=3D-1>while =
(!aw_wait=20
(1000))&nbsp; if (reset_gesture ?? reset_gesture =
?=20
GetTickCount ()) {&nbsp;&nbsp; /* time to set =
our=20
gesture back to 0 again */&nbsp;&nbsp; =
aw_int_set=20
(AW_MY_GESTURE, 0);&nbsp;&nbsp; aw_state_change=20
();&nbsp;&nbsp; reset_gesture =3D 0;&nbsp; =
}</FONT>&nbsp;=20
Edward Sumerfield<ESUMERFD at POBOXES.COM> wrote in =
message=20
?<A=20
=
href=3D"mailto:36756086.CBC209DB at poboxes.com">36756086.CBC209DB at poboxes.c=
om</A>&gt;...=20
=20
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; =
MARGIN-LEFT: 5px; PADDING-LEFT: 5px">Cool.=20
So If I do=20
<P>&nbsp;&nbsp;&nbsp; =
aw_int_set(AW_MY_GESTURE, 0);=20
<BR>&nbsp;&nbsp;&nbsp; aw_state_change();=20
<BR>&nbsp;&nbsp;&nbsp; =
aw_int_set(AW_MY_GESTURE, 5);=20
<BR>&nbsp;&nbsp;&nbsp; aw_state_change();=20
<P>It will work every time?=20
[View Quote] <BR>&gt;never again. What am I doing =
wrong?=20
<P>&gt;void avatar_chat() { =
<BR>&gt;&nbsp; int=20
rc; <BR>&gt;&nbsp;=20
printf(&quot;chatting\n&quot;); =
<BR>&gt;&nbsp;=20
aw_int_set (AW_MY_GESTURE, 5); =
<BR>&gt;&nbsp; if=20
(rc =3D aw_state_change ()) {=20
<BR>&gt;&nbsp;&nbsp;&nbsp; printf =
(&quot;Unable=20
to change state (reason %d)\n&quot;, =
rc);=20
<BR>&gt;&nbsp;&nbsp;&nbsp; exit (1);=20
<BR>&gt;&nbsp; } <BR>&gt;}=20
=
<BR>&gt;</P></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQU=
OTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_004A_01BE283E.A7FB4BE0--

roland vilett

Dec 15, 1998, 9:27pm
This isn't quite correct. Every time you call aw_state_change(), as with
all API methods that use attributes, the values of all attributes are sent
to the server regardless of whether your code sets them or not. If you have
never set an attribute, its value will be zero for integers, false for
booleans, and empty for strings (note this doesn't apply to attributes that
are set automatically by the SDK in response to events and requests.) If
you have set it before, it will continue to retain that value until you set
it again.

This is why it is okay to only set AW_MY_GESTURE and call aw_state_change(),
without setting all other AW_MY_ attributes as well, assuming you have
already called aw_state_change() before to locate your avatar in the world
somewhere. The SDK will simply send again all the same values for AW_MY_X,
AW_MY_Y, etc. as before. Note that this is different from the concept of
the server assigning default values for unspecified attributes.

-Roland

[View Quote]

roland vilett

Dec 15, 1998, 9:31pm
This is a multi-part message in MIME format.

------=_NextPart_000_005E_01BE283F.F3C865C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Again, yes, this is correct. But the beginning of this thread I believe =
was about the case of someone wanting an avatar to repeat the same =
gesture over and over again in response to chat events. In this case =
changing AW_MY_GESTURE specifically to zero is required in order to =
"reset" the gesture. Of course you could set it to some other gesture =
instead of zero, but then you would have more than one gesture going on.

-Roland
[View Quote] [View Quote] I tested this case - to change to a different than zero gesture =
will initiate properly the new gesture, while resetting to zero will not =
cause change in the avatar movement. It is needed only for the SAME =
gesture than the last one..=20
=20
[View Quote] Just one more question for you Roland.=20
The browser is deciding on the gesture to initiate if the =
number from the world server is different from the gesture it just =
performed?=20

We have said that we need to reset the gesture to zero 5 =
seconds after the initial gesture is sent. Could that rule be rephrased =
as "to initiate a sequence of gestures, each successive gesture must be =
DIFFERENT from the last."=20

The difference between these statements is of coarse that =
instead of zero we could set gesture 4, then 5 seconds later, set =
gesture 3, then 5 seconds later back to gesture 4 again. Would this =
sequence cause the browser to correctly initiate each sequence?=20

[View Quote] Whether or not their would be increased lag due to an =
increased number of users would depend on the outgoing bandwidth of the =
server. Servers with a high user load and low bandwidth would =
experience poor response time for all transactions, position updates =
included, as you would expect. If the server has adequate bandwidth =
available, though, I don't think you would ever notice a difference in =
propagation delay whether there was 1 user or 100 users in the world. I =
chose 5 seconds because that's what the AW browser does...5 seconds =
after signaling a gesture, it returns to 0. I'm actually not sure =
whether a shorter timeout would cause the gesture to terminate =
prematurely or not...my suspicion is not, since gestures can overlap =
(e.g. you can start a wave before completing the angry sequence, and the =
animation code will attempt to do both at the same time.) To know for =
sure I'd have to dive deep into the avatar animation code, which is not =
something I particularly relish (it isn't my code.) A simple experiment =
with a bot though would say for sure...-Roland=20
[View Quote] A performance question for you. You say that the =
server updates the browsers every second. Is there any kind of =
propagation delay noticed as the number of browsers increases or does =
the max logins per world keep this to a minimum.=20

You recommend resetting the gesture after 5 seconds. =
A gesture sequence takes a certain amount of time to run in a browser. =
If I set to gesture to 5 and reset to 0 in two seconds will it stop the =
currently running sequence?=20

Is there some timing advantage to noting long =
gesture sequence compared to short sequences and varying the reset time =
interval appropriately?=20

[View Quote] No, this won't work. In order for the gesture =
to be reset, the other browsers have to see the change. Remember that =
multiple calls to aw_state_change() are not propagated out to other =
clients more than once per second. Your code will simply change your =
state in the server, and then immediately change it back to the way it =
was before. To everyone else in the area, you will appear to have =
maintained gesture #5 all along.The correct way to do this is to add =
code to your bot to always change the gesture back to 0 again a few =
seconds after it was changed to 5. The easiest way to do this is to =
note the current time when you set the gesture to 5 (the Windows system =
call GetTickCount() returns a handy time value in milliseconds), and =
then in your main event loop periodically check this saved value against =
the current time. You will need to modify your current call to =
aw_wait() since your program now needs to take action in addition to =
simply responding to events. The relevant code changes could look =
something like this: #define FIVE_SECONDS 5000 unsigned long =
reset_gesture; void avatar_chat() {=20
int rc;=20
printf("chatting\n");=20
aw_int_set (AW_MY_GESTURE, 5);=20
if (rc =3D aw_state_change ()) {=20
printf ("Unable to change state (reason =
%d)\n", rc);=20
exit (1);=20
} reset_gesture =3D GetTickCount() + =
FIVE_SECONDS;} /* replace aw_wait(-1) with this: */ while (!aw_wait =
(1000)) if (reset_gesture ?? reset_gesture ? GetTickCount ()) { /* =
time to set our gesture back to 0 again */ aw_int_set (AW_MY_GESTURE, =
0); aw_state_change (); reset_gesture =3D 0; } Edward Sumerfield =
[View Quote] It will work every time?=20

[View Quote] You have to reset the gesture to 0 and =
then back to 5 to have the others=20
pick it up again. The resetting to 0 is =
done automatically by the awbrowser=20
after you clicked on a gesture begin=20
Walter=20

Edward Sumerfield schrieb in Nachricht =
?36748FD4.84162BA5 at poboxes.com>...=20
>The following source is supposed to =
initiate a gesture every time it hears=20
>some chat message. However, it only =
does it once after the program starts=20
and=20
>never again. What am I doing wrong?=20

>void avatar_chat() {=20
> int rc;=20
> printf("chatting\n");=20
> aw_int_set (AW_MY_GESTURE, 5);=20
> if (rc =3D aw_state_change ()) {=20
> printf ("Unable to change state =
(reason %d)\n", rc);=20
> exit (1);=20
> }=20
>}=20
>


------=_NextPart_000_005E_01BE283F.F3C865C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type><!doctype html public "-//w3c//dtd html 4.0 =
transitional//en">
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Again, yes, this is correct.&nbsp; But the beginning =
of this=20
thread I believe was about the case of someone wanting an avatar to =
repeat the=20
same gesture over and over again in response to chat events.&nbsp; In =
this case=20
changing AW_MY_GESTURE specifically to zero is required in order to=20
&quot;reset&quot; the gesture.&nbsp; Of course you could set it to some =
other=20
gesture instead of zero, but then you would have more than one gesture =
going=20
on.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>-Roland</FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
[View Quote] =
href=3D"mailto:3676DF62.65421F6D at poboxes.com">3676DF62.65421F6D at poboxes.c=
om</A>&gt;...</DIV>You=20
De Man Andras.=20
<P>So this is a documentation point to Roland then to clarify that =
that it=20
is not the change to zero but the CHANGE of the gesture that is =
important.=20
[View Quote] <P>The browser is deciding on the gesture to initiate if the =
number=20
from the world server is different from the gesture it just=20
performed?=20
<P>We have said that we need to reset the gesture to zero 5 =
seconds=20
after the initial gesture is sent. Could that rule be =
rephrased as=20
&quot;to initiate a sequence of gestures, each successive =
gesture=20
must be DIFFERENT from the last.&quot;=20
<P>The difference between these statements is of coarse that =
instead=20
of zero we could set gesture 4, then 5 seconds later, set =
gesture 3,=20
then 5 seconds later back to gesture 4 again. Would this =
sequence=20
cause the browser to correctly initiate each sequence?=20
[View Quote] <P>Is there some timing advantage to noting long =
gesture=20
sequence compared to short sequences and varying the =
reset=20
time interval appropriately?=20
[View Quote] immediately change it back to the way it was=20
before.&nbsp; To everyone else in the area, you =
will=20
appear to have maintained gesture #5 all=20
along.</FONT>The correct way to do this is to =
add code=20
to your bot to always change the gesture back to =
0 again=20
a few seconds after it was changed to 5.&nbsp; =
The=20
easiest way to do this is to note the current =
time when=20
you set the gesture to 5 (the Windows system =
call=20
GetTickCount() returns a handy time value in=20
milliseconds), and then in your main event loop=20
periodically check this saved value against the =
current=20
time.&nbsp; You will need to modify your current =
call to=20
aw_wait() since your program now needs to take =
action in=20
addition to simply responding to events.</FONT> =
<FONT=20
color=3D#000000><FONT size=3D-1>The relevant =
code changes=20
could look something like this:</FONT></FONT> =
<FONT=20
color=3D#000000><FONT size=3D-1>#define=20
FIVE_SECONDS&nbsp;&nbsp;&nbsp; =
5000</FONT></FONT> <FONT=20
size=3D-1>unsigned long reset_gesture;</FONT> =
void=20
avatar_chat() { <BR>&nbsp; int rc; <BR>&nbsp;=20
printf(&quot;chatting\n&quot;); <BR>&nbsp; =
aw_int_set=20
(AW_MY_GESTURE, 5); <BR>&nbsp; if (rc =3D =
aw_state_change=20
()) { <BR>&nbsp;&nbsp;&nbsp; printf =
(&quot;Unable to=20
change state (reason %d)\n&quot;, rc);=20
<BR>&nbsp;&nbsp;&nbsp; exit (1); <BR>&nbsp; =
}&nbsp;=20
reset_gesture =3D GetTickCount() + =
FIVE_SECONDS;} <FONT=20
color=3D#000000><FONT size=3D-1>/* replace =
aw_wait(-1) with=20
this: */</FONT></FONT> <FONT size=3D-1>while =
(!aw_wait=20
(1000))&nbsp; if (reset_gesture ?? reset_gesture =
?=20
GetTickCount ()) {&nbsp;&nbsp; /* time to set =
our=20
gesture back to 0 again */&nbsp;&nbsp; =
aw_int_set=20
(AW_MY_GESTURE, 0);&nbsp;&nbsp; aw_state_change=20
();&nbsp;&nbsp; reset_gesture =3D 0;&nbsp; =
}</FONT>&nbsp;=20
Edward Sumerfield<ESUMERFD at POBOXES.COM> wrote in =
message=20
?<A=20
=
href=3D"mailto:36756086.CBC209DB at poboxes.com">36756086.CBC209DB at poboxes.c=
om</A>&gt;...=20
=20
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; =
MARGIN-LEFT: 5px; PADDING-LEFT: 5px">Cool.=20
So If I do=20
<P>&nbsp;&nbsp;&nbsp; =
aw_int_set(AW_MY_GESTURE, 0);=20
<BR>&nbsp;&nbsp;&nbsp; aw_state_change();=20
<BR>&nbsp;&nbsp;&nbsp; =
aw_int_set(AW_MY_GESTURE, 5);=20
<BR>&nbsp;&nbsp;&nbsp; aw_state_change();=20
<P>It will work every time?=20
[View Quote] <BR>&gt;never again. What am I doing =
wrong?=20
<P>&gt;void avatar_chat() { =
<BR>&gt;&nbsp; int=20
rc; <BR>&gt;&nbsp;=20
printf(&quot;chatting\n&quot;); =
<BR>&gt;&nbsp;=20
aw_int_set (AW_MY_GESTURE, 5); =
<BR>&gt;&nbsp; if=20
(rc =3D aw_state_change ()) {=20
<BR>&gt;&nbsp;&nbsp;&nbsp; printf =
(&quot;Unable=20
to change state (reason %d)\n&quot;, =
rc);=20
<BR>&gt;&nbsp;&nbsp;&nbsp; exit (1);=20
<BR>&gt;&nbsp; } <BR>&gt;}=20
=
<BR>&gt;</P></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQU=
OTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_005E_01BE283F.F3C865C0--

canopus

Dec 15, 1998, 10:34pm
Thanks, Roland. I hope that all your clear and helpful remarks from this thread
will soon make their way into the documentation!

[View Quote] > This isn't quite correct. Every time you call aw_state_change(), as with
> all API methods that use attributes, the values of all attributes are sent
> to the server regardless of whether your code sets them or not. If you have
> never set an attribute, its value will be zero for integers, false for
> booleans, and empty for strings (note this doesn't apply to attributes that
> are set automatically by the SDK in response to events and requests.) If
> you have set it before, it will continue to retain that value until you set
> it again.
>
> This is why it is okay to only set AW_MY_GESTURE and call aw_state_change(),
> without setting all other AW_MY_ attributes as well, assuming you have
> already called aw_state_change() before to locate your avatar in the world
> somewhere. The SDK will simply send again all the same values for AW_MY_X,
> AW_MY_Y, etc. as before. Note that this is different from the concept of
> the server assigning default values for unspecified attributes.
>
> -Roland
>
[View Quote]

andras sarkozy

Dec 16, 1998, 6:13am
--------------00D671831211847C75723167
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

If we are at this topic :
My test involved 9 instances of the bots by Edward and it consumed %66 of=
my Dual 300 MHz P2 processor. Anyone know any explanation for it?

[View Quote] > Again, yes, this is correct. But the beginning of this thread I belie=
ve was about the case of someone wanting an avatar to repeat the same ges=
ture over and over again in response to chat events. In this case changi=
ng AW_MY_GESTURE specifically to zero is required in order to ?reset? the=
gesture. Of course you could set it to some other gesture instead of ze=
ro, but then you would have more than one gesture going on. -Roland
>
[View Quote] --------------00D671831211847C75723167
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
If we are at this topic :
<br>My test involved 9 instances of the bots by Edward and it consumed
%66 of my Dual 300 MHz P2 processor. Anyone know any explanation for it?
[View Quote] </body>
</html>

--------------00D671831211847C75723167--

edward sumerfield

Dec 16, 1998, 12:59pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
Because Edward writes very inefficient code?
<p>Which of my bots were you running?
<p>Most of them have one second poll (aw_wait(1000)) so that I can use
timers that are accurate to one second. I have not looked at how much CPU
this takes up.
[View Quote] </body>
</html>

roland vilett

Dec 16, 1998, 5:07pm
So, ummm, what exactly is your point, Canopus? That the documentation is
incomplete? Thanks, but I already knew that. Like the SDK itself, and Active
Worlds in general, the documentation is a work in progress, and it will
improve with time

-Roland

[View Quote]

andras sarkozy

Dec 16, 1998, 5:47pm
--------------98111C6F7B8E4FFF647422F4
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

The same you posted some times ago and here. aw_wait(1000) is there and n=
othing really else.
The loop is here:
for (int i=3D0;i<36000;i++) // 10 hours lifetime
{
(AWWait)(1000); // 1 sec only
if (reset_gesture && reset_gesture < GetTickCount ())
{
/* time to set our gesture back to 0 again */
(AWIntSet) (AW_MY_GESTURE, 0);
(AWStateChange) ();
reset_gesture =3D 0;
}
}


[View Quote] > Because Edward writes very inefficient code?
>
> Which of my bots were you running?
>
> Most of them have one second poll (aw_wait(1000)) so that I can use tim=
ers that are accurate to one second. I have not looked at how much CPU th=
is takes up.
>
[View Quote] --------------98111C6F7B8E4FFF647422F4
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
The same you posted some times ago and here. aw_wait(1000) is there and
nothing really else.
<br>The loop is here:
<br>&nbsp; for (int i=0;i&lt;36000;i++)&nbsp;&nbsp;&nbsp; // 10 hours lifetime
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp; (AWWait)(1000); // 1 sec only
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (reset_gesture &amp;&amp;
reset_gesture &lt; GetTickCount ())
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp; /* time to set our gesture back to 0 again */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (AWIntSet) (AW_MY_GESTURE, 0);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (AWStateChange) ();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reset_gesture = 0;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;
[View Quote] </body>
</html>

--------------98111C6F7B8E4FFF647422F4--

andras sarkozy

Dec 16, 1998, 8:47pm
--------------BB1EF9B79C3112AAB2ACDA8C
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable



[View Quote] > Are you running 9 programs like this or using a single program to manag=
e 9 bots. I would imagine that a single program would be more efficient b=
ecause there would be only one 1 second loop as opposed to 9 of them.
>

I do run 9 independent programs - each does something slightly different,=
but even 1/9th of a second is a century for a Dual PII machine.

>
> How are you getting 9 bots at the same time? I thought there was a limi=
t of 3.
>

You can run as many as you want - just have to pay for it :o))

>
> Wow this is some really old code. since then we have migrated to (aw_wa=
it) syntax, then to the AWSDK::aw_wait and now finally to the simplest fo=
rm aw_wait using the awsdk.lib wrapper of the dll. But whatever works.
>

That was my very first SDK apps to write (modify) so I used the example I=
found on my HD. I consider to write some more - so I'll use the latest w=
rapper - if I can find it for Cbuilder3 :o)


>
[View Quote] believe was about the case of someone wanting an avatar to repeat the sa=
me gesture over and over again in response to chat events. In this case =
changing AW_MY_GESTURE specifically to zero is required in order to ?rese=
t? the gesture. Of course you could set it to some other gesture instead=
of zero, but then you would have more than one gesture going on. -Roland=

s.com?...You De Man Andras.
hat that it is not the change to zero but the CHANGE of the gesture that =
is important.
sture will initiate properly the new gesture, while resetting to zero wil=
l not cause change in the avatar movement. It is needed only for the SAME=
gesture than the last one..
number from the world server is different from the gesture it just perfo=
rmed?
seconds after the initial gesture is sent. Could that rule be rephrased a=
s ?to initiate a sequence of gestures, each successive gesture must be DI=
FFERENT from the last.?
instead of zero we could set gesture 4, then 5 seconds later, set gestur=
e 3, then 5 seconds later back to gesture 4 again. Would this sequence ca=
use the browser to correctly initiate each sequence?
increased number of users would depend on the outgoing bandwidth of the s=
erver. Servers with a high user load and low bandwidth would experience =
poor response time for all transactions, position updates included, as yo=
u would expect. If the server has adequate bandwidth available, though, =
I don't think you would ever notice a difference in propagation delay whe=
ther there was 1 user or 100 users in the world. I chose 5 seconds becaus=
e that's what the AW browser does...5 seconds after signaling a gesture, =
it returns to 0. I'm actually not sure whether a shorter timeout would ca=
use the gesture to terminate prematurely or not...my suspicion is not, si=
nce gestures can overlap (e.g. you can start a wave before completing the=
angry sequence, and the animation code will attempt to do both at the sa=
me time.) To know for sure I'd have to dive deep into the avatar animatio=
n code, which is not something I particularly relish (it isn't my
for sure...-Roland
D02 at poboxes.com?...I see. Its a perspective change from me. I keep making=
the mistake of see actions as changes in the server but really they are =
changes in other browsers propagated by a 1 second polling server.
my class library infrastructure again. Doh.
erver updates the browsers every second. Is there any kind of propagation=
delay noticed as the number of browsers increases or does the max logins=
per world keep this to a minimum.
s. A gesture sequence takes a certain amount of time to run in a browser.=
If I set to gesture to 5 and reset to 0 in two seconds will it stop the =
currently running sequence?
ure sequence compared to short sequences and varying the reset time inter=
val appropriately?
to be reset, the other browsers have to see the change. Remember that mu=
ltiple calls to aw_state_change() are not propagated out to other clients=
more than once per second. Your code will simply change your state in t=
he server, and then immediately change it back to the way it was before. =
To everyone else in the area, you will appear to have maintained gesture=
#5 all along.The correct way to do this is to add code to your bot to al=
ways change the gesture back to 0 again a few seconds after it was change=
d to 5. The easiest way to do this is to note the current time when you =
set the gesture to 5 (the Windows system call GetTickCount() returns a ha=
ndy time value in milliseconds), and then in your main event loop periodi=
cally check this saved value against the current time. You will need to =
modify your current call to aw_wait() since your program now needs to tak=
e action in addition to simply responding to events. The relevant
fine FIVE_SECONDS 5000 unsigned long reset_gesture; void avatar_chat()=
{
n?, rc);
ONDS;} /* replace aw_wait(-1) with this: */ while (!aw_wait (1000)) if (=
reset_gesture ?? reset_gesture ? GetTickCount ()) { /* time to set our =
gesture back to 0 again */ aw_int_set (AW_MY_GESTURE, 0); aw_state_ch=
[View Quote] --------------BB1EF9B79C3112AAB2ACDA8C
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
&nbsp;
[View Quote] </body>
</html>

--------------BB1EF9B79C3112AAB2ACDA8C--

edward sumerfield

Dec 16, 1998, 8:48pm
--------------D731329ED8566A02A56FEFD7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Are you running 9 programs like this or using a single program to manage 9
bots. I would imagine that a single program would be more efficient because
there would be only one 1 second loop as opposed to 9 of them.

How are you getting 9 bots at the same time? I thought there was a limit of 3.

Wow this is some really old code. since then we have migrated to (aw_wait)
syntax, then to the AWSDK::aw_wait and now finally to the simplest form
aw_wait using the awsdk.lib wrapper of the dll. But whatever works.

[View Quote] > The same you posted some times ago and here. aw_wait(1000) is there and
> nothing really else.
> The loop is here:
> for (int i=0;i<36000;i++) // 10 hours lifetime
> {
> (AWWait)(1000); // 1 sec only
> if (reset_gesture && reset_gesture < GetTickCount ())
> {
> /* time to set our gesture back to 0 again */
> (AWIntSet) (AW_MY_GESTURE, 0);
> (AWStateChange) ();
> reset_gesture = 0;
> }
> }
>
>
[View Quote] --------------D731329ED8566A02A56FEFD7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
Are you running 9 programs like this or using a single program to manage
9 bots. I would imagine that a single program would be more efficient because
there would be only one 1 second loop as opposed to 9 of them.
<p>How are you getting 9 bots at the same time? I thought there was a limit
of 3.
<p>Wow this is some really old code. since then we have migrated to (aw_wait)
syntax, then to the AWSDK::aw_wait and now finally to the simplest form
aw_wait using the awsdk.lib wrapper of the dll. But whatever works.
[View Quote] </body>
</html>

--------------D731329ED8566A02A56FEFD7--

edward sumerfield

Dec 16, 1998, 8:52pm
Don't be hard on the guy Roland. He is only trying to help with specific
phrasing of your pending documentation. He doesn't deserve to be reprimanded. As
we work through this "work in progress" we have all had to deal with the,
expected, inaccuracies. This is not a problem except that we are all interested
in improving things for the future.

[View Quote] > So, ummm, what exactly is your point, Canopus? That the documentation is
> incomplete? Thanks, but I already knew that. Like the SDK itself, and Active
> Worlds in general, the documentation is a work in progress, and it will
> improve with time
>
> -Roland
>
[View Quote]

canopus

Dec 16, 1998, 10:48pm
Gee, I wasn't making a point. Just thought that it would be easy to copy
paragraphs from this thread into the aw_state_change doc or the AW_MY_GESTURE
doc.

[View Quote] > So, ummm, what exactly is your point, Canopus? That the documentation is
> incomplete? Thanks, but I already knew that. Like the SDK itself, and Active
> Worlds in general, the documentation is a work in progress, and it will
> improve with time
>
> -Roland
>
[View Quote]

1  2  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn