Difference between revisions of "Talk:MERVBot Tutorial"

From ASSS Wiki
Jump to: navigation, search
(Extra Code Samples)
(yea.. .mem leak)
 
(20 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
==hmm==
 +
Modified permanent get/setTag method = memory leak... boo
 +
telling them to beware is eh... i dunno [[User:BaK|BaK]]
 +
 +
==General Convo==
 
D1s: Anybody wanna format this int a table of contents? I'm lazy
 
D1s: Anybody wanna format this int a table of contents? I'm lazy
  
Line 8: Line 13:
  
 
[[User:CypherJF|CypherJF]]: Should we just call this "the bot tutorial" based on the tutorial by Underlord? Then update it accordingly? -- And also, the link to MervBot w/e 37 is now 45; should we just comment that this tutorial was writen for the 37 -- or... comments! lol.
 
[[User:CypherJF|CypherJF]]: Should we just call this "the bot tutorial" based on the tutorial by Underlord? Then update it accordingly? -- And also, the link to MervBot w/e 37 is now 45; should we just comment that this tutorial was writen for the 37 -- or... comments! lol.
 +
 +
[[User:CypherJF|CypherJF]]: I'd like to say that all sections appear to have been updated for the Wiki; time to go through edit, and catch mistakes. Add to the wiki itself - perhaps more example code.
 +
 +
[[User:CypherJF|CypherJF]]: Cyan and I were talking about the section "Checking if pilot is in a safe zone"; whether or not to just remove it. I remarked that it's a nice section for those to the whole plugin deal. But, I was just noticing how it'd make more sense to put the "Useful Player data" before hand... So i guess the next step is to go through and try to address the logical-aspect of ordering of the content? What's your guys' take?
 +
 +
[[User:Smong|Smong]]: Uh yeah.. so why are there so many major edits to just one page? I can't see anything in recent changes but edits to the mervbot tutorial.
 +
 +
[[User:CypherJF|CypherJF]]: See my other notes: "CypherJF: Well I've been doing the edits from all around campus. Like yesterday I did 4-6 things from the MathLab; and the rest from the dorm, etc. lol. I don't think it really matters, since there isn't much other activity going on.. on the wiki." So, I'd make edits and just post em. It happened to be the only activity and sooo it looks worse than it is.
  
 
== sscanf ==
 
== sscanf ==
Line 22: Line 35:
  
 
If someone doesn't make the effort to look up events in dllcore.h, they shouldn't be making plugins. I think of this tutorial as more of a "here are the basics and intricacies of making a MERVBot plugin" more than "here is how to follow step-by-step instructions and call it programming". --[[User:Cyan~Fire|Cyan~Fire]]
 
If someone doesn't make the effort to look up events in dllcore.h, they shouldn't be making plugins. I think of this tutorial as more of a "here are the basics and intricacies of making a MERVBot plugin" more than "here is how to follow step-by-step instructions and call it programming". --[[User:Cyan~Fire|Cyan~Fire]]
 +
 +
D1s: Even ''I'' look up things in dllcore.h, its a very useful resource. As long as it says to look in it, I don't think we'd need the full list here
  
 
== Extra Code Samples ==
 
== Extra Code Samples ==
Line 29: Line 44:
  
 
Alrighty, looks good. One thing I would ask is to try to save up a bunch of edits in a text editor or something, than have the myriad edits you do now. Thanks for sharing the burden with me! --[[User:Cyan~Fire|Cyan~Fire]]
 
Alrighty, looks good. One thing I would ask is to try to save up a bunch of edits in a text editor or something, than have the myriad edits you do now. Thanks for sharing the burden with me! --[[User:Cyan~Fire|Cyan~Fire]]
 +
 +
[[User:CypherJF|CypherJF]]: Well I've been doing the edits from all around campus. Like yesterday I did 4-6 things from the MathLab; and the rest from the dorm, etc. lol. I don't think it really matters, since there isn't much other activity going on.. on the wiki.
 +
 +
Oh, OK, that's fine. Also, do remember that the wiki will automatically do your <p>ing for you as long as you leave a blank line in-between "paragraphs". --[[User:Cyan~Fire|Cyan~Fire]]
 +
 +
== Example Code commenting system ==
 +
 +
What's the use of it? --[[User:Cyan~Fire|Cyan~Fire]]
 +
 +
[[User:Smong|Smong]]: So if people don't understand the examples they can request help or a clarification. Also people that do understand an example might want to post a better/alternative solution. I suppose since you need an account to edit a page, maybe the wiki can be setup so you don't need an account to edit the discussion page so people can put comments in there.
 +
 +
I think I wasn't being very clear, Cypher didn't understand me either. I was talking about his <!-- EXAMPLE A: BEGIN--> stuff. Anyway, I've gotten permission from him to remove it, it was only supposed to be temporary. The idea of anonymous talk posts is a good idea, but I'm not sure if its possible. --[[User:Cyan~Fire|Cyan~Fire]]
 +
 +
== Make bot spectate specific coordinates Section ==
 +
--[[User:50% Packetloss|50% Packetloss]] 14:34, Feb 21, 2005 (EST)
 +
 +
This is what is currently there.
 +
<pre>
 +
tell(makeFollowing(false));
 +
tell(makeFlying(true));
 +
me->move(512 * 16, 600 * 16);
 +
tell(makeSendPosition(true));
 +
</pre>
 +
 +
Now when you tell the bot tell(makeFlying(true)); the core makes DLLFlying= true; Thus in the core's function void Host::doEvents() instead of the bot sending position packets, the job is left to the dll.
 +
<pre>
 +
//...
 +
if (DLLFlying)
 +
{
 +
Uint32 limit = settings.SendPositionDelay;
 +
 +
if (time - lastPosition > limit)
 +
{
 +
imports->talk(makePositionHook());
 +
}
 +
}
 +
else if (Me->ship == SHIP_Spectator)
 +
{ // Spectating
 +
Uint32 limit = settings.SendPositionDelay;
 +
 +
if (time - lastPosition > limit)
 +
{
 +
// Cycle player spectated
 +
if (Me->ship == SHIP_Spectator)
 +
spectateNext();
 +
 +
sendPosition(false);
 +
}
 +
}
 +
else if //...
 +
</pre>
 +
So in the dll, in the positionhook event, you need to add tell(sendPosition(false));. Im not sure if it will have a dramatic effect if the bot is in spec (never tested it), but if the bot is in a ship it will disappear from the screen. I don't know a lot about this wiki stuff so Ill leave it up to you ladies to edit.
 +
 +
== Random Number Selection ==
 +
 +
When picking a random number, the code for [[MERVBot_Tutorial#Picking_a_random_pilot|Picking a random pilot]] works off GetTickCount, which is very bad. GTC does not have single digit accuracy, and you can see this by running a loop for a couple of seconds and 'bucketing' the return values module X. If X is something like 25 or 50, you'll see very obvious patterns, where certain numbers are skipped completely. Even modulo something smaller like 10, and the distribution is horrible. The section right above this uses rand() correctly. In a simple tutorial, even rand() % X is much better than GTC() % X.
 +
 +
== About recent code changes ==
 +
 +
[[User:Mine GO BOOM|Mine GO BOOM]] 22:42, Jun 8, 2006 (EDT): Instead of using numbers in the code, such as '9' in atoi and 256 for str, you should use sizeof. If you change the size of str in the future, makes it easier to handle, and is also less prone to errors when you are coding, as you '''know''' it won't overflow the variable (unless it doesn't tack on '\0' at the end, check documentation on that function?).

Latest revision as of 00:43, 17 March 2008

hmm

Modified permanent get/setTag method = memory leak... boo telling them to beware is eh... i dunno BaK

General Convo

D1s: Anybody wanna format this int a table of contents? I'm lazy

Smong: That is sick. Maybe split into more pages? Says it is over 160k.

Pests: There is already pages defined. You could just split them up into that.

OK, I'm working on converting it to real HTML (using <pre>) instead of the &nbsp; crap. --Cyan~Fire

CypherJF: Should we just call this "the bot tutorial" based on the tutorial by Underlord? Then update it accordingly? -- And also, the link to MervBot w/e 37 is now 45; should we just comment that this tutorial was writen for the 37 -- or... comments! lol.

CypherJF: I'd like to say that all sections appear to have been updated for the Wiki; time to go through edit, and catch mistakes. Add to the wiki itself - perhaps more example code.

CypherJF: Cyan and I were talking about the section "Checking if pilot is in a safe zone"; whether or not to just remove it. I remarked that it's a nice section for those to the whole plugin deal. But, I was just noticing how it'd make more sense to put the "Useful Player data" before hand... So i guess the next step is to go through and try to address the logical-aspect of ordering of the content? What's your guys' take?

Smong: Uh yeah.. so why are there so many major edits to just one page? I can't see anything in recent changes but edits to the mervbot tutorial.

CypherJF: See my other notes: "CypherJF: Well I've been doing the edits from all around campus. Like yesterday I did 4-6 things from the MathLab; and the rest from the dorm, etc. lol. I don't think it really matters, since there isn't much other activity going on.. on the wiki." So, I'd make edits and just post em. It happened to be the only activity and sooo it looks worse than it is.

sscanf

Well, I'm using sscanf() for parsing player input. Yes, an advanced function, but maybe it will discourage C++ newbs from making bot plugins. Any comments? --Cyan~Fire

D1st0rt: Cool beans. I learned something new :D

Event list

Removed event list because it was redundant with dllcore.h, less descriptive, and too easy to get out-of-date. Anybody who wants it back, please post here so I can ignore you. :-D --Cyan~Fire

CypherJF: Like people are really going to read through the dllcore.h file.. on a webpage tutorial. hmm i think not. I still say keep it there.

If someone doesn't make the effort to look up events in dllcore.h, they shouldn't be making plugins. I think of this tutorial as more of a "here are the basics and intricacies of making a MERVBot plugin" more than "here is how to follow step-by-step instructions and call it programming". --Cyan~Fire

D1s: Even I look up things in dllcore.h, its a very useful resource. As long as it says to look in it, I don't think we'd need the full list here

Extra Code Samples

CypherJF: I'd like to somehow split these up better; and make them linkable, what do you guy's think?

CypherJF: I made sub-headers, and so they'll be added into the table of contents. Let me know what you guys think of it.

Alrighty, looks good. One thing I would ask is to try to save up a bunch of edits in a text editor or something, than have the myriad edits you do now. Thanks for sharing the burden with me! --Cyan~Fire

CypherJF: Well I've been doing the edits from all around campus. Like yesterday I did 4-6 things from the MathLab; and the rest from the dorm, etc. lol. I don't think it really matters, since there isn't much other activity going on.. on the wiki.

Oh, OK, that's fine. Also, do remember that the wiki will automatically do your <p>ing for you as long as you leave a blank line in-between "paragraphs". --Cyan~Fire

Example Code commenting system

What's the use of it? --Cyan~Fire

Smong: So if people don't understand the examples they can request help or a clarification. Also people that do understand an example might want to post a better/alternative solution. I suppose since you need an account to edit a page, maybe the wiki can be setup so you don't need an account to edit the discussion page so people can put comments in there.

I think I wasn't being very clear, Cypher didn't understand me either. I was talking about his <!-- EXAMPLE A: BEGIN--> stuff. Anyway, I've gotten permission from him to remove it, it was only supposed to be temporary. The idea of anonymous talk posts is a good idea, but I'm not sure if its possible. --Cyan~Fire

Make bot spectate specific coordinates Section

--50% Packetloss 14:34, Feb 21, 2005 (EST)

This is what is currently there.

tell(makeFollowing(false));
tell(makeFlying(true));
me->move(512 * 16, 600 * 16);
tell(makeSendPosition(true));

Now when you tell the bot tell(makeFlying(true)); the core makes DLLFlying= true; Thus in the core's function void Host::doEvents() instead of the bot sending position packets, the job is left to the dll.

//...
if (DLLFlying)
{
	Uint32 limit = settings.SendPositionDelay;

	if (time - lastPosition > limit)
	{
		imports->talk(makePositionHook());
	}
}
else if (Me->ship == SHIP_Spectator)
{	// Spectating
	Uint32 limit = settings.SendPositionDelay;

	if (time - lastPosition > limit)
	{
		// Cycle player spectated
		if (Me->ship == SHIP_Spectator)
			spectateNext();

			sendPosition(false);
	}
}
else if //...

So in the dll, in the positionhook event, you need to add tell(sendPosition(false));. Im not sure if it will have a dramatic effect if the bot is in spec (never tested it), but if the bot is in a ship it will disappear from the screen. I don't know a lot about this wiki stuff so Ill leave it up to you ladies to edit.

Random Number Selection

When picking a random number, the code for Picking a random pilot works off GetTickCount, which is very bad. GTC does not have single digit accuracy, and you can see this by running a loop for a couple of seconds and 'bucketing' the return values module X. If X is something like 25 or 50, you'll see very obvious patterns, where certain numbers are skipped completely. Even modulo something smaller like 10, and the distribution is horrible. The section right above this uses rand() correctly. In a simple tutorial, even rand() % X is much better than GTC() % X.

About recent code changes

Mine GO BOOM 22:42, Jun 8, 2006 (EDT): Instead of using numbers in the code, such as '9' in atoi and 256 for str, you should use sizeof. If you change the size of str in the future, makes it easier to handle, and is also less prone to errors when you are coding, as you know it won't overflow the variable (unless it doesn't tack on '\0' at the end, check documentation on that function?).