Thursday, November 23, 2017

Digest for comp.lang.c++@googlegroups.com - 7 updates in 4 topics

"Öö Tiib" <ootiib@hot.ee>: Nov 23 11:49AM -0800

The C++ developers are different and so some write functions as
members, others as free functions or templates or even
specialize standard library templates.
 
There must be some trick how to sort that out with code.
 
How to implement such function template that calls a member
function or if such is not present then function from namespace
of argument or from global namespace or if such is not present
then a function from std namespace?
 
For motivating example "smart swap" that calls a member swap or
swap from namespace or std::swap. Since the checks are compile
time these will be likely removed by optimizing compiler
(like I comment out in following):
 
template<typename T>
inline void smart_swap(T& a, T& b)
{
// if (T::swap(T& t) exists)
a.swap(b);
// else if (swap(T& a, T& b) is found) swap(a, b);
// else if (::swap(T& a, T& b) is found) ::swap(a, b);
// else std::swap(a, b);
}
 
It is sure possible, but how to?
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 23 09:43PM

On Thu, 2017-11-23, Öö Tiib wrote:
> The C++ developers are different and so some write functions as
> members, others as free functions or templates or even
> specialize standard library templates.
 
Of course it also depends on the situation: which function you're
implementing.
 
> // else std::swap(a, b);
> }
 
> It is sure possible, but how to?
 
I haven't been paying attention (sorry!) but isn't this what
std::swap() is supposed to take care of?
 
Or put differently, isn't the author of T responsible for the
performance of std::swap(T&, T&) ?
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
fir <profesor.fir@gmail.com>: Nov 23 09:41AM -0800

W dniu środa, 22 listopada 2017 23:00:47 UTC+1 użytkownik Chris Vine napisał:
> don't particularly like their format.
 
> Back in the day, comp.lang.c++.moderated was the only C++ newsgroup
> that I read.
 
just follow strictly the antiidiot policy and rick troll will drop dead
 
1) never answer this idiot troll spamer (never, even if he talks on topic)
2) dont read it as you will allow his stupidity to disturb you
3) inform the newcomers about this moron shortly
Richard Damon <Richard@Damon-Family.org>: Nov 23 01:57PM -0500

On 11/22/17 3:35 AM, David Brown wrote:
> There is nothing that can be done about Rick's "stalker". Perhaps if
> Rick doesn't keep rising to the bait and multiplying the crap with "that
> was not the real me" posts, he would get bored and go away.
 
Actually, impersonation of another is generally a violation of the
AUP/TOS for most servers. While Giganews does not explicitly forbid it
by name, it likely falls outside their acceptable use policy. If Rick
maeks a report to abuse@giganews.com, it is quite possible that the
attacker may lose their posting privileges.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Nov 23 12:39PM -0800

On Thursday, November 23, 2017 at 1:58:06 PM UTC-5, Richard Damon wrote:
> by name, it likely falls outside their acceptable use policy. If Rick
> maeks a report to abuse@giganews.com, it is quite possible that the
> attacker may lose their posting privileges.
 
I have already done so.
 
--
Rick C. Hodgin
Richard Damon <Richard@Damon-Family.org>: Nov 23 01:39PM -0500


> https://ibb.co/kXKnCm
 
> https://ibb.co/jOFG56
 
> He is completely MAD !!!
 
It is fairly easy to see that those are likely impersonations, as Rick
post via Google Groups, but the impersonations come via Giganews.
 
While it is possible that Rick opened an account on Giganews to fake an
impersonation of himself, that is sort of unlikely.
fir <profesor.fir@gmail.com>: Nov 23 09:25AM -0800

I once wrote on this, but maybe i will
repeat
 
Im like 'fighting' for 15 years with OOP crap by saying sporadically that it is stupid and bad, I also often say that procedural is solid and cool (hovever probably there could be invented something other here too) modular is cool (l love windows dll-s greatly) and agent based is expected to me to be very cool too
 
agent bbased paradigm is somewhat researched by some but it is not
presented to much clear and practical afaik, I also on my side research it
a bit (though i dont spend many tme on it i was writing some texts on it)
 
I once find and wrote here on this group that agent based paradigm can be in fact realized (made) by normal c coding by using dll-s (his was not quite clear before)
 
I also was describing how it can be done and show basic elements of that
realisation
 
i also wrote a basic runing example (though im not sure if i posted it then, now i slightlt revrite it and may post it to download and see or test - sorry it is much ugly and basic
but as emmet brown says ;c i got no
time to much improve it (yet))
 
the basic elements are
 
1) you code host.exe
 
this is environment that link to your agents (whose are dll's - each dll is not agent per sef but it is code for a
group of agents of such type; ho0st will call this agent.dll as many times as he wants instantiating N agents of given type )
 
2) you code agent.dll (or more for separate types)
 
agent.dll has one entry point (i think it may be called Update() though i call i Run() in my code) this function/method is called in cyclic giving life to given agent - this is
one and only routine that is called on that agent
 
agent cyclically pools his environment
(methods for that are provoided by host.exe (it showed fortunatelly that exe can export functions too, though to be able to link it from agent dlls i need to build import library for the exe in mingw/gcc)
 
in my example the api provided are only two functions
 
__declspec(dllimport) int Move(int dx, int dy);
 
__declspec(dllimport) int LookAt(int dx, int dy);
 
one moves agents to adjacent cell on map the second gives info what is on adjacent tile
 
yhe host has a controll on that methods, for example if one agent
would like to jump more that to +-1,+-1 position form his current
position host can cut it off - this is very important as it provides hard
interface for agents 'abilities',
environment/hosts limits them and that
makes it really fully work at an agent
paradigm rules (it fully provides them, and thats why its so nice imo)
 
i wrote ugly and simple host (dorry i got no time but i will wrote more good lokking and cool in future i hope)
tthat is 2d soccer field
 
http://minddetonator.htw.pl/uglyhost.png
 
throwed a lot of 'balls' here (ball symbols more)
 
and i also coded two agents blacks and whites (each one in 10 instances) and
code them very simple behaviour, blacks walk in random,
 
 
int RunAgentBlack()
{
int dx = rand()%3 - 1;
int dy = rand()%3 - 1;
 
Move(dx, dy);
 
return 0;
}
 
 
whites look right for a bol if there is ball here they move on that ball pushing it, if no ball at right they are also walk in random
 
 
int RunAgentWhite()
{
 
 
int dx = rand()%3 - 1;
int dy = rand()%3 - 1;
 
if(LookAt(1, 0)=='b')
Move(1, 0);
else
Move(dx, dy);
 
 
return 0;
}
 
 
the app is ugly etc but my purpose was to ilustrate that agent paradigm can be done in c with dlls , can be well done in c with dll and how can be done in c with dlls
 
this is this app (can be tested on win32, probably will work in wine)
 
minddetonator.htw.pl/ag.zip
 
there is compile bat script there
so if someone only have mingw installed it can edit click and compile its own agent behaviours
 
(that could be used to play in some
agents/bot coding, compare the results
and make some agents science and experience, though i sadly know how lazy people are and do not expect to much from them)
 
(this post is btw an introduction to tis topic i hope to write more on this after)
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: