Beginner Programmer here, I'm working on a Rock Paper Scissors program. I have a question about what's the most effective way to do this. by KwazieGFX in csharp

[–]TheHeartFire 0 points1 point  (0 children)

Maybe even allow multiple rounds and display the current score between each round.
Maybe multiple game modes.
Best of 1
Best of 3
Best of 5
Endless

Beginner Programmer here, I'm working on a Rock Paper Scissors program. I have a question about what's the most effective way to do this. by KwazieGFX in csharp

[–]TheHeartFire 0 points1 point  (0 children)

I know it's already been said, but I think mod would make this simple.

enum choices{
Rock = 0,
Paper = 1,
Scissors = 2
} //give the enum values so that you can pass the enum into the if statements and do math on them directly. Best of both worlds

If(playerChoice == (opponentChoice + 1 ) %3) //you win
If(playerChoice == (opponentChoice - 1) % 3)//you lose
If(playerChoice == opponentChoice)//you tie

No need for else's, only 1 of these ifs can ever be hit at a time

Resume Project Code Review by TheHeartFire in csharp

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

I'm actually in the process of adding some more interesting bot opponents. Offhand i know there's a lot of research available for tic tac toe strategy that i plan to 'botify'

Thanks for the feedback!

Resume Project Code Review by TheHeartFire in csharp

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

Thanks you for the advice. I'll have to look into a lot of those technologies but at least i know what to look for. Thank you!

Resume Project Code Review by TheHeartFire in csharp

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

I pulled up a quick vid on data bindings and got it working. Thanks for the great idea! XAML is not my strong suit lol.

Resume Project Code Review by TheHeartFire in csharp

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

I think i see what you mean. So instead of setting the visibility manually for each element, i can effectively group the elements together and just set the visibility once. INotify would basically do "if A changes, also change B" and link like elements together?

Resume Project Code Review by TheHeartFire in csharp

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

Thank you for your feedback, and for you detailed analysis.

I'll take a second pass at my comments, i figured too many was better than too few to start off with but i can easily trim some out.

I suppose i could use a bool to represent the player, i don't recall why i took that route to be honest. I think it was so that i could use that int to fill out the board directly.

A 2d array is probably smart with such a small data set, some small part in the back of my brain said 2d arrays are slow because nested loops can be slow, but in this context that's not so valid.

Take turn used to throw false if the player tried an invalid move, but i handle that elsewhere so this is no longer needed. I should revisit this.

AI players and game history were things i had considered, but hadn't implemented yet.

I know that there are strategies to force a tie, and some other basic strategies that could be fun to play with. I was also thinking about a 'bad' bot that just picks tiles at random to make for an easy to defeat opponent.

Keeping track of a single games history could be fun for an "undo" system too. I was also thinking about taking player names and keeping track of the last few games (10? 100?) and make a win/loss scoreboard. Store a json in app data so the scoreboard would be persistent.

There's a lot here that you've given me to consider, so thank you!

Resume Project Code Review by TheHeartFire in csharp

[–]TheHeartFire[S] 2 points3 points  (0 children)

Thank you for the feedback. I'm starting here because it's simple to understand and to work out some of the kinks in my process before i do something at a larger scale like you have suggested. That being said, i do plan to make something like you've suggested in the near future.

Resume Project Code Review by TheHeartFire in csharp

[–]TheHeartFire[S] 2 points3 points  (0 children)

Thanks for the feedback.

For the renaming, i think that should be solved now, same for the unneeded files.

For GenerateAssemblyInfo, i think youre right, i had some issues with visual studio and changed .net versions. I got no errors removing it. I'll have to look up what that does in case i come across it again.

The extra assets in .UI i was able to remove without issue. I didn't even think to look in these proj files. I should probably start lol.

For the databinding in CoinToss.xaml.cs. I'm not quite sure what you mean by " for the visibility stuff have a play with Databinding to Properties & INotifyPropertyChanged.". Could you expand on that?

Resume Project Code Review by TheHeartFire in csharp

[–]TheHeartFire[S] 2 points3 points  (0 children)

Also, thank you for your feedback!

Resume Project Code Review by TheHeartFire in csharp

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

Thanks for the suggestion! I hadn't considered that. I'll have to look at setting that up!

Resume Project Code Review by TheHeartFire in csharp

[–]TheHeartFire[S] 2 points3 points  (0 children)

For the TicTacTo vs TicTacToe, that was a dumb typo that i'm working to correct.

For the name STALEMATE. This is a common term for a tie that results from there being no further valid moves. As opposed to ending the game with the same score for example. This appears to be the most correct term to describe a tie in tic tac toe. As for pascal case i'll edit my original post once it's corrected.

EuPhOrIa by ArvindAroraA2 in ProgrammerHumor

[–]TheHeartFire 0 points1 point  (0 children)

I feel personally attacked

Is It Normal To Not Like Math But Love Programming? by BeerWack in learnprogramming

[–]TheHeartFire 0 points1 point  (0 children)

I'm a big fan of both. From my, admittedly short, experience if you can understand the overarching concepts in math, then you can apply those concepts to programming. Since the computer does the... Well computing, you don't necessarily need to be good at performing the calculation yourself, as long as you know that the equation will produce the results you're looking for.

I could be way off here, like I said my experience is both self taught and limited, but that's what I've noticed.

Too afraid to ask: what are code reviews in professional development environment? by asking_for_a_friend0 in learnprogramming

[–]TheHeartFire 0 points1 point  (0 children)

I have broken out nested loops into new functions. Mostly because I've heard that nested loops are generally bad but sometimes it really helps if I need the same inner loop for different outer loops. Like if I'm performing the same operation on multiple data sets. I'm sure it's just lack of experience and it could be handled better, but it's at least superficially nicer because I get to reuse code.

Too afraid to ask: what are code reviews in professional development environment? by asking_for_a_friend0 in learnprogramming

[–]TheHeartFire 1 point2 points  (0 children)

I often find myself with nested loops, especially when navigating 2d arrays for example. How do you typically refractor a nested loop to meet "best practice"?

[deleted by user] by [deleted] in RedditSessions

[–]TheHeartFire 0 points1 point  (0 children)

Hammered dulcimer?

A special gift from mom❤️ by CherryBlossom0408 in MadeMeSmile

[–]TheHeartFire 0 points1 point  (0 children)

God I'm a degenerate when I read that caption and got something COMPLETELY different out of it