Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,246 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 3 of 3 1 2 3
Re: Tutorial: bitwise"&" operator use, **very usef [Re: Nadester] #19004
12/20/05 00:22
12/20/05 00:22
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Yeah I would smack my self in the face for reviving an old topic, but I actually was in need of this, had forgotten how to implement it, and there it was on my favourites list.

I don't think this ever was taken as far as it could be, using the square numbers meant the definition text was growing at an incredible length lol

I am gonna have to get up early and chew the fat on your take on bitwise implementation! Thanks for not chewing my face off for dragging the post up again


The Art of Conversation is dead : Discuss
Re: Tutorial: bitwise"&" operator use, **very usef [Re: indiGLOW] #19005
12/21/05 12:46
12/21/05 12:46
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
I just been talking to someone about using this method for node based path finding?

Im thinking that, each node has the skills set to the appropriate square number, incremented for ALL nodes, then a route through the nodes, could be stored like this...but could it also help work it out? I mean if you know the target node is 64, can you work out the route? Just thinking out loud


The Art of Conversation is dead : Discuss
Re: Tutorial: bitwise"&" operator use, **very usef [Re: indiGLOW] #280366
07/22/09 11:53
07/22/09 11:53
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline
Serious User
VeT  Offline
Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Great thread, this mustn't be lost.


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Tutorial: bitwise"&" operator use, **very usef [Re: VeT] #280393
07/22/09 13:54
07/22/09 13:54
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
wow, how long have you been searching to find this old thread? 2005 smile

I agree though, very important stuff here.
Just see the potential for mutliplayer games! If I have four guns and want to tell another user which of these was fired, with this I only need to send one value instead of 4...


Just a question though: has this changed now that we use LiteC and not Cscript?
How would you code the same thing with liteC?


Last edited by Germanunkol; 07/22/09 13:54.

~"I never let school interfere with my education"~
-Mark Twain
Re: Tutorial: bitwise"&" operator use, **very usef [Re: Germanunkol] #280408
07/22/09 14:40
07/22/09 14:40
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
#define setBit( x, n ) ( x |= (1<<n) ) //puts bit n in x on true (n=3, 10110 | 01000 = 11110 )
#define resetBit( x, n ) ( x ^= (1<<n) ) //puts bit n in x on false (n=3, 10110 ^ 00100 = 10010)

#define getBit( x, n ) ( x & (1<<n) ) //returns true when bit n in x is set (n=3, 10110 & 00100 = 00100 so TRUE ) (n=4, 10110 & 01000 = 00000 so FALSE)

int weaponsFired = 0;
setBit( weaponsFired, 3 ); //player 3 has fired (0000 | 0100 = 0100)
setBit( weaponsFired, 1 ); //player 1 has fired (0100 | 0001 = 0101)

if( getBit( weaponsFired, 3 ) ) { die(); } //we die due to player 3 (0101 & 0100 = TRUE)

resetBit( weaponsFired, 3 ); //player 3 stopped shooting, player 1 not (0101 ^ 0100 = 0001)

Last edited by Joozey; 07/22/09 22:13.

Click and join the 3dgs irc community!
Room: #3dgs
Re: Tutorial: bitwise"&" operator use, **very usef [Re: Joozey] #280428
07/22/09 15:49
07/22/09 15:49
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Interesting Joozey but one small mistake in your first example of the getBit macro:
n=3, 10110 & 00100 = 00100 so TRUE

either you meant n=2 or you need to add a zero at the end ;-)

Re: Tutorial: bitwise"&" operator use, **very usef [Re: Xarthor] #280435
07/22/09 16:17
07/22/09 16:17
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
great, thanks! smile


~"I never let school interfere with my education"~
-Mark Twain
Re: Tutorial: bitwise"&" operator use, **very usef [Re: Germanunkol] #280495
07/22/09 22:09
07/22/09 22:09
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I did made a minor mistake by not stating that the FALSE example is n=4. ((1<<4) makes 1000, (1<<3) makes 0100) From what I understand from your post you read the bits from left to right. But bits are to be read from right to left, and the remaining 0's are actually redundant.

0001 = 1 = 1
0010 = 10 = 2
0011 = 11 = 3
0100 = 100 = 4
0101 = 101 = 5
...

Last edited by Joozey; 07/22/09 22:16.

Click and join the 3dgs irc community!
Room: #3dgs
Re: Tutorial: bitwise"&" operator use, **very usef [Re: Joozey] #280521
07/23/09 06:41
07/23/09 06:41
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
no I also read from right to left but I guess I had a mistake in my thoughts somewhere else.
I assumed that the shifting starts with zero, so (1<<0) would make 0001 and (1<<3) makes 1000
But I guess thats wrong here.
Sorry for disturbing wink

Page 3 of 3 1 2 3

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1