What I mean is that things like StopIteration exceptions are fundamental to how iteration works. for loops and any kind of comprehension over iterators keeps calling __next__ until an exception is thrown. It kinda makes sense from an 'ease of building these tools' perspective but seems antithetical to what I've been taught.
[QUOTE=DrDevil;52664726]Are you referring to something like this?
[code]it = iter(sequence)
while True:
try:
value = it.next()
except StopIteration:
break
print(value)
[/code]
If yes, it's not the pythonic way to use iterators, see [url]https://softwareengineering.stackexchange.com/questions/112463/why-do-iterators-in-python-raise-an-exception[/url]
And personally I think it's a good way to handle the case, as you're trying to get the next item where there is none, which is exceptional.[/QUOTE]
Exceptions are generally at a certain cost.
The .NET Framework has an [url=https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator.movenext?view=netframework-4.7#System_Collections_IEnumerator_MoveNext]IEnumerator.MoveNext()[/url] that returns whether or not we reached the end of the enumeration, and you can fetch the [i]Current[/i] value.
[QUOTE=Karmah;52664718] /**/ vs //[/QUOTE]
Isn't this just multi-line comment vs single line comment? Why not just use a single line comment when you're commenting on a single line, and multi-line comment when you need to do multiple lines? That's always what I've done
[QUOTE=djjkxbox;52664821]Isn't this just multi-line comment vs single line comment? Why not just use a single line comment when you're commenting on a single line, and multi-line comment when you need to do multiple lines? That's always what I've done[/QUOTE]
They can also be used to comment inside lines of code, but I've never done that myself, so.
i.e.
[code]Call(param1 /* bla */);[/code]
I've done that, but only to temporarily debug something, not permanently
I've done inline block comments to silence compiler warnings for unused parameters, where I know I'll be using them in the future and don't want to forget their name =P
[QUOTE=Nabile13;52664826]They can also be used to comment inside lines of code, but I've never done that myself, so.
i.e.
[code]Call(param1 /* bla */);[/code][/QUOTE]
The example above is useful for when you want to comment about something without commenting the rest of the line.
The following example would comment the rest of the line:
[code]
Call(param1 // blah);
[/code]
Something I started doing:
[code]
/*
blah blah blah
// */
[/code]
Now you can add // on the first line to uncomment your code in between and the */ won't cause a problem.
I'm sure there's someone out there who prefers
[code]
// huge
// comment
// block
/*deprecatedFunction();*/[/code]
I'm a minimalist so I like to do
[code]
# python docstring quotes piss me the fuck off
# it's much easier to do this and it looks cleaner in IDEs
# just not on facepunch's weird ass highlighting
[/code]
Now you can pick a faction in multiplayer! :)
[IMG]https://i.imgur.com/paEVFgp.png[/IMG]
[IMG]https://i.imgur.com/JOLLEuJ.png[/IMG]
Which is pretty rocking. It exposed some massive errors in the way that I handle projectiles and battles which was a slightly less entertaining two days down the rabbit hole, but that's all cleaned up at least. The UI is all very debug at the moment, but it works which is the main thing :)
That's pretty much the end of the networking now - diplomacy is the last system that needs to be altered to work correctly, but it shouldn't (lol) be too bad (ha)
Got my GoldSource multiplayer bot to play Opposing Force CTF:
[img]https://raw.githubusercontent.com/tschumann/sandbot/master/screenshots/22-7-17/op4ctf_hairball0004.bmp[/img]
It's been working for a while but I only got around to releasing the update today.
[QUOTE=DrDevil;52663303]Phew, I've got a tough decision to make:
A good friend of mine recently became an official consultant for a very big open source project, and says he gets way more consulting offers than he could handle even with 2 clones of himself. So he offered to train me and then pass some consulting jobs my way.
The thing is: The project deals with very low level C coding and requires a lot of computer architecture knowledge, so it will be a very steep learning curve for me. He acknowledges that, and he said he will do it knowing that for the first 3 months he won't get any productivity gains out of me.
I am also not sure if low level computer architectures is something I can get behind, I've never done anything like that before.
On the other hand: Consulting jobs generate a metric shitton of money, which is kinda nice to have, together with a very flexible working schedule.
Should I do it? I've got the feeling that it's a once in a lifetime offer, especially since the project is gaining more and more traction and is already being used by some of the biggest companies.
It would also mean that I would stop my electrical engineering master's degree if this turns out as a viable job.[/QUOTE]
Programmers with a foot in electrical engineering are usually a good fit for tasks involving computer architecture (though you really might not have covered much if you're pure EE).
IMO people tend to find this much scarier than it is (but I personally find the subject interesting so I'm biased).
[QUOTE=Icedshot;52665395]Now you can pick a faction in multiplayer! :)
[t]https://i.imgur.com/paEVFgp.png[/t]
[t]https://i.imgur.com/JOLLEuJ.png[/t]
Which is pretty rocking. It exposed some massive errors in the way that I handle projectiles and battles which was a slightly less entertaining two days down the rabbit hole, but that's all cleaned up at least. The UI is all very debug at the moment, but it works which is the main thing :)
That's pretty much the end of the networking now - diplomacy is the last system that needs to be altered to work correctly, but it shouldn't (lol) be too bad (ha)[/QUOTE]
Looks a lot like Starsector, I like it!
Got this working today, nothing amazing but it works.
[vid]https://cdn-e2.streamable.com/video/mp4/xk3tg.mp4?token=1506253792_c5aeebc357a4f90d14ad5b95ce85869f2c0526ab[/vid]
[editline]10th September 2017[/editline]
I like the engine, it's convenient. It takes a bit of getting used to a dynamic language without break point debugging but I'm getting used to it.
My usual approach of bruteforce implementation doesn't work when I can't put a breapoint on something until I figure out why it doesn't work.
[QUOTE=reevezy67;52666851]Got this working today, nothing amazing but it works.
[vid]https://cdn-e2.streamable.com/video/mp4/xk3tg.mp4?token=1506253792_c5aeebc357a4f90d14ad5b95ce85869f2c0526ab[/vid]
[editline]10th September 2017[/editline]
I like the engine, it's convenient. It takes a bit of getting used to a dynamic language without break point debugging but I'm getting used to it.
My usual approach of bruteforce implementation doesn't work when I can't put a breapoint on something until I figure out why it doesn't work.[/QUOTE]
It has breakpoint debugging actually!
In the built in editor, click just to the left of the line numbers, it works famously!
[img]http://i.imgur.com/apnsLva.png[/img]
(yes my code is awful, deal with it :v:)
[QUOTE=Profanwolf;52667009]
(yes my code is awful, deal with it :v:)[/QUOTE]
[cpp]__kernel
//__attribute__((reqd_work_group_size(DIM_KERNEL3, DIM_KERNEL3, 1)))
//__attribute__((vec_type_hint(float3)))
void kernel3(__global struct triangle *triangles, float4 c_pos, float4 c_rot, __global uint* depth_buffer, __read_only image2d_t id_buffer,
image_3d_read array, __write_only image2d_t screen, __write_only image2d_t backup_screen, __global uint *nums, __global uint *sizes, __global struct obj_g_descriptor* gobj,
__global uint* lnum, __global struct light* lights, __global uint* light_depth_buffer, __global uint* static_light_depth_buffer, __global uint * to_clear, __global uint* fragment_id_buffer, __global float4* cutdown_tris,
float4 screen_clear_colour, uint frame_id, __global ushort2* screen_normals_optional,
int use_optional_blend_buffer, __global uint* optional_blend_buffer_depth, __read_only image2d_t optional_blend_screen, uint mip_start, uint use_linear_rendering
)[/cpp]
This is an actual function declaration in one of my projects (the 3d renderer, deferred rendering screen shading is complex ok)
[cpp]WATTR void \
C(write_image,PT##_fsuf)(read_write IT##_ity i, IT##_##CT##_cty c, int l, IT##_##PT##_pty p) \
{ \
C(PFX,C(store,C(PT##_ksuf,C(_lod,IT))))(LOWER_rw##IT(i), c, l, IT##_##PT##_parg); \
}[/cpp]
This is code that AMD released as part of their open source driver for OpenCL
your code is fine :v:
[QUOTE=Naelstrom;52666794]Looks a lot like Starsector, I like it![/QUOTE]
Thanks! I haven't played starsector/farer for a really long time now, its great to see that its still in development. I was really a fan of the procedural ship destruction in that game, plus it looks like it has a load more in terms of gameplay which is awesome
I'm planning to keep the entire thing much less flashy than starsector. Its no aurora or df, but I'm really going to be focusing on stuffing content in this game out of the wazoo. I find too often in space games there's the thin veneer of depth and interaction, which falls apart when you poke it even a little
The majority of technical work is nearly done though, after some more ui improvements and battle improvements, then i'm going to start adding von neumann probes, ai uprisings, ringworlds, black holes, ancient factions (partially implemented!) etc etc
[QUOTE=DoctorSalt;52664696]Question that's been on my mind: Many languages use exceptions for regular code use, like throwing an exception to say an iterator has finished. Is this not a bad practice? I thought there were supposed to be used for extenuating circumstances and not for sunny-day code logic.
See: Python
EDIT: I mean this in a high-level theory way (how languages use exceptions behind the scenes to implement common logic).[/QUOTE]
The main reason you wouldn't want to overuse them is because they usually have a pretty high amount of overhead (often collecting a full stack trace).
If Python doesn't have that issue, then there's really no good reason not to use them this way.
Personally I'd probably go with a multi-returning [I]next()[/I] function similar to JS's (of type [I]() -> { done : Boolean, value : any }[/I]), but I'm not sure that's actually a good idea in a language where you can't return that as by-value struct.
The nice thing about this is that there's no reference held to the current value (like in .Net for example), but that you still get a lightweight return type that's easy to branch on. A discriminating union value would be even better, though.
OH
That helps.
[QUOTE=reevezy67;52666851]Got this working today, nothing amazing but it works.
[vid]https://cdn-e2.streamable.com/video/mp4/xk3tg.mp4?token=1506253792_c5aeebc357a4f90d14ad5b95ce85869f2c0526ab[/vid]
[editline]10th September 2017[/editline]
I like the engine, it's convenient. It takes a bit of getting used to a dynamic language without break point debugging but I'm getting used to it.
My usual approach of bruteforce implementation doesn't work when I can't put a breapoint on something until I figure out why it doesn't work.[/QUOTE]
Did you make the sprites or you got them from OpenGameArt or similar?
[IMG]https://i.imgur.com/OS242CZ.png[/IMG]
I'm now off the networking sauce (everything works as intended, although some things are intentionally broken), which means its back to improving the UI
One of the big problems is that its very difficult to adequately control different groupings of ships. Fleets before were a totally opaque icon where you had no idea what was in them, so you had to cycle round to get an idea what was happening, which was bad
Now I've shape + size coded the different kinds of ship purposes (military, colony, scout, mining, these are labels assigned procedurally to your ship designs), as well as expanding them out into chevron stacks for a fleet. This makes it way easier to see what on earth is going on which rocks. Hooray!
Anyone know how licensing works? Specifically BSD 3 clause, what does it mean when it says "Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission." More specifically, if I integrate support for a BSD 3 library (specifically Cereal which is a serialization library) and specifically say I support it, is that legal or does it break BSD 3? Or is this point moot since I am not actually using the library itself, but only saying I support it?
[img_thumb]https://i.imgur.com/CTqRXtU.gif[/img_thumb]
This isn't really anything very impressive, but I figured I should share.
Under the hood I've got a real basic client/server system running off a custom packet reader/writer and a what I think is a pretty neat system for client server interaction. At this point I do actually have some client rendering, however I don't have that enabled for this since the server isn't in any control of that demo.
[img_thumb]https://i.imgur.com/8e4aF4R.png[/img_thumb]
This is a picture of the demo I mentioned, but its mostly just a renderer so far and needs some actual map data to show off anything cooler.
[QUOTE=RockyTV;52667170]Did you make the sprites or you got them from OpenGameArt or similar?[/QUOTE]
I google image searched the background, the little player sprite comes with the engine.
They're being swapped out eventually.
[QUOTE=Nabile13;52664797]Exceptions are generally at a certain cost.
The .NET Framework has an [URL="https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator.movenext?view=netframework-4.7#System_Collections_IEnumerator_MoveNext"]IEnumerator.MoveNext()[/URL] that returns whether or not we reached the end of the enumeration, and you can fetch the [I]Current[/I] value.[/QUOTE]
The next function also has a default argument for dealing with this situation.
[cpp]
sentinel = object()
while True:
value = next(it, sentinel)
if value is sentinel:
break
dostuff(value)
[/cpp]
For the case of iterating over a single iterator, the for... in syntax is definitely nicer. This trick is still useful when you want to do something like iterate a bunch of iterators at the same time. See for example the [URL="https://docs.python.org/3.4/library/functions.html#zip"]zip implementation[/URL] here.
[editline]11th September 2017[/editline]
Performance wise this doesn't change anything, the exception is still thrown and caught. It just encapsulates the mess.
[QUOTE=WTF Nuke;52669419]Anyone know how licensing works? Specifically BSD 3 clause, what does it mean when it says "Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission." More specifically, if I integrate support for a BSD 3 library (specifically Cereal which is a serialization library) and specifically say I support it, is that legal or does it break BSD 3? Or is this point moot since I am not actually using the library itself, but only saying I support it?[/QUOTE]
I read that as: if "John Doe" writes library LibXyz, and you use LibXyz in your Project123, you can't say "John Doe endorses Project123" without consent from John Doe. But I'm not a lawyer.
After a couple hours of work, I finally managed to deploy a portable MSVC 19.0.23918 compiler, ~1.3gb and runs on vfat drives.
[t]https://i.imgur.com/brk4IvF.png[/t]
[editline]11th September 2017[/editline]
Fuck you microsoft, I don't have the 4gb of C:\ space ya'll want :(
Planning on making my own file sync cloud thing for my code. I like to use Google Drive but the windows client is awful. It takes forever to upload anything.
Aren't they [url=https://www.theregister.co.uk/2017/09/11/google_deprecates_drive/]getting rid of the Google drive client?[/url]
I thought of that idea yesterday and that article was from today. Guess I actually have a deadline to do this now otherwise I gotta start worrying about locally storing my shit.
Sorry, you need to Log In to post a reply to this thread.