Submissions from 2015-02-13 to 2015-02-14 (5 total)

So I finally sorted out the problem I've been working on for a few days.

Now when you select a unit it highlights all tiles that are within a set distance of the unit (currently hardcoded to 3). I'll add in a cost based on the tile type over the next few days. Also need to make the highlight list remove duplicates as you may notice some of the tiles are double highlighted in the screenshot.

I had given up on this earlier today after several hours but had another quick look at it for 10 mins and had one of those great "oh yeah!" moments and fixed it. Programming can be massively frustrating at times :p

Today I finished working on producing random events. Some minor bugs were also fixed and small improvements made. Currently, I'm working on research buttons - displaying corresponding price and image. Tomorrow should be too busy and I'm hoping to finish off until next update. :)

I also started reading a book about Machine Learning named "The Elements of Statistical Learning: Data Mining, Inference, and Prediction". Hopefully, it will be useful in one way or another.

Yesterday's update can be found here.
In a case of any questions or suggestions, don't hesitate to contact me here or on twitter. ;)
For more updates, you should follow my twitter account - @PeterLauris and the account of Crystal Kingdom - @CrystalKingdom_
.

Shay Howe's Learn to Code Advanced HTML & CSS has a pretty good guide on transition/animation properties. So last night I read through the first half and made something random on CodePen: link

Feel free to cheat to see what happens at the end!

setInterval(function() { document.querySelector('.button').click() }, 25)

Today I added strict typing to some functions and modified how 'compileCodeBlock' returns information. It can now tell me what variables were read from during execution, something which I plan to use to diff between selectors for optimizing the CSS output.

I now have the following working in javascript files to pull in others:

//= require <src>

Next up will be //= require_tree <path>

This also means that I finally figured out my named regexp's from yesterday. It basically boiled down to storing the results in a map. For example:

// Match ^//= require(_tree)? (.*)$
r, err := regexp.Compile(`^//=[[:blank:]]*require(?P<tree>_tree)?[[:blank:]]+(?P<argument>.*)$`)
if err != nil {
    return src, err
}

sm := r.FindStringSubmatch(string(line))
m := make(map[string]string)
if len(sm) > 0 {
    // Take each match and associate it with the named match
    for i, name := range r.SubexpNames() {
        // Don't include non-matches
        if sm[i] != "" {
            m[name] = sm[i]
        }
    }
}

In looking at it just now, I changed the first [[:blank:]] to be optional. Seems like that will give less "WTF?" moments when using it if a space is forgotten.