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.


Topics - Michael_Lee

Pages: [1] 2 3 4
1
TI Z80 / Axe Interpreter
« on: December 20, 2011, 02:33:19 pm »
Edit: Links to latest updates at bottom of post.

I was bored, so I tried making an implementation of Axe Parser in Python.  It currently only supports a very limited subset of Axe (only a few tokens, no pointers, strings, subroutines, HL madness, etc), but I thought this would be a good project to try this Christmas break.

It has both an interpreter mode, where you can type commands in on the fly, and a mode to execute from a text file.  It currently will not open 8xp files -- given the small number of tokens I support, it wouldn't even be useful at this point anyways.



This should be compatible with all major OSes, but was tested on Windows 7 and Linux Mint. 
No .exes, sorry -- you need Python 2.7 and Pygame.

To run the interpreter, type
Code: [Select]
$ python source/main.py --interpreter
To run a text file, type
Code: [Select]
$ python source/main.py myfile.txt
A full list of supported tokens and other miscellaneous details can be found in the readme.


Note: I'm not really fond of the name 'Axe Interpreter' -- can anybody think up a better one?



### EDIT -- Latest releases: ###

  • v0.3: http://ourl.ca/14554/301297
    Completely redone, now with grayscale and goto statements.  I also made a dodgeball game to demo.
  • v0.2: http://ourl.ca/14554/273474
    A bunch of new features: getKey, more pxl-commands, more math, rudimentary pointers, and more control structures.  I also made a tunnel game using the commands currently available.
  • v0.1: http://ourl.ca/14554/273054
    Slightly tweaked UI, exe only (windows and linux)
  • v0.0: [See attached]
    Initial release.  Source code only.

2
Math and Science / Equation to graph this
« on: December 08, 2011, 08:27:38 pm »
Ok, I feel really stupid for asking this, but what is the name and general form of an equation that would be like one graphed below?  The red line is the graph and the blue lines are two horizontal asymptotes. 

It almost sort of like an inverse tan, but I was wondering if there was another equation that would graph to something similar.

3
Math and Science / Math problem: odd digits and probability
« on: November 11, 2011, 01:36:48 pm »
I was doing a problem for a math competition
Quote
How many five digit integers satisfy the following:
- All the digits are odd
- The difference between adjacent digits is 2
An example of such a number is 13535 or 57979
...and wanted to generalize it to "How many answers satisfy the conditions for n-digits"?

For example, given one digit, there are 5 possibilities {1, 3, 5, 7, 9}...
and given two digits, there are 8 possibilities {13, 31, 35, 53, 57, 75, 79, 97},
etc.

I managed to figure out a solution that didn't involve drawing out ridiculously large probability trees to brute-force the answer, but I want to know if there's an algorithmic or better way to solve the problem. 

Here's my solution below (it's an exact copy of an email I sent to my teammates), but I don't really understand why my solution works. (spoiler'd for length).

Spoiler For Spoiler:

So, I was puttering around with Python, trying to find patterns in the problem,
and hit upon a method for finding the answer.  The only thing is, I have no clue how it works.
It's also kind of difficult to explain without using paper + pencil
(or whiteboard + marker, which is much cooler), but I gave it my best shot.

(If possible, view this email in a monospace font -- try copying and pasting into notepad)

* * *

In short,
If the answer has one digit, then there are 5 possibilities
1 + 1 + 1 + 1 + 1 = 5

If the answer has two digits, then there are 8 possibilities
1 + 2 + 2 + 2 + 1 = 8

If the answer has three digits, then there are 14 possibilities
2 + 3 + 4 + 3 + 2 = 14

Here are a bunch more possibilities:
1   1   1   1   1     = 5
1   2   2   2   1     = 8
2   3   4   3   2     = 14
3   6   6   6   3     = 24
6   9   12  9   6     = 42
9   18  18  18  9     = 72
18  27  36  27  18    = 126
27  54  54  54  27    = 216
54  81  108 81  54    = 378

If you notice, each number in the sequence is equal to the sum of numbers
that are to the left to the right on the row above it.

3  6  6  6  3
 \   /
6  9  12 9  6

(9 is the sum of 3 and 6, for example)

So basically, this is like Pascal's triangle, except it's more a rectangle with
some fiddly bits.

* * *

If you're wondering what the numbers represent, they equal the number of
possibilities each branch in the tree has or the count of the number in the
final branch of the tree (that didn't make sense, did it).

An example (for three digits):

   1          3          5          7          9
 .   3      1   5      3   7      5   9      7   ,
    1 5    . 3 3 7    1 5 5 9    3 7 7 .    5 9



Each layer represents the number of possibilities in the tree.
If there is only one digit, there's only
1 1 1 1 1 possibilities.

If there are two digits, there's
1 2 2 2 1
possibilities per branch.
However, there is exactly
1 one
2 threes
2 fives
2 sevens
and 1 nine
given two digits.

If there are three digits, there are
2 3 4 3 2
possibilities per branch.
However, there's
1 one
3 threes
4 fives
3 sevens
and 1 nine in that layer.

* * *

Isn't this weird?


-- Michael.




4
TI Z80 / Axe Syntax Highlighting (for Gedit)
« on: October 02, 2011, 02:32:08 am »
I was poking around, and I didn't really see anything that had syntax highlighting for Axe, so I made one for Gedit for fun.  This isn't really anything spectacular, but it was a good excuse for me to practice my regex skills ;D

Add the file to the appropriate directory, and if your text file ends in .axe or if you select 'Axe Parser' from the Menubar ([View] -> [Highlight Mode] -> [Sources]), the syntax highlighting should kick in.  The colors you get should depend on what theme you currently have.

I believe this should support TokensIDE-style syntax (although it's been a long time since I've looked at TokensIDE, so I don't know how well this actually complies).


For Linux, just copy axe.lang to '~/.local/share/gtksourceview-3.0/language-specs' (or '~/.local/share/gtksourceview-2.0/language-specs').

Windows is apparently 'C:\Program Files\gedit\share\gtksourceview-2.0\language-specs\' or 'C:\Program Files\gedit\share\gtksourceview-3.0\language-specs\' (althought I can't confirm).

I don't know about Macs, sorry.


Props go to Deep Thought for inspiring me to write this.

5
Site Feedback and Questions / MOVED: chat does not work in ie
« on: September 30, 2011, 05:49:18 pm »

6
Miscellaneous / Tutoring others
« on: September 27, 2011, 02:01:36 pm »
I'm due to start my first real job (Hooray!) this Wednesday: I'm going to be tutoring another student in math.

I was wondering if there were any tips/tricks/things to keep in mind while tutoring?

7
Web Programming and Design / Temporary downloadable files -- best practice?
« on: September 16, 2011, 07:43:41 pm »
I'm taking user input (in a text box or whatever), and trying to make a file the user can then download.  What is the best way of managing the newly created files?

Should I assign them a unique name, based on a hash or something?  Or is there a way to preserve filenames without risking accidental name collision?

I really don't want a bunch of files to be created and slowly take up a huge amount of memory -- what's the best way of managing and purging temporary downloadable files?

(I'm trying to make something based of off Javascript and Python).

8
Miscellaneous / Lowered participation
« on: September 08, 2011, 09:07:16 pm »
Hey everybody.

Although I've been making an attempt to contribute more to Omnimaga, I've really been slowly fading away since pretty much spring this year, and now that I'm starting junior year in high school and trying to juggle a whole bunch of things (I finally got a part-time job ;D), I'm afraid that my participation in Omnimaga will grow even less.

I'm not leaving for good, and I definitely will continue to work on my projects and even attempt to start mini-ones from time to time, but I really doubt I'll have time to do anything major.

Just a head's up.


On a slightly related note, does anybody have strategies for dealing with packed schedules?  I have a whole bunch of stuff to do, and I'd really like to make everything I do as efficient as possible so that I actually have some free time to do stuff that I like.

9
Other / Lego Mindstorms
« on: September 06, 2011, 01:56:04 pm »
My local robotics club thought it would be cool (well, I thought it would be cool, and pushed the idea) to buy several sets of Lego Mindstorms (or something similar) so that newcomers could gain some experience playing and building stuff with them.

I'm currently in the process of researching what kind of kit would be best, but because I'm really new to this, I wanted to get some suggestions on what we should look into purchasing, and if there are any better alternatives to Lego Mindstorms.  Ideally, it should be a fairly versatile and large kit so we aren't limited to building only a few things, and needs to be programmable.

Suggestions?  ;D

10
Miscellaneous / MOVED: Hello
« on: May 18, 2011, 03:48:57 pm »
This topic has been moved to Introduce Yourself!.

http://ourl.ca/11075

11
TI Z80 / Contest Entry: Clones
« on: May 17, 2011, 03:06:52 pm »
Well, I've started a project I'm tenatively naming 'Clones.'

Basically, you are a blob with the ability to clone yourself, and switch between controlling any of your clones.

I'm probably going to focus on the puzzle-solving aspect of this.

12
The Axe Parser Project / MOVED: Help with Mario game
« on: May 09, 2011, 11:25:38 am »
Help for Axe programming should go in the Axe Programming sub-forum.

Therefore, this topic has been moved to Axe Language.

http://ourl.ca/10867

13
Web Programming and Design / Input: Website for Robotics Club
« on: May 04, 2011, 07:43:17 pm »
I've been helping make a website for the robotics club at my school.

It's still in the development stage, and has A LOT of work left to do (we need to actually buy a web domain, for example), but I wanted to get feedback on the design before it gets finalized.

Temporarily hosted at:
http://www.robotics1.multiscale.co.cc


Hosted at
http://spartabots.co.cc

(The background is temporary, it'll be replaced later, we don't have much content, some pages don't exist yet, and we still don't have a banner to put at the top of the page.)

I'm basically looking for feedback, criticisms, and suggestions on what I should do to improve the design.

14
It just occurred to me that this is the wrong thread: questions about Axe belong in the Axe language subforum.

Therefore, this topic has been moved to Axe Language.

http://ourl.ca/10702

15
The Axe Parser Project / MOVED: Sprite Collision Detection
« on: May 04, 2011, 07:32:44 pm »
It just occurred to me that this is the wrong thread: questions about Axe belong in the Axe language subforum.

Therefore, this topic has been moved to Axe Language.

http://ourl.ca/10745

Pages: [1] 2 3 4