• Content count

  • Joined

  • Last visited

Community Reputation

269 Neutral

About sooner123

  • Rank
  1. I got it working with this struct: namespace commandLineOS {     public struct Command {         public string name;         public string helpDoc;         public Delegate commandDelegate;     } This instantiation: commands.Add(new Command { name = "help", helpDoc = "lists this help file", commandDelegate = new Action<List<Command>>(commandHelp) }); And this call: commands[0].commandDelegate.DynamicInvoke(commands); I don't really understand what I did here or exactly why it's working but I am guessing I will need to use Func instead of Action if I want my command to return a value or take in more than one parameter.
  2. I'm creating a little command line interface for the player. They will be able to execute commands similar to in DOS. The commands themselves are structs: public struct Command {     public string name;     public string helpDoc; } And the program has a list of commands: List<Command> commands = new List<Command>(); I initialize all the commands like this: commands.Add(new Command { name = "exit", helpDoc = "exits the OS" }); I also want to be able to pass in a function pointer when adding an element to the commands list. Let's say I have a function like this: public static void helpCommand() {     Console.Write("here is a list of commands: etc."); } And I'd like use a delegate to bind this function to the command when I add the command to the commands list above. What would the syntax for the struct's delegate member be? And how would I pass the delegate into the commands.Add line? Not all command's functions will have the same signature.
  3. I'm working on an assignment. I actually solved the problem but I can't figure out exactly how to insert my code properly into the .js files.   I wrote a big program that does the actual cipher puzzle. I'm just not sure where to paste my code in to these files to get it to work.   [SOLVED] - I realized that these objects need to return a function.
  4. Spherical world for a 2D game

      I wrote an ASCII ray caster and had to deal with that exact case. Funny thing is the effects were so hard to interpret in ASCII that I had to convert the engine to a standard per pixel graphical raycaster to see what was going on. Wasn't aware what the phenomenon was called until years later when I started reading all of Carmack's notes on the BSPs in Doom.
  5. Spherical world for a 2D game

      3/4 of the way through this sentence it clicked that this is not a viable idea. They really won't have a good sense of the world at all. And anything that doesn't end up with some absurd case where they're at poles and the map is cycling around horizontally rapidly will end up having their orientation with respect to the axis of the sphere constantly changing and there will be nothing recognizable to them.     The issue you described is the problem I was trying to describe in the OP. Your solution is probably one of the better ones but as it's essentially ugly, it helps to highlight why I'm just going to have to end up going with a torus since a sphere won't work well at all.
  6. The game is 2d and overhead. The player can walk around and scroll the map arbitrarily. (practically the cardinal and ordinal directions, via arrows or WASD)   It's easy to do this if the world, logically is a torus. But if it's a sphere it seems more complex.   I've found resources aimed at representing a spherical world in a 3D game, but since this is 2d and directly overhead.   Is there any way to do this without having to represent the world as a real sphere and then sliding around on it with some sort of square subset of it? And it seems like even this would run into some issues along the edges and really throughout the whole square slice that gets more stretched the further you are from the center of the screen.
  7. Well that's how I've been doing it. What I don't like is that I have to take extra steps to re-insert that element into the sub-sample so that it's in a random location.   And just appending it then scrambling the sample seems wasteful since generating the sample already involved a permutation in the first place.   Is deleting wanted element, taking sub sample of remainder of list, appending wanted element to sub sample, and scrambling the sub sample really the best way to do it?   The way I'm appending it now is:  
  8. This would have the problem that the wanted element might appear twice.   So is there a way to take a sample from a list, such that the sample won't contain a specific element?   Also if I do it this way, assuming there is a way to generate a sample that doesn't contain a specific element, I then have to insert the wanted element randomly into the sample.   This seems like a very convoluted approach.
  9. I would like to generate a random subset that contains a specific element.   For example, given a list of the letters of the alphabet. Generate a 5 element sample that includes the 3rd element.   alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', ...] wantedSubset = random.sample(alphabet, 5)   This does everything I want except for guaranteeing that 'c' will be an element.
  10. You could of course have at least given a link to the specific video. Or given the name of the video.   edit: Well it was easy to find.   I'm sorry but that video was not useful at all. Jut you repeating yourself over and over giving really obvious advice when what is needed by most people is some concrete comparisons.
  11.   Just intuition here. I wasn't able to find anything else for modeling expected ratio of draws to decisive games given a rating gap (and ratings, since for a given rating gap, higher ratings implies more draws)   GM seemed a reasonable approximation but I can't justify it anymore than saying it was an intuitive guess.
  12. I'm trying to write a chess simulation where entity's ratings are emergent out of pairings where the results are based on comparison of various statistics.   Here is an example that covers the issue I'm running into:   player_1 has a strength attribute strength_1 player_2 has a strength attribute strength_2   I want the expected score [(# of wins + 1/2 * # of draws) / (number of games)] to equal strength_1 / (strength_1 + strength_2)   So far so good. The issue is when I include draws.   Arbitrarily (not exactly arbitrary, but tl;dr) I want the distribution of wins///draws///losses to stick to wins///GM(wins,losses)///losses, where GM is the geometric mean   It's not as simple as strength_1///GM(strength_1, strength_2)///strength_2 because this actually skews things in favor of the weaker player.   So it has to be reverse engineered algebraically.   We need to find x, y, and z, such that ((x + (1/2)*y) / (x + y + z) = strength_1/(strength_1 + strength_2)    <- we can treat the righthand side here as a constant since we know strength_1 and strength_2   And we also have that y = sqrt(x*z)   And finally we have the same equation as above but inverted for the other player: (z + (1/2)*y)/(x+y+z) = strength_2/(strength_1 + strength_2)   Problems are   A) equations are incredibly difficult to solve B) they might not even count as two equations/two variables because I'm not sure if the two main formulas are linearly independent. (same denominator and the constants in question add up to 1) This might not preclude their linear independence, but I'm not very experienced in this type of math so I don't know.
  13. Data Structures & Algorithms for Blackjack Simulator

    Thanks for all your replies.   PeterStock I think the performance may matter since I'm intending on running the simulation as a GA that will evolve towards better play. Also, I didn't mention this, but I'll actually be using upwards of 8 decks (4 and 6 most frequently) to better simulate real casino settings.   Segmented Thanks for the link. That's a nice algorithm. I'm actually leaning towards multiple splits and maybe some splits + messy merges to better simulate real shuffling.   Paradigm Shifter Yeah I am intending on having a variable for depth of penetration. The casino I just visited (for my first casino experience and a $1330 win overall in Blackjack  ) Seemed to reshuffle after roughly 75% penetration into four decks. I didn't know what I was doing or have any real system, but I was keeping separate running counts for 5's, 6's, Aces, and Faces, which apparently is more difficult than and less edge-earning than a simple High-Low system.   Didn't know about random_shuffle. That's awesome. Thanks.   Most casinos don't allow splitting on splits (vast majority if not all) and the opportunity is so rare. However, I feel like I should leave it an option for simulations in which billions of hands may occur. Hopefully my current "hands" design should allow for this. I'll be keeping it in mind.   Your is_soft should do the trick. I'll have to pay special attention to that.   Dealer rules will be part of the parameters of the sim. (hit/stand on soft 17, double after splits, whether you can surrender, # decks, % depth penetration)   The problem with a static table of best plays (which is what I used when I won this weekend in Vegas) is that the best plays do shift somewhat as you reach the end of a deck and counting indicates a heavily loaded or unloaded deck. Not super often, but enough to constitute more advantage from card-counting than is gained from just varying your bets. So I kind of want to give it the "standard table of best plays" and let things "evolve."   Counting cards actually isn't illegal. Only if aided by a device. Nowadays, if you are hurting the house's bottom line, they're more likely to just ask you to stop playing that specific game. My hope is to just grind them down rather than try to make some big plays. From my calculations, in fact, my leaving Vegas on my first trip with a 600% return-on-bankroll was a tad less likely than bankruptcy. So I got lucky and I'd like it to be slightly less "luck" next time
  14. I'm trying to create a Blackjack simulator so I can test out (and maybe genetically evolve) some various play-charts, betting-strategies, and card-counting-charts.   Before I dive into it, I wanted to outline the structure in detail, since the game has these caveats that make it less trivial to code than a game like poker. (like splitting)   My basic design so far is this:   Data Structures: -deck: composed of a vector or list of cards -card: composed of a value (like 10 for 10's, Jacks, Queens, etc.), a name and a suit -hand: composed of a bet, a list of cards, and two hands (potential left split and right split) -player: composed of a balance and a hand   Algorithms: -shuffling: i'm going to shuffle by sucking cards, randomly, out of the deck and creating a new deck, in order   Questions: 1. Should I use a vector or a list for the cards? I'm thinking: vector: O(1) for lookup, O(n/4) for removal (average cases) list: O(n/4) for lookup, O(1) for removal (average cases)   2. How do I deal with Aces? Is the best way to just have some conditional code whenever dealing with cards to see if a card is an Ace to check for soft 17's and the like?