Login
User Name:

Password:



Register

Forgot your password?
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
SWRFUSS 1.4
Author: Various
Submitted by: Samson
Users Online
Google, Naver

Members: 0
Guests: 24
Stats
Files
Topics
Posts
Members
Newest Member
488
3,788
19,631
595
Khonsu

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » General » General Discussions » Direction
Forum Rules | Mark all | Recent Posts

Direction
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2, 3 next >>
Post is unread #41 Jan 28, 2010 1:46 pm   
Go to the top of the page
Go to the bottom of the page

Keirath
Magician
GroupMembers
Posts148
JoinedJan 24, 2008

 
Is std::bitset something a C++ nub like me could figure out pretty easily?

Post is unread #42 Jan 28, 2010 2:33 pm   
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

 
I would think so, yes. It's an encapsulation of a bit vector that is created with arbitrary size.

If you want a topical example of writing "OOP" in C, by the way, I uploaded a C implementation of arbitrary sized bitvectors to MudBytes a while ago.

I'll mention again that I really don't think that std::bitset on its own is an appropriate solution; it's missing a few awfully nice features like automatic string conversion. (The code I refer to above doesn't have that feature, either. It's meant to demonstrate simple code that does something straightforward but in a (hopefully) pretty nice way, using OOP-like techniques in C.)

Post is unread #43 Jan 28, 2010 3:36 pm   
Go to the top of the page
Go to the bottom of the page

InfiniteAxis
Off the Edge of the Map
GroupAdministrators
Posts1,200
JoinedMar 21, 2006

 
After working in depth with std::bitset. It won't be used in these bases without a serious examination as to whether it's pros outweigh it's cons. It definitely leaves a little to be desired, as David Said, automatic string conversion would be nice. But it also appears to use more memory then an extended bitvector.

Might talk more later, defending human colonies in Mass Effect 2 right now... Oh, and drooling. Lots of drooling.

Post is unread #44 Jan 28, 2010 4:17 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
How exactly is "automatic string conversion" being defined? A template that does what flag_string does? If so, the one in AFKMud would suit this just fine.

I can't see memory usage being a deciding factor. Especially since I've not seen any indication in my own experience that std::bitset is any more or less of a memory hog than anything else. I think you're going to find that just including the STL in general is what's doing most of the memory hogging. You'll get that with std::string or std::vector just as quickly.

Post is unread #45 Jan 28, 2010 4:26 pm   
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

 
I haven't looked at the one in AFKMud, but I was thinking something along the lines of being able to set flags on the bitvector by name or by number. It would also make stringification easier, by returning a vector of strings that are set that the caller can then join as appropriate (using commas, spaces, whatever). The general idea is to encode the size and the associated strings with the template. A nice consequence of this is that bitvectors of the same size but different flag names become type-incompatible, so you cannot assign, e.g., mob flags to room flags even if they happen to be of the same size.

Post is unread #46 Jan 29, 2010 1:57 am   
Go to the top of the page
Go to the bottom of the page

kiasyn
Magician
GroupMembers
Posts121
JoinedJun 30, 2006

 
link should be working now

Post is unread #47 Jan 29, 2010 11:48 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
David Haley said:

I haven't looked at the one in AFKMud


I'm talking about this template:
template < size_t N > char *bitset_string( bitset < N > bits, const char *flagarray[] )
{
   static char buf[MSL];
   size_t x;

   buf[0] = '\0';
   for( x = 0; x < bits.size(  ); ++x )
   {
      if( bits.test( x ) )
      {
         mudstrlcat( buf, flagarray[x], MSL );
         // don't catenate a blank if the last char is blank  --Gorog 
         if( buf[0] != '\0' && ' ' != buf[strlen( buf ) - 1] )
            mudstrlcat( buf, " ", MSL );
      }
   }

   if( ( x = strlen( buf ) ) > 0 )
      buf[--x] = '\0';

   return buf;
}


I'm not sure exactly what you were proposing with setting flags on the bitvector. Do you mean extending the bitset class with additional member functions?

Post is unread #48 Jan 30, 2010 2:29 am   
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

 
Yes, I'm referring to more methods on the bitvector class, and indeed even encoding the flagarray as one of the template parameters to the bitvector type.

So it would be something like:
// declare the type
typedef bitset<123, mobflag_names> mob_flag_set;

// create an object of this type
mob_flag_set myMobFlags;

// set a flag by name
myMobFlags.set("guardian");

Post is unread #49 Jul 30, 2023 9:10 pm   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 
Good to see that link spammers are still at it. Am I missing something or is there literally no way to report spammers on this forum now? :facepalm:

Post is unread #50 Aug 3, 2023 11:08 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
There's no report button? Come to think of it I honestly can't say whether there ever was one or not, but I don't see one myself. I'm the admin though so it makes little sense for me to have one :P

In any case the spam post has been dealt with, including sending it to Akismet for processing.

Pages:<< prev 1, 2, 3 next >>