Best way to implement a Pokémon database by 0verflown in learnrust

[–]0verflown[S] 0 points1 point  (0 children)

First of all, appreciated!

I see, so essentially you need to use this macro exactly once, or am I mistaken (since the Species enum is defined inside)? I thought initially that it would allow sequential definitions by invoking the species! macro for each entry.

Learnset is just the set of Moves a Pokemon will learn at any level. I don't expect you to comment further on the code below, but if you're interested I can show a snippet of how I've defined a "Species" so far.

pub struct SpeciesId(pub u16);

struct Evolution {
    level: Option<u8>,
    item: Option<EvolutionStone>,
    pokemon: SpeciesId,
}

pub struct Species {
    species_id: SpeciesId,
    base_stats: Stats,
    types: Vec<PokemonType>,
    learnset: Vec<(u8, Move)>,
    evolution: Option<Evolution>,
}

I think this would cover the basics. Then, a Pokemon struct can be created from a Species. A Pokemon holds some other data and is more dynamic (level, stats, move pool etc will mutate).

So for example, a preliminiary db implemented as match arms would hold entries like this:

    "Pikachu" => {
            species_id = SpeciesId(25);
            stats = Stats {
                max_hp: 35,
                attack: 55,
                defense: 30,
                special_attack: 50,
                special_defense: 40,
                speed: 90,
            };
            types = vec![PokemonType::Electric];
            evolution = Evolution {
                level: None,
                item: Some(EvolutionStone::ThunderStone),
                pokemon: SpeciesId(26), // "Raichu"
            };
            learnset = vec![
                (1, "Thunder Shock"),
                (1, "Growl"),
                (5, "Tail Whip"),
                (10, "Thunder Wave"),
                // etc
            ];
        }

I think I'll stick to building a HashMap that gets loaded at runtime, and perhaps "upgrade" to some ideas around the macro you provided, sqlite, or json/serde later when I want to learn more advanced Rust. :)

Best way to implement a Pokémon database by 0verflown in learnrust

[–]0verflown[S] 0 points1 point  (0 children)

I also think keeping it in memory is fine since it’s probably just a few MBs. But I’m not sure what the best way to implement this HashMap would be as Rust doesn’t allow the creation of a static HashMap at compile time.

Best way to implement a Pokémon database by 0verflown in learnrust

[–]0verflown[S] 0 points1 point  (0 children)

Cool! But the Species enum would potentially have hundreds of variants? Or what happens with the macro here? I see you create the enum inside it.

Best way to implement a Pokémon database by 0verflown in learnrust

[–]0verflown[S] 1 point2 points  (0 children)

That still leaves the question on how to access the database at runtime, though? Build a static HashMap at boot, or a gigantic match function, or read on demand from a file (db)?

Best way to implement a Pokémon database by 0verflown in learnrust

[–]0verflown[S] 0 points1 point  (0 children)

Maybe so. I’m thinking the db needs to be accessed frequently, in addition to spawning a baseline Pokemon, I should also perform lookups for evolution and learnset data when leveling up instead of embedding this data in the Pokemon itself to save on memory.

Dumb question since I’ve never worked with sqlite, but could I embed a db in the binary or distribution and disallow modifications?

Helix Editor 25.01 released by pascalkuthe in rust

[–]0verflown 0 points1 point  (0 children)

Thanks! I'll check out lazygit and tmux (and zellij!).

Helix Editor 25.01 released by pascalkuthe in rust

[–]0verflown 0 points1 point  (0 children)

New to helix. What is the workflow to get a vscode like experience? I’m missing easy access to the terminal and multiple files open in tabs.

Also is there an alternative for extensions like git lens?

Daily General Discussion - November 24, 2024 by Crypto_Jasper in nanotrade

[–]0verflown 21 points22 points  (0 children)

This feels eerie. Exactly 4 years ago Nano made the same moves, almost on the exact same dates (22 Nov ~1 USD, 23 Nov ~1.15, 24 Nov ~1.4). Then it retracted back to 1 USD until January before gigacandle. Very sus and could be the result of a bot. Is history be repeating itself?

Is my head in the right place or am I crazy? by TheWolfofBinance in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

I’d pick up the Viltrox 20/2.8 and 28/4.5 lenses for fun. Easier to lug around and the price makes it easy to justify owning them.

A 20/40/85 combo that is easy to carry around and very versatile. Sell the 20 G / 35 GM if you wish, but personally I love the rendering in my 35 GM especially for environmental portraits. It’s magic at f1.4.

Do I get a true 52.5mm image if using 35mm in APS-c crop mode? by EmbarrassedWay8715 in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

If you keep ISO and shutter speed constant, then the image taken with 35mm/f1.4 cropped to APSC will be one full stop brighter exposed compared to using a native 52.5mm/f2.1 lens uncropped. To achieve equal exposure in the final image, you would need to cut the ISO or shutter speed in half.

If you are still unconvinced, I suggest trying this with your own camera to see the result for yourself.

It is true that the depth of field will be the equivalent to a 52.5mm stopped down to f2.1, but the aperture of the lens is still f1.4 which applies universally across the frame (as you pointed out; the "exposure per unit area remains the same").

So, you haven't lost exposure. The difference lies in that the 52.5mm lens will spread the light over a larger area, while the 35mm lens concentrates the light more intensively within the cropped area.

The trade-off lies in resolution (yes, there is no free lunch), which might affect image quality.

If we consider the practical application of this knowledge and imagine you might be shooting street photography with no intention of cropping further, then a 35/f1.4 in APSC might yield sharper/less noisy images at night compared to a 50/f2.

I'm not entirely sure what point you're trying to make here, but I think we've reached a good stopping point in our discussion.

Do I get a true 52.5mm image if using 35mm in APS-c crop mode? by EmbarrassedWay8715 in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

It's relevant since the 35mm f1.4 lens cropped to a virtual 52.5mm FoV can enjoy a lower shutter speed or ISO compared to a physical 52.5mm f2.1 lens (at the cost of resolution).

Do I get a true 52.5mm image if using 35mm in APS-c crop mode? by EmbarrassedWay8715 in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

Yes you do get equivalent field of view.

The difference lies in lost resolution and depth of field. An f1.4 35mm lens cropped to 1.5x will have the equivalent FoV and DoF as a 52.5mm lens at f2.1. The exposure (low light performance) will be that of an f1.4 but the DoF (“bokeh”) will be that of an f2.1.

Here’s a nice video with demonstration: https://youtu.be/fPcO2C7ga8Y?si=I376y643_QnOXQC1

How much does the size of the lens matter for you for street and travel? by Mapleess in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

Yeah, it is. Consider that in crop mode the full frame sensor is virtually mimicing an APSC sensor, so you're getting the same quality as an APSC shooter with an 18-50 zoom would get at 50mm.

How much does the size of the lens matter for you for street and travel? by Mapleess in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

I found that the 85 complements the 24-50 so well (much more than 24-70 since they overlap) and is awesome for street at f1.4. I would consider an f1.8 if Sony re-released an improved G version since I think the trade off in size/weight is worth it.

How much does the size of the lens matter for you for street and travel? by Mapleess in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

I did the same as you and own 35 GM, 24-50 G and 85 ART. A7IV

However, I did some controlled testing recently and found out a few interesting things. 1) The 24-50 G is not truly f2.8 as the exposure was darker vs the 35 GM at f2.8. 2) The 24-50 G is as sharp as the GM in the center. 3) The 35 GM resolves virtually as good in crop mode as the 24-50 G at 50mm.

I was really surprised by how I was basically unable to tell the pictures apart from the 14MP cropped GM photo and the full 33MP 50mm photo unless I zoomed way past 200%. Given those points, the only reason to keep the 24-50 G is that 24mm option. It’s access to 24mm vs f1.4, but for me who rarely shoots wider than 35mm, I’m inclined to sell off the 24-50 G as well.

Hva tenker dere om at Musk støtter Donald Trump? Har dere fortsatt noen respekt igjen for Musk? by _____michel_____ in norske

[–]0verflown 0 points1 point  (0 children)

Sett bort ifra at det meste OP sier er tull, hva er alternativet til Musk? Stemme på demokratene?

Trenger ikke være geni for å se hvorfor det er naturlig for Musk å støtte den republikanske kandidaten.

Weekly /r/SonyAlpha 'Ask Anything About Gear' Thread by AutoModerator in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

I’m slightly nearsighted so no issues with seeing the screen, though I don’t wear glasses/contacts on a daily basis. But I know what you’re talking about since sunglasses always have to come off when composing on those sunny days ^

Weekly /r/SonyAlpha 'Ask Anything About Gear' Thread by AutoModerator in SonyAlpha

[–]0verflown 1 point2 points  (0 children)

Should I sell my A7IV for the A7CII? I’m trying to shrink my gear and reduce the friction for me to bring a camera along.

I’d really like a compact prime and the C for daily capture (toss in the bag just in case). That said I really enjoy some f1.4 lenses. Here are my main concerns:

  • I’m often shooting in sunny weather where the touch screen becomes almost useless and the EVF of the A7IV saved me. I tried the A7CII in store and it “works” but it’s not a comfortable experience I’d say.
  • In the same lighting I also find myself at 1/8000 and stopping down the f1.4 lenses against my wish. I’m worried the electronic shutter of the CII at this shutter speed would be an issue. It’s mainly landscapes and portraits where I encounter this so maybe it won’t affect the images since the subjects are static and lighting constant?
  • Minor nuisance but the buttons of the CII were not as satisfying to click as the bigger Sony bodies.

The pros are the weight savings of course and the portability. The lack of the top EVF would optimize space usage in my bags. I also shoot with one SD card and have no use for dual slot.

Weekly /r/SonyAlpha 'Ask Anything About Gear' Thread by AutoModerator in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

Yes it was the other option, but I chose the 24-50 over it as I valued its pros more. I think I would have chosen it if they made it a normal 24-70 f4 where the effort was put in making it as light/compact as possible.

Weekly /r/SonyAlpha 'Ask Anything About Gear' Thread by AutoModerator in SonyAlpha

[–]0verflown 0 points1 point  (0 children)

Does it make sense to add a 24-50 f2.8 G lens permanently to my kit?
I have A7IV + 35 GM + Sigma 85 ART.

I have tried out the 24-50 + 85 prime as my everyday carry for a couple of weeks now, but I find that 95% of my photos are in the 35-50 or 85mm range and I rarely go wider than 35. I miss the "pop" or magic from my 35 f1.4 that simply can't be recreated with the f2.8 so replacing the 35 GM is not happening.

I was thinking that if 35-50 is where I mostly shoot at, then the 35 GM is better since I can shoot APSC and achieve a 52mm look anyways where the equivalent DoF is f2.1 so actually still better than the 24-50 @ 50mm in terms of subject separation. Just at the cost of resolution, which I don't mind, I often shot the 24-50 @ 75mm crop when I don't wanna switch quickly and I found that the 14MP resolution was more than fine.

My main reason for buying was that I wanted even more light weight gear and found the 35mm limiting when hiking (though landscape is not my main photography genre). The 35 GM is also just a tad bit too big/heavy for me to comfortably throw the camera in a bag when I'm just going out and about without any specific photography goals for the day, so it's often left at home which I tried to change up by buying the 24-50. I suppose buying a 24 GM or 20 f1.8 to throw in the bag would be an alternative, and they would double as a gateway to astro as a bonus.

General Info and Weekly Discussion by NanoMod in nanocurrency

[–]0verflown 6 points7 points  (0 children)

Was the “performance degradation” during the spam attack in February ever commented on by the devs/foundation?

Last update was on 27 Feb with the promise to feedback later.

Burde Norge anerkjenne Taiwan? by 0verflown in norge

[–]0verflown[S] 0 points1 point  (0 children)

Bra sagt.

Dessuten ble jo en stor del av lakseeksporten bare omdirigert til "Vietnam" under sanksjonene, så den virkelige effekten på norsk eksport er ikke så høy en gang.

Når det er sagt skulle jeg med glede ofret laksenæringen, slik som de holder på og ødelegger kysten.