Author Topic: Question Regarding Axe Murderer's Flag Sets  (Read 348 times)

Legacy_DM_Vecna

  • Hero Member
  • *****
  • Posts: 501
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« on: July 13, 2011, 03:42:41 am »


               First off math is my weak point including the correct usage of terms.

I have yet to really dig into this system for all it is worth. At first glance I would like to set a variable on my commoners to determine if they are to be randomized and in which catagory.

For instance: with 32 boolean flags
0000 0000 0000 0000 0000 0000 0000 0000
lets say the farthest right digit could represent randomized head
the second to the right could represent the need to randomized hair color
etc.

So if I want to set this variable ahead of time on the commoner will I need to convert it to some other format than the above 32 digit integer? If so can anyone teach me how to do that on a calculator? '<img'>

Thanks so much!!!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #1 on: July 13, 2011, 04:47:11 am »


               I myself like to use cCac
'Image

I do not however know of a place tht you can download it by itself.   The only place where I know of where you could get a copy of it is by downloading the Hide package. >>  HIDE - High Level Assembly download page. 


If you downloaded the HIDE Full install from the link above. You could find the cCalc.exe program in the  .\\HIDE\\bin directory.   You can just exstract it from the zip and discard the rest.  It is a standalone program and does not need the rest of the package to run. 

To convert your flags to an intenger all you would have to do is check off the flag and read the number from the Singed field below it.  



As far as binary numbers and converting goes.  This may help. 
CHAPTER ONE:
DATA REPRESENTATION

               
               

               


                     Modifié par Lightfoot8, 13 juillet 2011 - 04:17 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #2 on: July 13, 2011, 05:16:15 am »


               This is easy on the calculator that comes with Windows. Just set it to Programmer view, and you can convert from hex, binary, and digital at the click of a button.

Funky
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #3 on: July 13, 2011, 05:24:58 am »


               

FunkySwerve wrote...

This is easy on the calculator that comes with Windows. Just set it to Programmer view, and you can convert from hex, binary, and digital at the click of a button.

Funky


Do you mean the Scientific View in windows calculator?     Or is there an upgrage to the caculator that I dont know about in future versions of windows? ( I'm Still running XP) . 

If you do use the windows calculator (at leas the one I have with XP.)  I would suggest converting the numbers to HEX by hand then converting to decimal.    Just from experence I mess up way too many times trying to type in a string of 32 bits.  
               
               

               
            

Legacy_Tiggers.no.tail

  • Jr. Member
  • **
  • Posts: 82
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #4 on: July 13, 2011, 05:34:11 am »


                If he's using a 4-byte integer (32) bits to make a Bit mask it's quite simple to add things. Say for example I have one byte:0000
The "furthest left" bit is referred to as the "Most Significant Bit" (as it represents the highest value, in this case 8), the "furthest right" bit is called the "least significant bit" (it represents 1).
Lets say in your example that the MSB represents a randomized head and the bit to the right of it represents the randomized hair color.
Using boolean math you can make a bitmask out of this like follows. Say for example I have the following consts

const int RANDOM_HEAD = 8
const int RANDOM_HAIIR_COLOR = 4
const int RANDOM_.... = 2
const int RANDOM_... = 1
If you want to set the flag to include a random head and a random color do the following (lets say you're passing it into the function

void Foo( int MY_BIT_MASK ) {
}

you can make a function call like this:

Foo( (RANDOM_HEAD|RANDOM_HAIR_COLOR) );

(note the use of PIPE ( | ) to OR them together)

This will cause the language to BITWISE OR the value together.

if you want to TEST for what flags are set, it simple, you can do so using BITWISE AND'ing to check for a
certain flag

for example

void Foo( int MY_BIT_MASK ) {
    if( MY_BIT_MASK & RANDOM_HEAD ) {
        //code to run for random head here
     }
    if( MY_BIT_MASK & RANDOM_HAIR_COLOR ) {
      //code to run for random hair color
   }
}

Using this method, you can store a maximum of 32 flags inside a single 4-byte integer.

Hope this helps.
               
               

               


                     Modifié par Tiggers.no.tail, 13 juillet 2011 - 04:35 .
                     
                  


            

Legacy_DM_Vecna

  • Hero Member
  • *****
  • Posts: 501
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #5 on: July 13, 2011, 05:53:57 am »


               great, thanks for the input guys. So I really like cCalc. It was easy to download. But let me make sure I am using it correctly. If I want true on the flags 0,1,2,11,12,13 I get 14343. So for the flag I would store 14343 as an int?

thanks,
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #6 on: July 13, 2011, 05:58:36 am »


               

DM_Vecna wrote...

great, thanks for the input guys. So I really like cCalc. It was easy to download. But let me make sure I am using it correctly. If I want true on the flags 0,1,2,11,12,13 I get 14343. So for the flag I would store 14343 as an int?

thanks,


Correct.

Also if you type the number into the input line it will show you what bits are set in the number.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #7 on: July 13, 2011, 06:04:19 am »


               

Lightfoot8 wrote...

FunkySwerve wrote...

This is easy on the calculator that comes with Windows. Just set it to Programmer view, and you can convert from hex, binary, and digital at the click of a button.

Funky


Do you mean the Scientific View in windows calculator?     Or is there an upgrage to the caculator that I dont know about in future versions of windows? ( I'm Still running XP) .    


No, I mean Programmer View. It's new in Win 7:
See a picture of it here

Funky
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #8 on: July 13, 2011, 06:07:34 am »


               @Funky

Cool.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #9 on: July 13, 2011, 01:56:51 pm »


               @Funky

Echo Lightfoot8's comment + very.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Question Regarding Axe Murderer's Flag Sets
« Reply #10 on: July 13, 2011, 05:59:44 pm »


               Here is the link to download it if you want. It works for xp and up. The exact one shown above can be found on the net. I found it also and tested with vista and will test it with xp and get back to you.
www.microsoft.com/download/en/details.aspx
               
               

               


                     Modifié par ShadowM, 13 juillet 2011 - 05:43 .