The need for an IRC #chatroom for ACK users

Chris H.'s Ultima / ACS-style game development system!

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

The need for an IRC #chatroom for ACK users

Post by Garth's Equipment Shop »

I am a big fan of IRC. I normally use it for online gaming because it is easy for players to lose each other in game but if they are in same IRC channel they can stay in touch, call for help, set up trade meetings, or whatever.

But I have often wished for a channel with ACK users in it whenever im in the middle of the design process and i just wanted to ask a quick question and move on, or to get feedback on something, or ask for any ideas on how to impliment something, or to report bugs found in a WIP or to ask about how to use a mod such as rld's MEgamod.

Right now I've run into a problem loading one of my old test adventures in which i had set up a skills system complete with its own separate experience gains/leveling for each skill, and the skills can be used in game for resource gathering, crafting, etc. Unfortunately this particular game will not load from the ACK launcher even though all the others do. I went into the folder and all seems to be in order there so i havent a clue what the problem could be.

I have a question about the use of the megamod. What do you and Heather mean when you talk about setting the bits of a variable? IS it something different that simply A=1?
Last edited by Garth's Equipment Shop on Sat Jul 17, 2010 8:00 pm, edited 1 time in total.
Which of you is interested in my fine wares?

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Sometimes you just need real time help or feedback you know? Makes a huge difference. Alot more efficient for the design process, and also there you can possibly collaborate like in a design team. Easy to set up new channels if need be for folks who wish to really collaborate on a single design.
Which of you is interested in my fine wares?

Heather Harrison
Posts: 44
Joined: Fri May 21, 2010 8:40 pm

Post by Heather Harrison »

As far as bits of a variable go, it works something like this. Translating a number into binary will show which bits are set. For example, A=5 is binary 00000101 (assuming A is an 8-bit variable). Making use of each bit separately is a very efficient way to use variables when you need a bunch of status flags that are set to either 0 or 1, or when you have variables that have a limited range of values.

ACK supports the logical & operator in IF statements, and this can be used to figure out whether or not a bit is set. On the example above, A&4 will register as true because the third bit from the end is set to 1, but A&2 will register as false because the second-to-last bit is set to 0.

In ACK, one easy way to set a bit is (after making certain that the bit isn't already set) is to do something like SET A=A+128. This will change the first bit to 1 if it isn't already set. (Or use A=A-128 to set that bit to 0 if it is set to 1.) I haven't fully gone through the documentation yet to see how well ACK supports logical operators. If it can do something like SET A=A | 128 or SET A=A & !(128), then it won't be necessary to know beforehand whether a bit is already set.

Since this is binary, the decimal number corresponding to each bit is 2^n. In an 8-bit variable, the highest bit corresponds to 128, and in a 16-bit variable, the highest is 32768.

An example of why this is useful is the magic system in my new version of Ultima II. It only takes two 16-bit variables (S2 and T2) for me to keep track of all of the wizard and cleric training and spells, and I even have a few bits left over in case I decide to add some spells later.

Here is an example.

If S2=29189, then the player has had novice (2^12 = 4096), intermediate (2^13 = 8192), and advanced (2^14 = 16384) wizard training and knows the first (2^0=1), third (2^2=4), and tenth (2^9=512) wizard spells. If you add up all these numbers, you will get 29189. Then, when trying to cast a spell, the game checks whether the player knows the spell. If the player tries to cast the fifth (2^4=16) wizard spell, the game checks S2 & 16. In the example above, this comes out false and the spell cast macro displays a failure message. If the player tries to cast the first wizard spell (2^0=1), the game checks S2 & 1, and this comes out true so the spell casting macro can move to its next step.

Hopefully my explanation hasn't been too long-winded, but since the question was asked I thought I should put in a detailed explanation in case beginners to this way of thinking stumble upon this thread.

I've been doing this for years. Back in my days of programming on a limited 8-bit computer (an Atari 800, which is still in good working order, by the way) I used this method extensively to conserve memory.

I still need to go through the documentation to figure just how well ACK supports the logical operators so that I can possibly avoid doing some things the hard way.

My Ultima II remake is so big that I have to do this where possible in order to get the most out of the available variables. It may seem like ACK has a lot of general-purpose variables available, but it is easy to use them up, especially when there are multiple quests and a complex magic system to keep track of.

Heather

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Wow! That is so complex! I had no idea anything in ACK could get THAT complicated lol! BAsically all i understood was that it is somehow possible to squeeze a bunch more values into just a few variables or have one variable somehow do the work of many variables? Whichever the case, at the end of the day you are getting more bang for your buck within ACK's limited framework. I want to learn to do that. So I will attempt to get my head around what you tried to explain to me. So far it is going over my head unfortunately lol. Is there a good "for dummies" reference to this sort of thing somewhere online? Something to take me from total noob in the dark to "eureka! I get it! :D"?
Which of you is interested in my fine wares?

Heather Harrison
Posts: 44
Joined: Fri May 21, 2010 8:40 pm

Post by Heather Harrison »

Once you understand it, it really isn't that complicated. It's just basic mathematics and logic on a base 2 system, rather than the base 10 system we all know well. I've never looked around on the web for explanations of efficient use of variables through binary numbers. I figured this out on my own back in the 1980's. I think one reason ACK appeals to me is that it makes sense in the context of my early computer experience. In a way, I see the limitations as a challenge, and in my Ultima II remake I am trying to find out just how much ACK can do.

Maybe the Wikipedia entry on binary numbers is a good place to start.

http://en.wikipedia.org/wiki/Binary_numeral_system

If you have any specific questions, maybe rld or I can help.

Heather

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Post by rld »

ACK does support the bitwise AND (&) and OR (|) operators in SET assignments, as well as in IF expressions. From the change notes:

Code: Select all

Changes in v3.231:

New operators for macros: & (and), and | (or).  Useful for bitwise operations, allowing you to store lots of yes/no values in a single variable.  For example, "SET A = A | 64" and "IF A & 64 THEN..."

I verified that the & and | operators are working with SET.

So, for example:

To set bit 0 of variable A to 1: SET A = A | 1
To clear bit 0 of variable A to 0: SET A = A & 254

To set bit 1 of variable B to 1: SET B = B | 2
To clear bit 1 of variable B to 0: SET B = B & 253

For a clear, you could also do

IF B & 8 THEN
SET B = B - 8

if that's easier to follow.

Post Reply