Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Xeda112358

Pages: 1 ... 66 67 [68] 69 70 ... 317
1006
Dapianokid said his took 11 seconds to compute the 42nd prime palindrome, but from the conversation, he may have a much more efficient algorithm for larger values. I think his was also running at 150MHz, so I am not sure.

Has anybody set any benchmarks for other languages?

1007
So, I am curious, too, with what Runer is asking. For example, in TI-BASIC, although we could make a program to handle arbitrary precision, can we safely assume that we will only be using up to 14-digit numbers?
Spoiler For My Current Results:
(TI-BASIC, TI-84+SE)
Currently, my program can find the following values in the following time:
42:prgmPALPREM , 23 seconds, returns 18181
100:prgmPALPREM , 88 seconds, returns 94049
290:prgmPALPREM , 682 seconds, returns 1958591

These are big improvements over previous versions:
42 : 44→40→30→27→23
100: 280→199→135→101→88
290: 4700→2256→1375→732→682

So it has been getting a lot faster for larger numbers, but it still takes 12.2 minutes to compute the 290th term XD I have only been modifying the prime testing routine each time, but maybe if I can make the palindrome generating routine faster, I can get better times o.o
EDIT: Updated stats with version 5

1008
Computer Projects and Ideas / Re: haroldbot (theorem prover / solver)
« on: April 05, 2013, 01:07:35 pm »
I tested it; I had fun. I just keep forgetting to use * and == even though I know I am supposed to :P

1009
Miscellaneous / Re: What Does Your Voice Sound Like? (New Collection)
« on: April 05, 2013, 09:52:41 am »
Yep, that's me :D I can make lots of different noises, but I like whistling noises the best :)

1010
Miscellaneous / Re: What Does Your Voice Sound Like? (New Collection)
« on: April 05, 2013, 08:56:01 am »
I made a new one, but it has the proper format, plus my awesome whistling skills :P (Except that I messed up on a few XD)

Also, some of those are clearly not bird whistles >.>

1011
Oh my gosh, this sounds fun o.o I probably won't have time, though, but if I do, I will try!


1012
TI Z80 / Digisibility Test (Z80 ASM)
« on: April 02, 2013, 01:03:50 pm »
Inspired by Round 2 of the 2013 TI-Concours BASIC category, I made this assembly program to test if a number is digisible. A number is digisible if every digit of the number divides the whole number evenly. Since you cannot divide by 0, every number with a 0 in it is automatically not digisible. So the input is a positive integer, and the output is text drawn to the screen where 0 =  not digisible, 1=digisible.

So here is what I was wondering: How fast or small can you make a program like this in assembly? My version takes a string input, so long as it fits in RAM and properly outputs a result. It is also 140 bytes on the calculator, so I am thinking it could be made a bit smaller XD (I think it is 122 bytes of code).

Hopefully I will remember to convert the code to readable source code, later. My approach is to keep track of which digits are in the sequence while finding the value of the string mod 2520 (every digit 1~9 divides 2520). Then, check to see if each present digit divides that value. At the same time, if any value appears that is not 1~9, it returns 0, so this takes care of non-integers and integers with a 0 in their digit expansion.

1013
Introduce Yourself! / Re: I just got done reading!
« on: April 01, 2013, 06:15:05 am »
That is always an awesome way to do it XD

1014
Introduce Yourself! / Re: I just got done reading!
« on: March 31, 2013, 02:11:05 pm »
Aha, nice! The way you used A for two purposes is clever. You can also use 'xor a' or 'sub a' as a clever way of setting A=0. It saves a byte, among other things.

1015
Introduce Yourself! / Re: I just got done reading!
« on: March 31, 2013, 01:26:21 pm »
hmm, one way  to clear plotSScreen uses the fact that it is 768 bytes, so you can do:
Code: [Select]
     ld hl,plotSScreen
     ld bc,768
Loop:
       ld (hl),0
       inc hl
       dec bc
;test if bc=0
       ld a,b
       or c
       jr nz,Loop
     ret
That is a routine that has a lot of optimising that can be done to it, but it might be easier to follow than some of the following.
Spoiler For Spoiler:
Code: [Select]
;alter the above code, saving 2300 t-states
     ld hl,plotSScreen
     ld bc,300h    ;300h = 768. So C=0, B=3
     ld a,c
Loop:
       ld (hl),a     ;1 byte, 7 cycles, compared to 'ld (hl),0' which is 2 bytes, 10 cycles
       inc hl
       dec bc
;test if bc=0
       ld a,b
       or c
       jr nz,Loop
     ret
Code: [Select]
;alter the above code to replace everything after 'inc hl'
;saves 7675 t-states, so 9975 t-states saved in all so far. Also a few bytes smaller.
     ld hl,plotSScreen
     ld bc,300h    ;300h = 768. So C=0, B=3
     ld a,c
Loop:
     ld (hl),a
     cpi            ;not using it for its inteaded use. Still, increments HL, decrements BC, checks if BC is 0
     jp pe,Loop
     ret
;25378 t-states, 14 bytes
Here is a different approach:
Code: [Select]
     ld hl,plotSScreen
     ld bc,3    ;768 = 300h, but here we load 3 into C, 0 in B
     sub a      ;set A=0, more optimised than 'ld a,0'
Loop:
       ld (hl),a
       inc hl
       djnz Loop
       dec c
       jr nz,Loop
     ret
;15 bytes, 19789 t-states
And probably the best method for speed and size:
Spoiler For Spoiler:
Code: [Select]
     ld hl,plotSScreen
     ld (hl),0
     ld de,plotSScreen+1
     ld bc,767
     ldir
     ret
;13 bytes, 16152 t-states

1016
Introduce Yourself! / Re: I just got done reading!
« on: March 31, 2013, 12:32:58 pm »
Wow, that looks pretty nice o.o I have very little knowledge in dithering stuff, but you will definitely find people here with assembly knowledge! So, what are you working on?

Also, welcome to Omni, here are some
!peanuts

1017
TI Z80 / Re: ORG: online Z80 IDE and assembler
« on: March 31, 2013, 11:26:40 am »
I am not sure if this is a problem that was introduced or something else, but when I compile the code and click 'download', I am redirected to http://clrhome.org/lib/404.php

The first time I did this, I lost my code (but I remembered it all, so I recovered it quickly).

EDIT: Actually, it seems to be doing the same for quite a few in-site links.

1018
Math and Science / Re: Tic-Tac-Toe algorithm
« on: March 30, 2013, 11:47:25 am »
I am not familiar with matlab, but does it allow for the following:
  • Vector Addition/Subtraction and indirection

-or-
  • Matrix row operations

I would assume it had some way to do these. I did a quick search and you could probably do something like this:

First, review the following matrix rows of the form [[D1,H1,H2,H3,V1,V2,V3,D2]]
[a]=[[1,1,0,0,1,0,0,0]]
[b]=[[0,1,0,0,0,1,0,0]]
[c]=[[0,1,0,0,0,0,1,1]]
[d]=[[0,0,1,0,1,0,0,0]]
[e]=[[1,0,1,0,0,1,0,1]]
[f]=[[0,0,1,0,0,0,1,0]]
[g]=[[0,0,0,1,1,0,0,1]]
[h]=[[0,0,0,1,0,1,0,0]]
[i]=[[1,0,0,1,0,0,1,0]]
Then in MatLab you will want to define your matrix like this (from what I saw):
Code: [Select]
A = [1,1,0,0,1,0,0,0; 0,1,0,0,0,1,0,0; 0,1,0,0,0,0,1,1; 0,0,1,0,1,0,0,0; 1,0,1,0,0,1,0,1; 0,0,1,0,0,0,1,0; 0,0,0,1,1,0,0,1; 0,0,0,1,0,1,0,0; 1,0,0,1,0,0,1,0; 0,0,0,0,0,0,0,0]
Notice that the last row is comprised of all zeros. This is the row holding all of the information about the moves taken in the game. From here, I cannot help much more (this is my first experience with MatLab), but from what I see, if the user selects a position a,b,c,d,e,f,g,h,i, that corresponds to rows 1,2,3,4,5,6,7,8,9 in the matrix. Where B is 1 or -1 depending on the turn (X or O) and C is the row:
Code: [Select]
A(10,:) = A(10,:) + B*A(C,:)
And you might want to do something like this to signify that the move has already been selected:
Code: [Select]
A(C,1) = .5
I have no clue if that works, but I was trying to set the first element in the row to .5. That way, you can just check if the first element is .5.

I have no clue what easy tricks or methods there are to test if an element in the last row is 2,-2, 3, or -3. In TI-BASIC, we can simply extract the last row as a list, then do something like '2=L1' and it returns a list of boolean values, 1 means the list element is 2, 0 means it wasn't. We could do sum(2=L1) and it will return 0 if no elements are 2, some other positive integer otherwise. I have no clue if anything like this can be done in MatLab, sorry :/

EDIT: Also, I would like to point out that you registered at 11:23:53. If that last digit was an 8, that would have been rather awesome o.o

1019
Other Calc-Related Projects and Ideas / Re: Compressing maps
« on: March 28, 2013, 10:57:33 am »
Another method that you might be interested in works like this:
Say you have 10 different tiles and numbers are stored with 14 digits of precision. You can then store each map layer with the nth digit in the number. To access the map in TI-BASIC code:
Code: [Select]
10fPart(10^-N[A]
If you aren't familiar with TI-BASIC, fPart( simply grabs the decimal part of a number (leaving off the integer part). If the language you are using doesn't have that, there is probably some equivalent to a floor() function (round down to the nearest integer) and you would essentially do #-floor(#).

If you have M different tiles, you can theoretically store up to floor(14/log(M)) different maps in a single matrix element, this way. However, I would go with 1 less than that to avoid precision problems. Your code for extracting a given matrix would be to replace the 10 in the above code with M.

I hope to see more ideas :D Encoding data with primes and properties of numbers can have some pretty interesting effects.


That's a very interesting method! There are only two small downsides it really has: one is being limited to a maximum of 10 features before it reduces your storage capability by half. But when you use two decimal places for each tile instead of 1 you can store as many as 100(!) different tiles, allowing you to store maps that are more artistic, while still reducing your storage by a factor of 6 (I take 12 decimal places as the limit just to make sure I don't go over it, otherwise the factor would be 7 (14/2)). The second is that this storage method is far less efficient when you use it with maps that don't need 10 different features, but even so it is more efficient than my method since it allows for up to 13 maps to be stored in a single matrix as opposed to my 12 maps which is only in the best-case-scenario of using only 1 terrain feature.

Hmmm... I think I might change the first post a bit to make this thread more of a discussion for different methods to compress maps, and perhaps even to simply 'compression methods' if the need to discuss compression for data other than maps arises.

If you use the method explained a little later, you can use a map with something like 5 features and get 20 maps in one matrix. With only 2 features, you can get 46 maps in one matrix because 14/log(2) is about 46.5. I used 10 as an example because it would be easier to think of each layer as a digit in base 10 instead of a digit in base M :P If you wanted to use up to 30 tiles, you could get floor(14/log(30))=9 maps.

But I did think of another way to get a few more maps, just now. Floating Point numbers usually have a separate bit to store whether it is negative or positive, so you actually probably have 2*1014-1 numbers to work with. That is how it works on the TI calculators, anyway (1014-1 negative numbers, 1014-1 positive numbers, and 0).



Ooh, I just had an idea for quickly checking (with your method). For example, a 4-feature map will use 2,3 for the first layer, 5,7 for the second, and so on. Then to check layer 1, simply use gcd() of the matrix element and 6. The second layer, use the matrix element and 35 and so on. Then you just check if the value is {1,2,3,6} or {1,5,7,35} et cetera, corresponding to the tile.


Another neat method for storing maps is to use dynamic tiles that change based on the tiles it is in contact with. For example, a trick I used in TI-BASIC for storing map data for a maze was to store to a picture (black and white) the map. When drawing a tile, it would test the corresponding pixel, then check above, below, and to either side to see precisely which tile was needed. In this way, you could store a tilemap using a single bit for each tile, using 16 tiles, which is a rather crazy level of compression. In normal circumstances, you need at least 4 bits for each tile if you have 16 tiles (2^4=16). When I took remade it in assembly, it compressed a 32*32 map (1024 tiles) to 128 bytes, using 16 unique tiles. In pure TI-BASIC I think the best compression I could get would be using a 19-element list (a little over 171 bytes).

Here is a screenshot of one of the many offshoots I made using this technique:

1020
TI Z80 / Re: ASMDREAM - the TI-8X+ on-calc assembler
« on: March 27, 2013, 01:39:09 pm »
Instead, i'll probably go for a new programming language.
I really like the idea of making it real-time.
But it's quite a challenge, since parsing & executing at the same time eats some cycles.
I'm curious to see how fast it can be (compared to ti-basic)...
Already, asmdream could be converted into a powerful language on its own. If you take out the compiling menu stuff and simply run through the source code throwing in bonus functions like for drawing, output/input, and loops, it doesn't matter if it is slower. It would still be a very powerful language with how versatile you have made macros.

Pages: 1 ... 66 67 [68] 69 70 ... 317