Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it,
follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given
their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!
SELECT * FROM posts WHERE tid = 'PA PROGRAMMING THREAD'
Posts
I doubt it's anything to write home about since Erlang is designed for general distributed systems rather than Matlab-style numerical computations. And I guess that's my problem with Julia. When I first read about it, it seemed like another language that's a wishlist of features without a clear purpose. But that's my general complaint about a lot of languages that come out nowadays.
I think this is a result of people writing languages because they get upset with the limitations of what's out there and think "I can do better". I guess the better approach is to say "I want a language for X" and then build a language that is really good at that?
Not to be elitist, but it's what you said and also the fact that most of them aren't PL people. So the language isn't built on solid foundations which becomes apparent in its one-off blemishes and lack of focus.
I'm doing SSIS for the first time, and I'm not sure how to make it do the things I would in a full on application or a stored procedure. Does anyone know the best way to get foreign keys (from dimension tables) that match records being imported into a fact table?
E.g. what's the SSIS GUI's equivalent for this?
Invite me: XBox Live | PS3 | Steam
Link to me: Number Sorter | Achievement Generator
What tricks did he show you?
My original programming assignment was going to use string arrays, and array lists of string arrays. At this thread's suggestion, I swapped it for enums. He showed me how to do iterative for loops with the enums (I know about iterative for loops, but didn't know I could get it to do an iterative loop on all the values contained within enums) so that making a non-binary tree according to all the values in each enum I made was automated. It went from a mangled recursive DFS to a really nice, recursive BFS. I saved my DFSing for displaying the tree properly.
The correct response. What's his preferred color scheme?
Looks like the standard Netbeans color scheme.
A private array with a fixed number of elements.
A getter and a setter.
The getter accepts as an argument which element of the array you want and returns with a switch clause(whatever).
The first element of the array is initialized to a value and the rest are set to bullocks.
The only place where the second array element is initialized is if you call the getter with it as parameter.
The only place where the getter is called with 2nd el as parameter is if you call it with the third el as a parameter.
Tell me how chain setting like this is a valid design pattern and convince me there aren't at least 5 better ways to achieve the same goal.
Winner gets my unconditional love.
Frankly, if you want to initialize in your getters with your pubic setters, I'll read your shit and move on.
The fact that the second element is de facto initialized only from the getter of the thrid one bugged me out of proportion though. I want to see if I'm missing something obvious.
If the array is just acting as a cache to save computational work, then this sounds like a standard memoizing approach to mathematical sequences like Fibonacci or factorials, where you have to calculate for state N-1 before you can get state N.
I don't have the ANTLR BNF handy, but I'll toss up a code sample of what it looks like. I learned more about ANTLR and LL* parsers this weekend than I probably ever wanted to know.
function Add (a, b) return a + b end var _someScriptWideValue state Normal var _someStateWideValue message ReceiveDamage _someStateWideValue = Message.DamageValue _someScriptWideValue = true var someArray = ${ 1, 2, 3, 4 } var someHash = #{ "Key1" : 1, "Key2" : 2 } if _someStateWideValue > 0 then self.CastSpell(Spells.Heal, self) end end endIt's sort of Ruby-basic-javascript-lite-esque. The syntax itself is actually very flexible. For instance, 'then' after an if is optional. And and Or boolean expressios can be expressed using they keywords 'and' and 'or', or the symbols '&&' and '||', respectively. Null can be expressed using 'null', 'nothing' or 'nil'. Just a super easy, flexible syntax. There are no OO definition constructs (no class), and no functional programming stuff (no lambdas or yield blocks). Trying to keep the language crazy simple for non-programmers, so I am erring almost completely to the side of "basic as possible, flexible syntax, does what is expected 90% of the time".
So far all I have is the basic parsing structure, which outputs an AST, and the beginnings of static analysis of that AST (to catch errors that aren't parse related, such as unreachable code). I've also started on the code generation step, which I think is very cool. I am piggy backing completely on System.Linq.Expressions, which has facilities to express complete programming expressions in code. See http://msdn.microsoft.com/en-us/library/bb155837.aspx. The resulting code is JIT'ed when you call 'Compile' on the final expression, and runs at .NET native speeds.
I find this much much suitable to my problem space than trying to force Lua on the problem. As awesome as Lua is, it's still written for real programmers, and has some constructs that make it less than ideal for a tightly controlled DSL.
honestly, it doesn't look bad, but you really, really, really shouldn't be writing your own languages for something like this. ECMAScript is fine, hell make it ruby scriptable... just don't use your own shit. there's no gain to be had there. while my compiler course was fun, i have no desire to whack my hand with that hammer, and prefer to just use somethign out there that already works.
Joe's Stream.
you know... i took a quick look, and it appears, that no, you're boned.
Joe's Stream.
It appears. I figured that maybe it was plain text... nope.
Apparently .numbers files are hex based... plain text files. Yeah.
It's the basis of what a DSL is all about.
That setup is pretty much like the ZZT "OO" scripting I linked. Labels (states), messages, a script attached to an object (?). Not sure on that last one but it looks like it.
That is much more noob friendly than ECMAScript.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
Function attached to an object. 'self' is basically the object the script you see is attached to. Since this will always be a "character" object, it will have a CastSpell function, most likely defined native side. There are no OO definition constructs like classes, but there is still basic dot notation for object access.
Yep, that is precisely the "OO"-ness of the scripting I refer to.
It makes all the management of OO go away. Just create a game object, attach code.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
If an AI script fails to compile or run, the game will silently fall back on the default UI script (which will be written in this, and visible to the user, though read-only) so that users can never "break" their party. It will also contain a combat simulator to test your scripts.
If you don't mind assistance on the scripting part, it's something of the game I could focus on and probably help with. Know a good bit about em and it wouldn't take up all my time heh.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
MonoTouch.
I might take you up on that at some point. I'll be open sourcing a lot of this (basically everything but my game data).
Other work kicked my ass, so I am finally getting back around to this.
My thinking was that users don't have to sign in/out - they just go to the site, pick a major, click the courses they took, and they're done. Creating a whole account structure, sign in/out, seemed like a lot of work for little gain. I wasn't sure how to make Rails remember "okay, they clicked this on the last page, now take them here and remember that"
Well, what's the use case here?
If a user is going to come to your site once, click through once and be done, you don't need to be saving anything anywhere. All of your relevant data can be passed via URL parameters. If a user clicks on major with id 3 they'll go to /majors/3 and do everything from there.
If a user is going to expect to be able to come back later and find their data in the same state they left it, you need something harder than sessions.
grammar Bliss; options { language=CSharp3; output=AST; ASTLabelType=CommonTree; backtrack=true; k=3; } // AST tokens tokens { SCRIPT; PARAMS; BLOCK; BLOCKVARIABLES; EMPTY; CONDITIONAL; DECLARATION; NESTED; ID; EQUAL; NOTEQUAL; AND; OR; NOT; ASSIGN; STATE; FUNCTION; MESSAGE; ENTER; EXIT; UPDATE; RETURN; IF; ELSEIF; ELSE; FOR; WHILE; DO; VAR; CALL; ARGS; INDEX; TRUE; FALSE; NULL; DOT; STRINGLIT; INTLIT; FLOATLIT; ADD; SUB; MULT; DIV; MOD; LESS; GREATER; LEQUAL; GEQUAL; ADDASSIGN; SUBASSIGN; MULTASSIGN; DIVASSIGN; MODASSIGN; INC; DEC; ARRAY; HASH; HASHPAIR; } @header { using System; } @lexer::members { const int HIDDEN = Hidden; } // Work around a bug in the CSharp3 target @lexer::namespace { Bliss.Script } @parser::namespace { Bliss.Script } @parser::members { private int _scopeDepth = 0; } public script : scriptDecl eol? -> ^(SCRIPT scriptDecl) ; scriptDecl : ((blockVariableDefinition | functionDecl | stateDecl) { if(_scopeDepth != 0) { if (state.backtracking>0) {state.failed=true; return retval;} MismatchedSetException mse = new MismatchedSetException(null,input); DebugRecognitionException(mse); throw mse; } })+ ; functionDecl @init { bool hasParams = false; } : 'function' identifier ('(' functionParams { hasParams = true; } ')')? block end -> { !hasParams }? ^(FUNCTION identifier PARAMS block) -> ^(FUNCTION identifier functionParams block) ; stateDecl : 'state' identifier stateBlock { _scopeDepth++; } end -> ^(STATE identifier stateBlock) ; functionParams : (identifier (',' identifier)*)? -> ^(PARAMS identifier*) ; block @init { int count = 0; _scopeDepth++; } : (eol statement { count++; } ((eol | ',') statement { count++; })*)? eol? -> { count > 0 }? ^(BLOCK statement*) -> ^(BLOCK EMPTY) ; stateBlock : (eol? stateBlockPart)* -> ^(BLOCK stateBlockPart*) ; stateBlockPart : blockVariableDefinition | messageBlock | enterBlock | exitBlock | updateBlock ; messageBlock : 'message' identifier block end -> ^(MESSAGE identifier block) ; enterBlock : 'enter' block end -> ^(ENTER block) ; exitBlock : 'exit' block end -> ^(EXIT block) ; updateBlock : 'update' block end -> ^(UPDATE block) ; statement : expression | variableDeclaration | ifStatement | forStatement | whileStatement | returnStatement ; variableDeclaration : 'var' identifier -> ^(DECLARATION identifier) ; blockVariableDefinition : 'var' blockAssignmentExpression (',' eol? blockAssignmentExpression)* eol -> ^(BLOCKVARIABLES blockAssignmentExpression*) ; blockAssignmentExpression @init { bool hasAssignment = false; } : identifier ('=' expression { hasAssignment = true; })? -> { hasAssignment }? ^(ASSIGN identifier expression) -> identifier ; ifStatement : ifBlock elseIfBlock* elseBlock? endNibble -> ^(CONDITIONAL ifBlock elseIfBlock* elseBlock?) ; ifBlock : 'if' expression 'then'? block -> ^(IF expression block) ; elseIfBlock : 'elseif' expression 'then'? block -> ^(ELSEIF expression block) ; elseBlock : 'else' block -> ^(ELSE block) ; forStatement : 'for' a=expression ',' c=expression ',' l=expression 'do'? block endNibble -> ^(FOR $a $c $l block) ; whileStatement : 'while' expression 'do'? block endNibble -> ^(WHILE expression block) ; returnStatement : 'return' expression? -> ^(RETURN expression?) ; expression : assignmentExpression ; assignmentExpression : assignmentLeft '=' orExpression -> ^(ASSIGN assignmentLeft orExpression) | orExpression ; assignmentLeft : variableDeclaration | unaryExpression ; orExpression : (andExpression -> andExpression) (or a=andExpression -> ^(OR $orExpression $a))* ; andExpression : (equalityExpression -> equalityExpression) (and e=equalityExpression -> ^(AND $andExpression $e))* ; equalityExpression : (relationalExpression -> relationalExpression) (equality r=relationalExpression -> ^(equality $equalityExpression $r))* ; relationalExpression : (additiveExpression -> additiveExpression) (relation a=additiveExpression -> ^(relation $relationalExpression $a))* ; additiveExpression : (multiplicativeExpression -> multiplicativeExpression) (additive m=multiplicativeExpression -> ^(additive $additiveExpression $m))* ; multiplicativeExpression : (unaryExpression -> unaryExpression) (multiplicative u=unaryExpression -> ^(multiplicative $multiplicativeExpression $u))* ; argumentList : (expression (',' expression)*)? -> ^(ARGS expression*) ; unaryExpression : postfixExpression | not primaryExpression -> ^(NOT primaryExpression) ; primaryExpression : identifier | arrayExpression | hashExpression | '(' expression ')' -> ^(NESTED expression) | constant ; arrayExpression : '${' eol? (expression (',' eol? expression)*)? eol? '}' -> ^(ARRAY expression*) ; hashExpression : '#{' eol? (hashPair (',' eol? hashPair)*)? eol? '}' -> ^(HASH hashPair*) ; hashPair : constant ':' expression -> ^(HASHPAIR constant expression) ; postfixExpression : (primaryExpression -> primaryExpression) ( '(' args=argumentList ')' -> ^(CALL $postfixExpression $args) | '[' e=expression ']' -> ^(INDEX $postfixExpression $e) | '.' p=primaryExpression -> ^(DOT $postfixExpression $p) )* ; booleanLiteral : 'true' -> TRUE | 'false' -> FALSE ; nullLiteral : ('nothing' | 'nil' | 'null') -> NULL ; stringLiteral : STRING -> ^(STRINGLIT STRING) ; intLiteral : INT -> ^(INTLIT INT) ; floatLiteral : FLOAT -> ^(FLOATLIT FLOAT) ; constant : booleanLiteral | nullLiteral | stringLiteral | intLiteral | floatLiteral ; not : 'not' | '!' ; and : 'and' | '&&' ; or : 'or' | '||' ; end : 'end'! eol? { _scopeDepth--; } ; endNibble : 'end'! { _scopeDepth--; } ; equality : '==' -> EQUAL | '!=' -> NOTEQUAL ; relation : '<' -> LESS | '>' -> GREATER | '<=' -> LEQUAL | '>=' -> GEQUAL ; additive : '+' -> ADD | '-' -> SUB | '+=' -> ADDASSIGN | '-=' -> SUBASSIGN ; multiplicative : '*' -> MULT | '/' -> DIV | '%' -> MOD | '*=' -> MULTASSIGN | '/=' -> DIVASSIGN | '%=' -> MODASSIGN ; eol : (EOL!)+ ; identifier : IDENTIFIER -> ^(ID IDENTIFIER) ; WHILEKW : 'while'; IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ; WS : (' ' | '\t' | '\u000C')+ {$channel=HIDDEN;} ; INT : '0'..'9'+ ; FLOAT : ('0'..'9')+ '.' ('0'..'9')* EXPONENT? | '.' ('0'..'9')+ EXPONENT? | ('0'..'9')+ EXPONENT ; COMMENT : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;} ; STRING : '"' ( ESC_SEQ | ~('\\'|'"') )* '"' ; EOL : '\n' | '\r' ; fragment EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ; fragment HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ; fragment ESC_SEQ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | UNICODE_ESC | OCTAL_ESC ; fragment OCTAL_ESC : '\\' ('0'..'3') ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ; fragment UNICODE_ESC : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT ;This is a combined grammar, so the lexer and parser rules are in the same file. Anything with a name LIKE_THIS is a lexer rule. Name's likeThis are parser rules. Because of the way I do my grammar -> AST conversion, this is a very parser heavy grammar. The lexer does very little besides identify some lexer level constructs like strings and identifiers.
In individual rules, everything to the right of the -> is the transform or rewrite grammar, and is basically what will appear in my AST for a successfully parsed fragment. Rewrite rules in ANTLR can be used for some really cool text transform stuff, using output=StringTemplate, but I am doing AST, so my output is an AST based on ANTLR's CommonTree. Essentially ANTLR takes my grammar and transforms it in to a machine process-able AST. That gets me to the point where I know there are no grammar errors. I then statically analyze and generate code from that AST. ANTLR actually has something called "tree grammars", where you can do all that static analysis and code generation in their BNF language, but that seemed way out of scope for the parser for me. I'd rather keep that code in hand-rolled C# and keep the ANTLR stuff specifically to lexing/parsing. The only block of static analysis you'll see in there is the scope depth check, and that's because I don't pass END on to the AST, so it would be harder to check in static analysis. Not impossible, just harder. So it's easiest to do simple scope depth checking at the parser level in this case.
The BNF is not 100% complete. I am still missing inc/dec postfix operators, and there may be some gaps in the expression coverage I haven't fixed yet...but it's mostly a working language spec.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
If I were to go the lexer token route, it's likely I'd split the grammar in to separate lexer and parser files.
alright, out of sheer coincidence, i've written the master schedule builder for the most widely used school admin software in the US. no, it's not exaggeration.
what exactly are you trying to build? Student schedules? A "Master Schedule" in order to optimally place classes so that the most amount of student's get their selected classes? Both? Master schedule and student schedules?
If you have a master schedule, a brute-force approach is what i've found most effective for student placement (spanning tree type searches, but be sure to set a reasonable dive limit). If you're trying to build a master schedule, the phrase "partially colored weighted graph" should already be a known animal to you, or you are in for an education that you probably weren't expecting.
Joe's Stream.
I was going to post a question about database stuff, but I realized my problem! Variable names are important, kids.