My university results were released today - I got a 1st.
Hazaar!
I got .8 for my dissertation, and .96 for my favourite module of the whole degree: Understanding Programming Languages.
I enjoy functional programming and cookies.
My university results were released today - I got a 1st.
Hazaar!
I got .8 for my dissertation, and .96 for my favourite module of the whole degree: Understanding Programming Languages.
Approximately 12000 words on my dissertation so far! The cap is 15000 – I’m getting dangerously close. I should be able to reduce it a lot by swapping out code samples for images though. This would also make them easier to read as they will have syntax highlighting. Redoing my poster this weekend too.
Getting my game dev on!
This is the main menu so far. The six blocks are radio buttons for the six levels I should be making. In this screenshot, the last four levels are locked, as the player has only completed level 1 and unlocked level 2. The level selection works (and doesn’t for locked levels), and the play/quit buttons also work.
For game play, I worked out a cursor system using raycasting onto a plane which resides in it’s own layer, so that the ray doesn’t collide with anything else. Using this ray I take the hit point and store it for the player to shoot at – should they release the left mouse button.
If anyone wants to know more about my game, here is a link to my game proposal presentation: Presentation!
Changed my idea for my Game Dev module completely! Should be fun ^_^
It’s still a physics based puzzle platformer, but it’s more awesome than my previous idea!
Latest improvements:
Sub-expressions are now matched and swapped out if a reduction is made.
Conditionals evaluate with bindings correctly.
Executor forms also evaluate with bindings correctly.
I have a few abstract ideas about ensuring termination, but nothing properly explored yet.
As well as cycle capturing for termination, I also have to build an infix expression parser. For which, I am thinking about implementing a modified version of the shunting-yard algorithm. We’ll see how that goes.
I have a meeting with my project supervisor at 11am today. I’m wondering what he’ll say if I tell him I started from scratch two days ago and have already completed the core functionality. :D
Just have to write the recursive rule matcher and infix parser until my core functionality is complete!
Then I’ll go on to extend the reduction system to also destruct non list structures, so I can define rules as such:
(swap [a b]) = [b, a]
Or a more advanced example, defining a complete map function purely using rewriting rules.
(map x []) = [] (map x [f]) = [(x f)] (map x [f & rest]) = (conj (map x rest) (x f))
Which will be pretty awesome.
So far I have macros for building a rewriting system, defining a named rewriting system, rules processing, variable & constant definitions, and parser definition - without an infix parsing implementation.
This morning I have worked on my dissertation project.
I’ve built a very simple reduction mechanism which works as such:
Take a rule:
a * (b + c) = (a * b) + (a * c)
Have an expression:
x * (3 + (b / 2))
Apply the rule, and generate variable mappings if appropriate:
{ a : x
b : 3
c : (b / 2) }
Apply a the variable map with rule to get the reduced expression:
(x * 3) + (x * (b / 2))
I’ve the written the expressions here in infix but really they work as s-expressions. I’m building a parser to translate infix to s-expression to make my reduction system usable with expressions as they are usually written in mathematics (in infix).
I’m anticipating that the next difficult parts may be: reduction cycle detection and termination, the whole infix-parser, and the infix printer (if necessary).
I’m reading “The Joy of Clojure”, and it is wonderful. The following is what I learnt today:
Maps can be used as functions for value lookups:
({:a 3, :b 4} :a)
;-> 3
Keywords can also be used as function to look up map values:
(:b {:a 3, :b 4})
;-> 4
To split a string using regular expressions, use (.split reg string). Also that .split results in a Java array, so we need `vec to build a vector from it (if needed):
(vec (.split #"\s+" "Hello Bacon!")) ;->["Hello" "Bacon!"]
To capture matched patterns in strings, use (re-seq reg string).
(re-seq #"\w+" "Sick Bacon Manouevre")
;-> ("Sick" "Bacon" "Manouevre")
`re-seq can also capture groups:
(re-seq #"(\w)\w*" "Holy Bacon") ;->(["Holy" "H"] ["Bacon" "B"])
There are three methods of looking up a value in a vector. Each with their differences (I won’t go into them here).
(nth [:a :b :c] 1) ;-> :b (get [:a :b :c] 1) ;-> :b ([:a :b :c] 1) ;-> :b
`get-in and `assoc-in work like `get and `assoc, except they accept a vector of nested indicies:
(def matrix [[1 2 3] [4 5 6] [7 8 9]]) (get-in matrix [1 1]) ;-> 5 (assoc-in matrix [1 1] :new) ;-> [[1 2 3] [4 :new 6] [7 8 9]]
`update-in applies a function (potentially with arguments) to some value in a vector.
(update-in matrix [0 0] * 10) ;-> [[10 2 3] [4 5 6] [7 8 9]]
So far for my dissertation project, I have worked out how I’ll have the Term Reduction System defined and instances will store their settings. I started implementing the definition functions/macros to build a dummy TRS. It’s going very well! I also wrote a method of spliting up a reduction relation rule into it’s left-hand-side and right-hand-side.
On a different note, I found out I can clear the output in iTerm using Cmd+K, lovely.
Today I decided that I would once again learn to program. Currently I feel as though I haven’t really been programming for a while. At least not properly. Yes I did learn some Objective-C, and write an iOS game entitled Slidieo, which was published on the app store. But I realise that this is really ‘just’ coding. Programming isn’t coding, it’s more about the ideas, the methods, and style of the algorithms designed.
“Solve the problem, then write the code.”
Currently I see myself as an ‘okay’ programmer. Although taking into account that everyone seems to think (or at least say) I am a lot better than I seem to feel I am, and that I believe I have an ‘impostor syndrome’. Maybe I could daringly take up the label of a ‘good’ programmer.
As I say, I have decided to continue learning programming. I will now stop wasting valuable time watching anime. Replacing this with trying to learn as much as I can about different coding styles, learning interesting algorithms, and just generally practicing.
A few days ago I started learning some basic game programming in Java from some interesting/entertaining video tutorials from Bucky on YouTube!
I’m going to blitz through these tutorials, and build some very (very) basic games. Probably starting with something like Pong, then Space Invaders, Asteroids, Pacman, etc…
Why so basic games? I feel I need to progress into the mind-state for game programming. I believe one of the best ways to do this is to start with small/simple games, and build up from there!
Along-side this adventure into Java game programming, I will also delve into the world of GUI design (and coding)! As well as many other aspects of software development and other technologies. Some I will pick up from the software engineering course to which I am currently enrolled, the rest purely from interest!
I am finding it amazing how easy it is to not do anything particularly productive or even remotely interesting. From this observation I thought it wise to do something about it! So here I am writing about my development plans. I will continue posting about my progress here, including any projects I build. For some I may even submit a link to the final product and source code for anyone willing to learn from them, or just enjoy the program (if at all possible).
I will mainly focus on using Java as my coding outlet. Not because I like it (for sometimes I don’t - when it’s rather shit), but because my university course uses Java. I feel it would probably be most effective to stick to one main language initially. Then once I am happy I believe I am a ‘great’ programmer, I will then progress to more interesting languages. Maybe I’ll also do a little PHP, mySQL, and the standard client-side web development technologies too, just to keep up with it - for the sake of nostalgia.
I leave you with this, my first ever blog post, and this (unbelievably humorous) quote I found recently mentioning Java and anal sex…
“Saying Java is good because it works cross-platform, is like saying anal sex is good because it works cross-gender.”
Laters, Liam.
…Hey wow it’s 5:14 in the morning :D