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 - 3rik

Pages: [1] 2 3 ... 8
1
TI-Nspire / Re: Scramble/Boggle Lua
« on: August 13, 2012, 12:20:03 am »
Errors happen much less frequently now that letterkeys is defined.

There are still a couple errors.
If I press, release, and then hold tab while I push a letter key, I get an error on line 228. dx is a nil value.
If I rapidly jam the tab button (or get unlucky every once in a while), there's an error on line 212. word is an empty string. This causes an arithmetic error because string.byte is returning nothing.
Holding tab doesn't work as well on the student software as on the handheld. This isn't a big concern.

This game is really coming along. Good work so far!  :)

2
TI-Nspire / Re: Scramble/Boggle Lua
« on: August 06, 2012, 09:15:52 pm »
I tried it out, but it kept giving errors around line 212. This is what the console says
Quote
212: attempt to index global 'letterkeys' (a nil value)
and
Quote
212: attempt to perform arithmetic on a nil value
It seems that letterkeys isn't defined anymore.

3
TI-Nspire / Re: Scramble/Boggle Lua
« on: August 04, 2012, 10:04:03 pm »
I'm glad you found a solution. It looks like there's less lag than I expected. A table probably takes up more memory than a string.

4
TI-Nspire / Re: Scramble/Boggle Lua
« on: July 27, 2012, 11:22:28 pm »
When I load the script with the pre-generated table, Lua is using ~20 MB of the 64 MB of operating memory. TI probably set the max level lower than full capacity. So, maybe the table by itself is just small enough to fit in under their max but when the rest of the program is running, Lua uses even more memory and that signals to Lua to throw an error.

I can attach the program I used to generate the table and you can experiment with shorter tables.

I was looking at the 12dicts wordlists. Here's a download link: http://downloads.sourceforge.net/wordlist/alt12dicts-4.zip.
They come with some symbols to catagorize some of them, but I just deleted them all. I just used the replace feature in Notepad++ and turned on regular expressions. I had it find
Quote
[^a-z]
and replace it with nothing.

I also had it replace
Quote
\r\n
with
Quote
","
and added the brackets to make it a table.

Then, I assigned the result to the variable "list" in the attached program and ran it using Lua (on the computer). It will write to (or overwrite) a file called pregendict.txt (in the current directory) with the code for the pre-generated table.

5
Lua / Re: Chipmunk Physics
« on: July 26, 2012, 04:36:17 pm »
Thanks for gathering these resources!  :)


space = pSpace(9.8)

got turned into

space = pSpace(9.8)

in your code.

6
TI-Nspire / Re: Scramble/Boggle Lua
« on: July 24, 2012, 10:35:36 pm »
Figures. The student software must allow for more memory to be used. One thing that could be done is generate the table before hand. It would be faster and there wouldn't be two lists of words. 100,000 words is a bit excessive, so a dictionary with less words would also work. I tried actually sending this to my nspire cx, so as long as the rest of the program isn't massive, this should work. There are 81536 words. I'll attach the file of the pre-generated table.

Edits:

It takes a little more than 20 seconds for my calculator to open the document with the script. Indexing the table, however, takes less than a millisecond.

Also, don't forget to assign this table to a variable.

I wouldn't say "shrunken." This dictionary is probably larger than an array with the words. It just indexes a lot faster than an array since most of the guess and check is avoided.

7
TI-Nspire / Re: Scramble/Boggle Lua
« on: July 24, 2012, 01:51:49 pm »
Wouldn't be surprised. Mine is actually just a laptop hooked up to a monitor. I think I was also running a bunch of other things when I first tried pasting into the student software.

8
TI-Nspire / Re: Scramble/Boggle Lua
« on: July 24, 2012, 12:56:52 pm »
Notepad++ took more like a whole second to paste everything (over 1,000,000 characters after all).  :P

Notepad++ is kind of the exception. It's a very lightweight program  :D. Bulky IDEs like the script editor in the student software tend to crash (or come very close) when I paste in the code, though. I don't even think the syntax highlighting can be turned off in the student software to avoid this issue.  :(
That's why I had to use the old scripting tools and Notepad++.

I clarified this in my previous post.

9
Lua / Re: Pool Nspire
« on: July 24, 2012, 12:21:33 am »
This seems really nice. I look forward to seeing how it turns out.  :)

10
TI-Nspire / Re: Scramble/Boggle Lua
« on: July 23, 2012, 10:57:29 pm »
I tested this way on the student software and it took about 3 seconds to load my list of ~100,000 words and convert it to the table. From there it was able to index any word very quickly (including long words like symptomatologically). The overall memory is a tad bulky (but there's only so much you can shrink 100,000 words). Each key, however, only points to a table containing, at most, 27 new keys.

A warning: don't paste tables like this into programs bulky IDEs with syntax highlighting. I pasted a table into the student software, walked away for an hour, came back and it was still trying to highlight everything. I eventually gave up and used the old scripting tools to test out the method.

I'll attach the code I tried with.

EDIT: I just realized that there are two lists in this program. There is still a table with all 100,000 words in it. I haven't sent this code to my calculator, so I'm not 100% sure that there won't be any memory issues.

EDIT2: I just realized, if one wanted definitions included with this structure, the values of the endofs (or _s) would just need to be changed from true to the definition. This wouldn't really apply to Boggle, but it could be used elsewhere.

EDIT3: loadstring is intended to be more for accepting code from the user. oclua is a good example of this. Tables and strings should be able to handle this problem without loadstring.

11
TI-Nspire / Re: Scramble/Boggle Lua
« on: July 23, 2012, 08:02:43 pm »
If the plan is to have large dictionaries, this might be useful.  :)

Code: [Select]
function editDictionary(dictionary, old_dict)
local data = old_dict or {}
for _, word in ipairs(dictionary) do
local curchar = data
for i = 1, #word do
local char = word:sub(i, i)
if not curchar[char] then
curchar[char] = {endof = i == #word and true or nil}
elseif not curchar[char].endof then
curchar[char].endof = i == #word and true or nil
end
curchar = curchar[char]
end
end
data.lookup = function(tbl, str)
local function lookup(str)
local curchar = data
for i = 1, #str do
curchar = curchar[str:sub(i, i)]
end
return curchar.endof
end
err, ret = pcall(lookup, str)
return err and ret or nil
end
return data
end

It takes a table like
Code: [Select]
list={"carbon","cars","car","cat","cats"}

and creates a table like
Code: [Select]
dictionary = {
c={
a={
r={
b={
o={
n={endof = true}
}
}
s={endof = true}
endof = true
}
t = {
s={endof = true}
endof = true
}
}
}
lookup = function(tbl, str)
--blah blah blah
end
}



lookup takes a string and rapidly returns a true or nil value based on if the word is in the list of acceptable words.

Here's an example:
Code: [Select]
dict = {"cat", "cats", "dog", "mouse"}

dictionary = editDictionary(dict)

print("d:", dictionary:lookup("d"))
print("do:", dictionary:lookup("do"))
print("dog:", dictionary:lookup("dog"))
print("dogs:", dictionary:lookup("dogs"))
print("dogz:", dictionary:lookup("dogz"))

amendment = {"dogs"}
dictionary = editDictionary(amendment, dictionary)
print("\nAmendment: dogs added!\n")

print("d:", dictionary:lookup("d"))
print("do:", dictionary:lookup("do"))
print("dog:", dictionary:lookup("dog"))
print("dogs:", dictionary:lookup("dogs"))
print("dogz:", dictionary:lookup("dogz"))

prints

Code: [Select]
d: nil
do: nil
dog: true
dogs: nil
dogz: nil

Amendment: dogs added!

d: nil
do: nil
dog: true
dogs: true
dogz: nil

What I like about this way is that it narrows the search down for each letter in the string instead of searching for the whole string in a giant table or string. It could be potentially bulky, though.

Worst case scenario, it could end up indexing something like dictionary.p.n.e.u.m.o.n.o.u.l.t.r.a.m.i.c.r.o.s.c.o.p.i.c.s.i.l.i.c.o.v.o.l.c.a.n.o.c.o.n.i.o.s.i.s.endof but most of that searching would be handled by Lua itself.

This is case sensitive, but if it makes a difference it would only take a simple metatable to fix.


EDIT: Reread the first post and testing a few things first

12
ROM Hacking and Console Homebrew / Re: Petit Computer
« on: July 23, 2012, 04:32:44 pm »
can you write programs on a computer and transfer them over?
You can write programs on the computer only with a certain fanmade application (which is japanese but also has an english version)

I think the program that does this is from here: http://micutil.com/ptcutilities/top_e.html.

It has a program editor, sprite and tile editors, and converts programs to QR codes (and vice versa).

13
Introduce Yourself! / Re: New user
« on: July 17, 2012, 03:37:27 pm »
Welcome! What brings you to Omnimaga? It seems like you have quite a bit of experience in assembly already. There's also a language called Axe that's pretty popular around here. Do you have any projects in mind?

Also, here's some more peanuts ;):
!peanuts

14
TI-Nspire / Re: Matrix Library
« on: July 16, 2012, 03:03:53 pm »
I think I'm okay for now. I'm sort of taking a crash course in linear algebra before I finish up the next version. I do have a lot of new things added, so I'll post what I have so far and update the first post.

15
TI-Nspire / Re: Matrix Library
« on: July 09, 2012, 01:44:08 am »
I fixed a few bugs, and changed all the asserts to errors so it's easier to find mistakes.

Pages: [1] 2 3 ... 8