Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411669 Posts in 69397 Topics- by 58452 Members - Latest Member: homina

May 16, 2024, 11:22:38 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The happy programmer room
Pages: 1 ... 242 243 [244] 245 246 ... 279
Print
Author Topic: The happy programmer room  (Read 680056 times)
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #4860 on: July 18, 2017, 04:32:20 PM »

For an actual product, probably Game Maker Studio 2

But I do want to learn more about low level programming, and a sandboxed VM that everyone will probably use sounds like the perfect place to learn. I'd program directly in bytecode just to learn how to do things with it. I wouldn't make an actual full game that way though. That'd be too much work.
Logged

JWki
Level 4
****


View Profile
« Reply #4861 on: July 19, 2017, 06:56:04 AM »

Wrote a JSON parser as a simple enough challenge to test out my understanding of context-free grammars and making a lexer and parser according to the rules of the grammar that I wrote based on the JSON spec. It's so much easier to parse something once the grammar has already been outlined with such notation. Now maybe in the future I have a chance of successfully writing a parser/compiler for a programming language without too many headaches, should I feel like it! Hand Thumbs Up Right

Did you write it as a recursive descent parser?
Logged
oahda
Level 10
*****



View Profile
« Reply #4862 on: July 19, 2017, 07:31:29 AM »

Tried to read up on that, but I don't think I understood the description entirely. I interweaved the lexer and parser so that a new token is only lexed when the parser needs one, instead of lexing all the tokens first and then parsing them afterwards, so that I can break immediately when there is an ungrammatical sequence of tokens. And there is recursion, if that has anything to do with it. Tongue
« Last Edit: July 19, 2017, 07:38:33 AM by Prinsessa » Logged

JWki
Level 4
****


View Profile
« Reply #4863 on: July 19, 2017, 09:21:10 AM »

Tried to read up on that, but I don't think I understood the description entirely. I interweaved the lexer and parser so that a new token is only lexed when the parser needs one, instead of lexing all the tokens first and then parsing them afterwards, so that I can break immediately when there is an ungrammatical sequence of tokens. And there is recursion, if that has anything to do with it. Tongue

A recursive descent parser essentially means that there's a procedure for each rule in the grammar - or for each node in the AST, if you generate one - and you recursively move into these procedures as you parse the token stream.

This is versus a state based parser where you maintain a DSA of sorts (or multiple even) to implement your grammar.

So let's say we have this input:

Code:
if(true) { return ; }

and lex it with this token stream as a result:

Code:
{IF}, {PAREN_LEFT}, {TRUE}, {PAREN_RIGHT}, {BRACKET_LEFT}, {RETURN}, {SEMICOLON}, {BRACKET_RIGHT}

And we have the rule

CONDITIONAL = IF PAREN_LEFT (EXPRESSION) PAREN_RIGHT BRACKET_LEFT BLOCK BRACKET_RIGHT

with EXPRESSION and BLOCK being defined in some meaningful way that we don't care about rn, then this would match a function

Code:
void ParseConditionalStatement(TokenStream tokens)
{
   // We entered this function because we have parsed an IF token, so the next token should be PAREN_LEFT
   if(!RequireToken(tokens, PAREN_LEFT)) { Fail("Expected ("); }
   tokens.EatToken;
   
   ParseExpression(tokens);    // In this function, we will use the rules for EXPRESSION

   if(!RequireToken(tokens, PAREN_RIGHT)) { Fail("Expected )"; }
   if(!RequireToken(tokens, BRACKET_LEFT)) { Fail("Expected {"); }
   
   ParseStatement(tokens);     // STATEMENT is probably our top-level rule

   if(!RequireToken(tokens, BRACKET_RIGHT)) { Fail("Expected }"); }

}

In a DSA based parser, you would maintain the rules as "states" that you're in and that you can data drive by definining generic states and transitions as pairs of states. So a recursive descent parser is "hardcoded" (unless you use code generation to generate it like Flex), but it's more straightforward to write and debug and you're probably doing something like this already as you say recursion is involved.
Logged
oahda
Level 10
*****



View Profile
« Reply #4864 on: July 19, 2017, 09:32:46 AM »

Ah, yes, exactly. Maybe I have stumbled across the term sometime in my reading but then forgotten. That's why I wrote the grammar in the first place. Then I essentially converted the grammar into code, just like you described. Then my "AST" is really just the JSON object itself, as there wasn't really any need to go through the extra step, considering it's just a data format and not an actual language—but I'd definitely use one if it were! DSA I'm not familiar with.
Logged

JWki
Level 4
****


View Profile
« Reply #4865 on: July 19, 2017, 09:54:59 AM »

Ah, yes, exactly. Maybe I have stumbled across the term sometime in my reading but then forgotten. That's why I wrote the grammar in the first place. Then I essentially converted the grammar into code, just like you described. Then my "AST" is really just the JSON object itself, as there wasn't really any need to go through the extra step, considering it's just a data format and not an actual language—but I'd definitely use one if it were! DSA I'm not familiar with.

My bad, DSA stands for Deterministic State Automaton, so a deterministic state machine.

Logged
Ordnas
Level 10
*****



View Profile WWW
« Reply #4866 on: July 19, 2017, 09:57:04 AM »



Recently achieved a major milestone in a project I've been working on. Quite satisfying to get there as I've been working toward it for a while.

http://www.entropicsoftware.com/aie/sat/overview.html

Garthy, my compliments for the Satellite Chocolate Board!

Thanks for checking it out and for the kind words. Smiley

It's something I'm quite proud of as a combined electronics/software project. I'm a software engineer by profession but I've picked up a bit of electronics recently.

There were two parts to the milestone:

- The electronics side: Fully build the first prototype and make it work.
 
- The software side: Two things: (i) be able to write simple code that shows off the various components of the board; and (ii) get the supporting software to the point where you can write a led blinker (essentially "hello world" for electronics) and get it running on the board in under a minute.

And then write it all up and demonstrate it. I've been working toward this point for a while, and I finally made it. SmileySmileySmiley

ARM microcontrollers can be a bit tricky to use, so one of my goals was to come up with a library/system that would make it much easier to work with.

The led blinker might not sound like much, but it involves working with an ARM microcontroller and a Max V CPLD, both of which are very powerful but can be hard to use. The idea was to make it easy to use when using the library.

Video demo of the one-minute led blinker here:

http://www.entropicsoftware.com/aie/sat/one-minute-led-blinker.html

The other pages have demos of the rest of the board. Best starting point is here:

http://www.entropicsoftware.com/aie/sat/overview.html

I like the "Use the temperature sensor to turn on/off an infrared-controlled airconditioner.", during the summer it could be very helpful!  Grin

Thanks. One piece of feedback I've received for the overview page was to list some possible projects that it could be used for. Since it's a general-purpose board it can be a little unclear as to the sorts of things that are possible. As in, how general is general-purpose?

Now all I need is an infrared-controlled airconditioner. Wink


From the video, it seems really easy to write and build a program + flashing on it!

I was always a bit attracted by electronics, this post just gave me more desire to start!
Logged

Games:

Ordnas
Level 10
*****



View Profile WWW
« Reply #4867 on: July 19, 2017, 10:07:17 AM »

Wrote a JSON parser as a simple enough challenge to test out my understanding of context-free grammars and making a lexer and parser according to the rules of the grammar that I wrote based on the JSON spec. It's so much easier to parse something once the grammar has already been outlined with such notation. Now maybe in the future I have a chance of successfully writing a parser/compiler for a programming language without too many headaches, should I feel like it! Hand Thumbs Up Right

I think is really hard to write a parser/compiler, but is something that, someday, I will try to do. Do you have any suggestion about why someone should learn about Chomsky languages and if are there any advantages in learning from it?
Logged

Games:

oahda
Level 10
*****



View Profile
« Reply #4868 on: July 19, 2017, 10:31:09 AM »

Wrote a JSON parser as a simple enough challenge to test out my understanding of context-free grammars and making a lexer and parser according to the rules of the grammar that I wrote based on the JSON spec. It's so much easier to parse something once the grammar has already been outlined with such notation. Now maybe in the future I have a chance of successfully writing a parser/compiler for a programming language without too many headaches, should I feel like it! Hand Thumbs Up Right

I think is really hard to write a parser/compiler, but is something that, someday, I will try to do. Do you have any suggestion about why someone should learn about Chomsky languages and if are there any advantages in learning from it?
Here's a nice resource to start from: https://ruslanspivak.com/lsbasi-part1/

If you're referring to the Chomsky hierarchy and one of the types, the context-free grammar, which is what I used, then at least for me it makes it a lot easier. With a fairly compact notation you outline everything that goes into the language and the syntax it must follow, which gives you a complete overview, and then you basically just translate everything to code the way JWKi outlined above and it almost writes itself. I've tried throwing myself into writing parsers before without this knowledge and without doing this step, and it's been a lot messier. And if you use EBNF notation, there is actually software out there that just reads in your grammar and spits out a working parser! Hand Thumbs Up Right
Logged

Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #4869 on: July 19, 2017, 02:57:53 PM »

From the video, it seems really easy to write and build a program + flashing on it!

Thankyou. Smiley Making the process nice and easy was my goal. Smiley

This is one thing I really enjoy doing with software. I like to take things that are horribly and unnecessarily complicated and turn them into something with a friendly interface.

Quite some time ago I developed a 3D engine for my game suite. This was back in the days when most options had pricetags of five or six digits minimum, and your first triangle in D3D took pages of code that you pretty-much had to copy blindly just to get a single triangle up. Shortly after the invention of the wheel if I recall correctly. Most of the time you were fighting the code to figure out why all you were getting was an empty black screen.

I was able to get the hello world of my engine down to four lines in main(), and that included a set of animated spinning cubes and a blue sky. I was really proud of that. Smiley I considered changing the way input was managed to get it down to three lines, but I decided that I'd already made my point on ease-of-use. Wink

I was always a bit attracted by electronics, this post just gave me more desire to start!

That's awesome. Smiley It's a fascinating area and I could never give a reply that would do it justice without  going massively off-topic for the thread. So, a few quick tips:

- Start with something like a Raspberry Pi. Later get a breadboard, wires, and cheap LEDs. Make a LED blinker controlled by the Pi.
- Electronic components are surprisingly cheap, but you'll eventually end up wanting a lot of them. Tools are expensive.
- Never use a soldering iron without temperature control. Avoid lead-free solder, it is way too hard for a beginner to work with. Buy a flux pen and wick before you start soldering.

Some links to online stores that both sell parts and have massive sets of tutorials:

- https://learn.sparkfun.com/
- https://learn.adafruit.com/

Good luck. Smiley
Logged
SouldomainTM
Level 0
***


"In Science We Trust"


View Profile
« Reply #4870 on: July 20, 2017, 05:54:58 AM »

I found a better language than C#, it's called F#. I never thought that one language could do so significantly better than C#. :O

To put F# to the test. I'm making a custom F# engine for my current game.
Logged

Ordnas
Level 10
*****



View Profile WWW
« Reply #4871 on: July 20, 2017, 06:55:55 AM »

That's awesome. Smiley It's a fascinating area and I could never give a reply that would do it justice without  going massively off-topic for the thread. So, a few quick tips:

- Start with something like a Raspberry Pi. Later get a breadboard, wires, and cheap LEDs. Make a LED blinker controlled by the Pi.
- Electronic components are surprisingly cheap, but you'll eventually end up wanting a lot of them. Tools are expensive.
- Never use a soldering iron without temperature control. Avoid lead-free solder, it is way too hard for a beginner to work with. Buy a flux pen and wick before you start soldering.

Some links to online stores that both sell parts and have massive sets of tutorials:

- https://learn.sparkfun.com/
- https://learn.adafruit.com/

Good luck. Smiley


Thank you very much Garthy, when I will start I will definitely follow you tips! The Raspberry Pi is very cheap, I knew about it, I found it particularly interesting for building a budget PC with a Linux distro under $30. And the Sparkfun tutorials seem well made, I was looking right now the "Getting Started with the Raspberry Pi Zero Wireless".
Logged

Games:

Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #4872 on: July 20, 2017, 03:55:49 PM »


Thank you very much Garthy, when I will start I will definitely follow you tips! The Raspberry Pi is very cheap, I knew about it, I found it particularly interesting for building a budget PC with a Linux distro under $30. And the Sparkfun tutorials seem well made, I was looking right now the "Getting Started with the Raspberry Pi Zero Wireless".

I'd recommend the Pi 3 ahead of the Zero (or Zero W) for a first Pi. Reasons:

- Far better specs.
- Quad core vs single core.
- No soldering required. Zero requires soldering on headers (which means you need access to a soldering iron and solder).
- HDMI (Pi 3) vs micro HDMI (Zero) for display.
- 4 USB vs 1 USB.
- Availability (zeroes have had notorious supply issues).
- Better value for money.

Advantages of Zero:

- Small and low profile. Easier to fit into projects.
- Easier to solder into projects and add custom headers.
- Cheaper (if you are okay with the specs)
- Probably runs cooler. Pi 3 gets warm.

Both have wireless.

Remember to add a case (select any that specifically list the model), power supply (prefer official for that model), and a Micro SD card to run. Try to find a place that can supply at least the case and power supply with your Pi to save on postage.
Logged
ferreiradaselva
Level 3
***



View Profile
« Reply #4873 on: July 20, 2017, 08:10:32 PM »

I'm not a C# programmer, but I found MonoGame very well written. I'm looking at the math module, and it's very readable. Looks better than Unity's or GLM library. I'm translating that module to my C framework.

I will take a look on other parts to see if I can find other good code.
Logged

Ordnas
Level 10
*****



View Profile WWW
« Reply #4874 on: July 21, 2017, 06:59:37 AM »


Thank you very much Garthy, when I will start I will definitely follow you tips! The Raspberry Pi is very cheap, I knew about it, I found it particularly interesting for building a budget PC with a Linux distro under $30. And the Sparkfun tutorials seem well made, I was looking right now the "Getting Started with the Raspberry Pi Zero Wireless".

I'd recommend the Pi 3 ahead of the Zero (or Zero W) for a first Pi. Reasons:

- Far better specs.
- Quad core vs single core.
- No soldering required. Zero requires soldering on headers (which means you need access to a soldering iron and solder).
- HDMI (Pi 3) vs micro HDMI (Zero) for display.
- 4 USB vs 1 USB.
- Availability (zeroes have had notorious supply issues).
- Better value for money.

Advantages of Zero:

- Small and low profile. Easier to fit into projects.
- Easier to solder into projects and add custom headers.
- Cheaper (if you are okay with the specs)
- Probably runs cooler. Pi 3 gets warm.

Both have wireless.

Remember to add a case (select any that specifically list the model), power supply (prefer official for that model), and a Micro SD card to run. Try to find a place that can supply at least the case and power supply with your Pi to save on postage.


Eheh, now let's make some fun!  Grin
Logged

Games:

Ordnas
Level 10
*****



View Profile WWW
« Reply #4875 on: July 21, 2017, 07:02:17 AM »

I'm not a C# programmer, but I found MonoGame very well written. I'm looking at the math module, and it's very readable. Looks better than Unity's or GLM library. I'm translating that module to my C framework.

I will take a look on other parts to see if I can find other good code.

Is MonoGame the framework based on the now-dead XNA from Microsoft? I used to program on XNA, it was interesting, it's a shamed that Microsoft abandoned the framework, I did not follow all the story, anyone knows why?
Logged

Games:

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #4876 on: July 21, 2017, 10:41:37 AM »

It's worth noting that with the cheaper pi, you can design a game and sell it WITH it and make a return because the price is small. Like a console specific to your game.
Logged

Photon
Level 4
****


View Profile
« Reply #4877 on: July 21, 2017, 02:09:59 PM »

So I'm making a number puzzler where you have to, at its core, put single-digit numbers together in sets to solve different equations. I was figuring out each possible set per sum by hand and didn't want to take the time to write something to do it for me. Well, I backtracked on that and I actually figured out a relatively painless way to construct sum sets with no repeats:

Code:
typedef ComboList = Array<Array<Int>>;
 
class ComboCalculator
{
public var min_num:Int;
public var max_num:Int;

public var combo_amt:Int;
public var combo_map:Map<Int, ComboList>;

public function new(p_min:Int, p_max:Int)
{
this.min_num = p_min;
this.max_num = p_max;
}

public function calculate(c_amt:Int)
{
if (c_amt < 2)
{
trace("Invalid amt parameter.");
return;
}

this.combo_amt = c_amt;
this.combo_map = new Map<Int, ComboList>();

// Set up the base set that we'll work with

var set:Array<Int> = new Array<Int>();
var base:Int = this.min_num;

for (i in 0...this.combo_amt)
{
set.push(base);
base++;
}

// Start calculating

var calc_loop:Bool = true;

var sum:Int;
var s_i:Int = this.combo_amt - 1;

while (calc_loop)
{
while (set[s_i] < this.max_num + 1)
{
sum = 0;

for (val in set)
{
sum += val;
}

if (!this.combo_map.exists(sum))
{
this.combo_map.set(sum, new ComboList());
}

this.combo_map.get(sum).push(set.copy());
set[s_i] = set[s_i] + 1;
}

while (true)
{
s_i--;

if (set[s_i] + 1 != set[s_i + 1])
{
set[s_i] = set[s_i] + 1; // Increment this number

while (s_i != this.combo_amt - 1)
{
set[s_i + 1] = set[s_i] + 1; // Each following number will be +1
s_i++;
}

break; // Exit this loop
}

if (s_i == 0)
{
calc_loop = false;
break; // Exit this loop
}
}
}
}
}
Way less painful that I figured it would be to write. Works great (though its output is not formatted in a particularly great way yet):

EDIT: Now it is...  Smiley

Code:
ComboCalculator.hx:126: 10 (CNT = 1) >> [1,2,3,4] ; 
ComboCalculator.hx:126: 11 (CNT = 1) >> [1,2,3,5] ;
ComboCalculator.hx:126: 12 (CNT = 2) >> [1,2,3,6] ; [1,2,4,5] ;
ComboCalculator.hx:126: 13 (CNT = 3) >> [1,2,3,7] ; [1,2,4,6] ; [1,3,4,5] ;
ComboCalculator.hx:126: 14 (CNT = 5) >> [1,2,3,8] ; [1,2,4,7] ; [1,2,5,6] ; [1,3,4,6] ; [2,3,4,5] ;
ComboCalculator.hx:126: 15 (CNT = 6) >> [1,2,3,9] ; [1,2,4,8] ; [1,2,5,7] ; [1,3,4,7] ; [1,3,5,6] ; [2,3,4,6] ;
ComboCalculator.hx:126: 16 (CNT = 8) >> [1,2,4,9] ; [1,2,5,8] ; [1,2,6,7] ; [1,3,4,8] ; [1,3,5,7] ; [1,4,5,6] ; [2,3,4,7] ; [2,3,5,6] ;
ComboCalculator.hx:126: 17 (CNT = 9) >> [1,2,5,9] ; [1,2,6,8] ; [1,3,4,9] ; [1,3,5,8] ; [1,3,6,7] ; [1,4,5,7] ; [2,3,4,8] ; [2,3,5,7] ; [2,4,5,6] ;
ComboCalculator.hx:126: 18 (CNT = 11) >> [1,2,6,9] ; [1,2,7,8] ; [1,3,5,9] ; [1,3,6,8] ; [1,4,5,8] ; [1,4,6,7] ; [2,3,4,9] ; [2,3,5,8] ; [2,3,6,7] ; [2,4,5,7] ; [3,4,5,6] ;
ComboCalculator.hx:126: 19 (CNT = 11) >> [1,2,7,9] ; [1,3,6,9] ; [1,3,7,8] ; [1,4,5,9] ; [1,4,6,8] ; [1,5,6,7] ; [2,3,5,9] ; [2,3,6,8] ; [2,4,5,8] ; [2,4,6,7] ; [3,4,5,7] ;
ComboCalculator.hx:126: 20 (CNT = 12) >> [1,2,8,9] ; [1,3,7,9] ; [1,4,6,9] ; [1,4,7,8] ; [1,5,6,8] ; [2,3,6,9] ; [2,3,7,8] ; [2,4,5,9] ; [2,4,6,8] ; [2,5,6,7] ; [3,4,5,8] ; [3,4,6,7] ;
ComboCalculator.hx:126: 21 (CNT = 11) >> [1,3,8,9] ; [1,4,7,9] ; [1,5,6,9] ; [1,5,7,8] ; [2,3,7,9] ; [2,4,6,9] ; [2,4,7,8] ; [2,5,6,8] ; [3,4,5,9] ; [3,4,6,8] ; [3,5,6,7] ;
ComboCalculator.hx:126: 22 (CNT = 11) >> [1,4,8,9] ; [1,5,7,9] ; [1,6,7,8] ; [2,3,8,9] ; [2,4,7,9] ; [2,5,6,9] ; [2,5,7,8] ; [3,4,6,9] ; [3,4,7,8] ; [3,5,6,8] ; [4,5,6,7] ;
ComboCalculator.hx:126: 23 (CNT = 9) >> [1,5,8,9] ; [1,6,7,9] ; [2,4,8,9] ; [2,5,7,9] ; [2,6,7,8] ; [3,4,7,9] ; [3,5,6,9] ; [3,5,7,8] ; [4,5,6,8] ;
ComboCalculator.hx:126: 24 (CNT = 8) >> [1,6,8,9] ; [2,5,8,9] ; [2,6,7,9] ; [3,4,8,9] ; [3,5,7,9] ; [3,6,7,8] ; [4,5,6,9] ; [4,5,7,8] ;
ComboCalculator.hx:126: 25 (CNT = 6) >> [1,7,8,9] ; [2,6,8,9] ; [3,5,8,9] ; [3,6,7,9] ; [4,5,7,9] ; [4,6,7,8] ;
ComboCalculator.hx:126: 26 (CNT = 5) >> [2,7,8,9] ; [3,6,8,9] ; [4,5,8,9] ; [4,6,7,9] ; [5,6,7,8] ;
ComboCalculator.hx:126: 27 (CNT = 3) >> [3,7,8,9] ; [4,6,8,9] ; [5,6,7,9] ;
ComboCalculator.hx:126: 28 (CNT = 2) >> [4,7,8,9] ; [5,6,8,9] ;
ComboCalculator.hx:126: 29 (CNT = 1) >> [5,7,8,9] ;
ComboCalculator.hx:126: 30 (CNT = 1) >> [6,7,8,9] ;
« Last Edit: July 21, 2017, 02:19:27 PM by Photon » Logged
ferreiradaselva
Level 3
***



View Profile
« Reply #4878 on: July 21, 2017, 05:50:31 PM »

Ok, this is very satisfying news to me:

https://www.phoronix.com/scan.php?page=news_item&px=Nintendo-Switch-Vulkan-Conform

Nintendo is part of Khronos group, now, and is conformant with OpenGL and Vulkan. This is so good.


Is MonoGame the framework based on the now-dead XNA from Microsoft? I used to program on XNA, it was interesting, it's a shamed that Microsoft abandoned the framework, I did not follow all the story, anyone knows why?

Yes, it is. I never used, but I was looking the API and some tutorials to compare with my framework, and it looks really (*really*) good. About XNA, who knows what actually happened, the API wasn't actively updated, until the point they abandoned.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4879 on: July 22, 2017, 06:46:39 AM »

XNA died as part of Microsoft shutting down XBLIG and Shawn Hargraves has moved on to working on Win2D for microsoft.

Monogame continued the development and updated it to include something like 10+ platforms (all consoles, mobile, vita). They also massively improved it by adding a dedicated content pipeline tool and generally improved stuff across the board.

So XNA really isn't dead, it lives on better than it ever was as XNA.

If you are working in classic XNA and want to get more targets there's also FNA. I haven't used it myself but I've heard good things. Towerfall I believe used FNA.

Logged

Pages: 1 ... 242 243 [244] 245 246 ... 279
Print
Jump to:  

Theme orange-lt created by panic