Jump to content
XCOMUFO & Xenocide

Alien Calculator


stewart

Recommended Posts

I cant remember if I mensioned but before a PDA were to be put in the game it'd be neat if there was a JAVA version on the website. Anyway before doing that, I think for practise and to work out the kinks it might be neat to create a simple alien electronic calculator simulator as a JAVA thingie first. It'd be a lot simpler than a PDA simulator, it could generate interest through geek-appeal and we might learn from the process of making it.

 

I have some ideas already.

First rather than having all 64 numbers on there it has:

0, 1, 2, 3, 4, 8, 16, 24, and 32, from these you build the numbers. We should just make it a basic + - x / ^ sto rcl

 

What do you think?

Link to comment
Share on other sites

I agree, having all 64 numbers would be cumbersome and not very practical.

Well, it's not that I'm against a alien calculator, but Aliens might calculate a lot in their heads, and if not, they might have something more sophisticated then a calculator with a keypad. I think they would use sth. with a brain interface, no? Or did I get this wrong and this is for the X-Corps troops?

Well, nevermind. It's not really speaking against a calculator as a toy for us, just if we want to fit it in the game as an alien artefact (v1+ or bonus) we might see us confronted with ome problems explaining it.

On the technical side I agree with you - but you don' need the 3, so why use it?

Link to comment
Share on other sites

Okay, now I'll try to come up with an output display concept. Then the artists in our little group inspired by those can come up with a visual for the whole thing.
Link to comment
Share on other sites

  • 1 month later...

Well guys, it took me some time, but I managed to come up with a very simple Alien Calculator. Until now, one has to feed it with decimal numbers, it is only able to add two numbers and it's not designed to calculate big numbers (it can only display two Alien digits, so maximum is "63|63"(which is sth around 4096 - which is not working so, last safe working number was 4094 if I'm not mistaken - whyever). Nevertheless, it's a start :)

Have a try and tell me what you think.

Edited by Mad
Link to comment
Share on other sites

It craps out for sums larger than 62 though.

It does? Damn! How do you define "crap out"? That it writes two digits for sums bigger then 62 is the way it's thought to work. Maybe I got the Alien numbering wrong, but I thought, we do this like this: one digit for 0-63, if the Number is bigger then 62, two digits are used. For a 63 this will be a 1 followed by a zero (1*63 + 0 = 63), for 64 a 1 followed by a 1 (1*63 + 1) and for 129 a 3 followed by a two (2*63 + 3) etc etc...

Edited by Mad
Link to comment
Share on other sites

Nope 64=10.

can't work this way. then they would have 65 digits. This would be Base 65 then, wouldn't it? Remember, you have to start counting with the zero - Dual-System is base 2 - you use zero and one. (I mean, it's no problem to change it, just thought we would use 64 Symbols... )

 

---Edit---

yes, exactly like you said! 64 = 1 0. Sorry. Fixed in the new version. At least I hope so.. . :)

Edited by Mad
Link to comment
Share on other sites

Ok, here is a new, much more powerful version. It is able to add, substract, multiply and divide all numbers fitting into the "Integer" data type. Meaning: you can use numbers up to 4000000000. I think this should be sufficient... :)

It has a few bugs though (like not displaying a zero if the result is 0) but I'm just too tired to fix this right now. I will handle this in the next days. :) Until then... enjoy... :)

Again, I would be happy if you could post any bugs you encounter (especially wrong results!!!). Thanks :)

 

---Edit---

Could not sleep with the zero issue... fixed... :)

Should be without any bugs now.

Edited by Mad
Link to comment
Share on other sites

Okay, now I'll try to come up with an output display concept.  Then the artists in our little group inspired by those can come up with a visual for the whole thing.

How far are you with this? I think, I'm more or less done with the calculator, only thing missing is a "GUI" and the fitting routines...

 

---Edit---

Oh, and it would be cool, if every "button" is a JPEG on it's own, 'cause I intend to realize the input with an "onclick" routine. :)

 

---Edit2---

wohoo post #500 :party:

Edited by Mad
Link to comment
Share on other sites

Okay lets begin with the input panel. I'll make a negative color version of it to represent a pressed button. I'll come up with a functional description of it. In the mean time look up RPN calculators, there are some online simulators of HP RPN calculators. RPN is the 1-enter-1-plus variety rather than 1-plus-1-equals.
Link to comment
Share on other sites

Okay lets begin with the input panel.  I'll make a negative color version of it to represent a pressed button.  I'll come up with a functional description of it.  In the mean time look up RPN calculators, there are some online simulators of HP RPN calculators.  RPN is the 1-enter-1-plus variety rather than 1-plus-1-equals.

That is exactly what I wanted to do, because, I think something like this will be the only way to go, if we don't want 64 numbers on the input panel... Nevertheless, I thought of something in the way of 1-enter-plus-1-enter, because it's more intuitive, isn't it?

 

---Edit---

Ok, I checked on RPM, and I must say, though this is fascinating I prefer the Algebraic method. Nevertheless, because it's much easier to code... :Blush: (javascript doesn't know stacks)

Edited by Mad
Link to comment
Share on other sites

Engineers use RPN I figured the aliens . . . .

 

 

post-3-1139616389_thumb.jpg

 

 

Okay let me draught-up a description; hang on.

 

We'll just do a stack depth of two with one store.

Link to comment
Share on other sites

The basic way function are run is: firstnumber-enter-secondnumber-operation; there is no "equals" button.

 

The first number is place in the first place on the stack. The second number is also put in the first place on the stack and the first number moves to the second place on the stack. When the operation is performed on the two numbers, the stack is cleared and the result is place in the first place on the stack. If a third item is placed on the stack, everything shifts up and the top item is destroyed.

 

There is a place to store one number; this is outside the stack. The item in the first place on the stack is copied to this location; the stack item is not removed. A number retrieved from store is placed in the first stack position, everything moves up.

 

Swapping shifts the second stack item to the first and the first to the second.

 

So to review the button so far:

Store puts an item into storage.

Get, gets an item from storage

Swap, exchanges the two items on the stack.

The various arithmetic operators perform their function with stack item two being the first number and stack item one as the second item.

 

Above the buttons is a four-line display. The lowest line is the number presently being entered The second lowest line is stack item one, the second highest line is stack item two and the top is storage.

 

Now the more complicated part: entering numbers. There are nine numbers represented. Notice that 1,2, and 3 are grouped together, and that, 8, 16, and 24 are also grouped together. Each digit is "built". If you press 32 then the number will be at least 32, pressing four adds four to it. But repressing these numbers does nothing more. In the case of the grouped numbers if you press say 1 then it adds 1 to the number but if you now press 2 it will subtract 1 then add 2. So it will only take the last entery of the entire group. Zero is different, hitting zero sets the total to zero clearing whatever work you've done so far, so the digit is now set at zero. If you want though you can add to zero.

 

Hitting enter, enters the digit, then you star entering the next digit which then shift the digit you just entered one place to the left. Once you've entered the final digit you hit enter one more time to put the entire number in the first stack location. Hitting the x key is the decimal.

 

Clear as mud?

Link to comment
Share on other sites

Hitting enter, enters the digit, then you star entering the next digit which then shift the digit you just entered one place to the left.  Once you've entered the final digit you hit enter one more time to put the entire number in the first stack location.  Hitting the x key is the decimal.

 

Clear as mud?

Clear, but not programmable - at least I do not know how to until now... ^_^ . If I understand you correct, you want a double-enter for declaring the first number complete and stored in Level1 of the stack? I have absolutely no clue if, and if, how to program this in Java. Can't we just make an extra button? Hm. I will try to think of a way to code this, but maybe it would be better / more easy to add another button...

Edited by Mad
Link to comment
Share on other sites

Enter for each digit of the number then enter for the entire number.

 

On the other hand anouther button wont hurt. Program for an extra button. I think I'll also add a clear stack and clear memory button too. Let me work on the graphic.

Link to comment
Share on other sites

I've got the keypad in my head but I still have to draw it up. It'll be:

 

0,1,2,3,4

.,8,16,24,32

+,-,Put,Enter

*,/,Swap,Clear_Stack

^,Store,Get,Clear_Store

Link to comment
Share on other sites

0,1,2,3,4

.,8,16,24,32

+,-,Put,Enter

*,/,Swap,Clear_Stack

^,Store,Get,Clear_Store

 

Looking good :) (could you draw every button as single JPEG? So that it won't be one big picture, but 20 pictures? Thanks :) )

What is "swap" for?

Link to comment
Share on other sites

Lets make the display AT MOST 8 digits wide, and that's including decimal and exponent.

 

BTW what do think about exponent? Do you want to bother with that?

Link to comment
Share on other sites

Lets make the display AT MOST 8 digits wide, and that's including decimal and exponent.

 

BTW what do think about exponent?  Do you want to bother with that?

Exponent in the display? I'd rather not... ^_^ Decimal alone will be a pain in the a$$... :( Nice keypad :) Well, so I will try to cut it apart...

Link to comment
Share on other sites

I figured you'd say that. I'd better come up with some error codes for the display then.

 

Come to think of it I should come up with the display. :(

Link to comment
Share on other sites

I figured you'd say that.  I'd better come up with some error codes for the display then.

 

Come to think of it I should come up with the display. :(

Error codes? Like: "What, you dare to think in such ambitious hights? The great OM will crush you for your arrogance!" ;)

Well, I figured we would just leave the display in a monochrome color (or non-color like white) which will be the color of the website in which javascript is printing the reults. And around it you could make a nice frame - so we would have a housing for the keypad and the display. Just like a good old earth calculator... :)

Well, and the thing with the exponents and decimals is a little bit complicated, since the program now calculates using integers. So technically ther are no decimals. I will have to write a complete new subroutine for that, and I'm "just" a CTD member after all... ;) so this might take me a while...

Edited by Mad
Link to comment
Share on other sites

I was thinking of a segmented display. I meant error codess like: undefined (divide by zero or square root of a negative), over/underflow.

 

We can do reals of the 123.456 variety but skip the 123.456E100 variety.

 

Oh crap I've got to decide how I want to handle negatives!!!!

Link to comment
Share on other sites

I was thinking of a segmented display.  I meant error codess like: undefined (divide by zero or square root of a negative), over/underflow.

 

We can do reals of the 123.456 variety but skip the 123.456E100 variety.

 

Oh crap I've got to decide how I want to handle negatives!!!!

Yea, I would apreciate if we could skip the exponential thing. We can't use too big numbers anyway.

 

Segmented display? Yea, no problem. Just remember, that you won't see anything of the display anymore as soon as a number is displayed - that is of course if we stick with the digits the calculator now uses.

Link to comment
Share on other sites

Okay here' the potential outputs of the display.  I'll post the blank display and chassiss shortly

Wow! This certainly looks cool! :)

 

---Edit---

On the other hand... I would like to do something veeery painful to you... You did it again: one big bmp instead of 74 small pictures... :Cry:

Well, at least it's easier to cut them out now with the white background... :)

In a related matter: what's the purpose of those "empty" fields?

Edited by Mad
Link to comment
Share on other sites

Actually the "line" that says error you can take all 8 squares.

 

Anyway I've resized the buttons.

 

Here's the "pressed buttons.

 

Calculator

 

 

and it's ugly

 

 

Hey it's V.1

 

If someone wants to jazz it up, be my guest.

Pushed_Buttons.bmp

Pushed_Buttons.jpg

calculator.bmp

calculator.jpg

Link to comment
Share on other sites

Well perhaps the other folks who read this forum can try prettifying it.

And if there is someone amongst these who knows javascript, thou shall raise their voices, 'cause I've run into some trouble using functions...

Link to comment
Share on other sites

never used it but whats your question anyway.

Well, the thing is, I tried to write an input routine (which is "reading" the user input (user clicks on a digit, routine gets it and writes the digit to the screen)).

This is working fine, but two things bother me. 1st) It locks up in Firefox. After the digit is written to the screen it is caught in an endless loop and nothing happenes. And, possibly connected to the first error the 2nd) when I hit the reload button, nothing happenes. I have to open the script "fresh" so it will work again.

 

This is the test code I worked with so far:

<html>
<head>
<script language="javascript">
//initialize variable picname
var picname;

//declare function printpic, which can get one input variable (picname)
function printpic(picname)
{
//write "<IMG src = alienNumberXX.jpg>"  (where XX stands for a number from 0 to 64) to the html document, to call the picture with the correct digit.
document.write("<IMG src=alienNumber" +picname +".jpg>");
}   
</script>
</head>

<body>
//initialize a form for the keypad
<form name ="keypad">
//use a picture (of an alien digit) as input. when clicked initialize the function printpic with the corresponding number.
<input type="image"SRC=keypad1-1.jpg  name="key1" id="key1" onclick="printpic(1)" />
</form>
</body>
</html>

That's it. Ihave no clue why it's not working the way it should... :(

(I used the complete html structure, including every tag, so everyone can just copy&paste it in a text document and run it as html code. Pictures are not included, well, this shouldn't cause any trouble I think.)

 

Apreciate any help I can get. Thanks. :)

Link to comment
Share on other sites

×
×
  • Create New...