Programing a Baseball simulator (Cancelled)

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Programing a Baseball simulator (Cancelled)

Postby Vytron » Fri Aug 08, 2014 4:28 pm UTC

I just hit a grand slam on a multiplayer baseball simulator, and loved it! The problem is, and it's with all the baseball simulators that I've seen, it was mostly luck. My skill came in coming with the best players that I could, set the best lineup, and have the best bullpen and Manager preference, but in the end, they have this that simulates the games, and it does it by rolling up numbers.

You get bad numbers, nothing else matters. If your opponent rolls good numbers, it can offset your skills. And indeed, veterans of the site were complaining that they'd lost simulated World Series because of the luck factor, and all kind of baseball simulations I've seen depend on the roll of a dice or the drawing of cards. All you can do is improve your chances. The best players are those that improve their chances, but no matter what they do, if they have a streak of bad luck, they'll lose.

That's what I've been designing a baseball game simulation of my own, that gets rid of the luck factor completely. All the numbers on the player's cards are there to see by everyone, so if you can predict the lineup and pitcher that your opponent is going to use, you should be able to beat them, with strategy, not luck.

For a long time I struggled about how to procedurally generate player cards. Randomly generating them was easy, but I wanted their name to have meaning (i.e. a card for "Batman" always creates the same card.)

Finally I found my solution on random.org's persistent identifier. Looking for a string for "Batman" would always create that card, so the card being Batman had a meaning.

Image

The first 3 numbers of the left column go to the player's VY (Velocity), the next ones go for CL (Control), the next for FG (Fielding) and the last three for defense.

The first 3 numbers of the right column go to the player's CT (Contact), the next ones go for PR (Power), the next for SD (Speed) and the last three for attack.

The remainng number (which goes to the bottom middle of the card) is energy.

I have added grades at the left of the numbers, higher numbers are generally better in the sim so players can use them as guideline to draft their players.

Velocity and Control are used when pitching. Fielding is used after the ball made contact with the oppoent's bat, or someone is attempting to stretch/steal a base against you.

Contact and Power are used when batting, Speed is used after your bat made contact with the ball, or for attempting to streths/steal a base.

The pitcher/batter mechanic is as follows. Here, the pitcher is the one on the left.

ImageImage

First, the first number of the Pitcher's VY is matched against the first number of the batter's CT.

Here's this master table that is used thorough the sim:
Spoiler:
1 Beats 3, 4, 5, 9
2 Beats 1, 4, 6, 9
3 Beats 2, 4, 7, 9
4 Beats 5, 6, 7, 9
5 Beats 2, 3, 6, 8
6 Beats 1, 3, 7, 8
7 Beats 1, 2, 5, 8
8 Beats 1, 2, 3, 4
9 Beats 5, 6, 7, 8
0 Loses to everything
If Retry:
0 Beats everything.


Beating the opponent's number doesn't mean there's a positive outcome, just that it's more likely.

If the Pitcher wins, it matches its first CL number against the next unused CT number of the batter.

If the Batter wins, it matches its first PR number against the next unused VY number of the pitcher.

So there are CLvCT and VYvPR charts with all outcomes for all possible combinations, with the CLvCT chart being generally better for the batter and the VYvPR being generally better for the batter. With the highest numbers giving the best outcomes and the lowest numbers giving the worst ones.

ImageImage

So, here, the first VY number is a 6, and the first CT number is a 2. 6<2 according to the master table so the batter wins. Next is VYBvPRA (second VY number against first PR number). Herb's is an 8 and Batman's is an 8.

The tying table looks as follows:
Spoiler:
9=9. HR.
8=8. Triple.
7=7. Double.
6=6. Hit->2B.
5=5. Single.
4=4. Retry (Batter-Pitcher Contact Vs. Fielding).
3=3. Out.
2=2. High Base out, out.
1=1. High 2 Bases out, out
0=0. If B2, High 2 Bases Double, Out. Else, Hit->2B.

HR = Home Run
Hit->2B = Batter to second, players forced to move advance
If B2 = If there's exactly two players on the bases


8=8 is a Triple, so everyone on the bases score, and Batman moves to third. Herb has used VYA (first VY number) and VYB (second VY number), so she'll need to use VYC (third VY number) against the next batter.

If VYvCT ties, there's a chart for CLvPR outcomes.

These outcomes may lead to deeper outcomes where the batter battles against the fielders, SDvFG, CTvFG and PRvFG, etc.

There's an "uniqueness" rule for outcomes, in where, if a pitcher has already used VYA and VYB against a batter, the next time they face it they must use VYC, and if all three have been used, their defense numbers kick off. So, if Batman was pitching and already had used his 6, 0 and 1 against some batter, the next time he'd use its 8 (first number of defense) against that player.

The same applies to all other stats like CL and FG, and once a batter has used all its numbers from CT, PR, or SD against some player, it starts using its attack numbers (simulating tiredness for some players and engaging in others.)

Finally, energy drops for pitchers every time they have faced a full rotation of batters, and batter's energy drops after the next time they face a pitcher. Once the energy is negative all their numbers are decreased by one. After a game is over all players recover 0.5 energy. This is so players have to use batters from their bench, and there's also forced timeout for pitchers so they can't pitch next game.

--------

And that's basically it, for example games you can read previous iterations of the system, here where a simplistic variation of the system was used, with cards only having three numbers and rotating them for everything on a single chart, and here which uses this system, but grabbed the stats from Pokémon stats, and didn't have attack, defense or energy implemented.

Anyway, the problem of all this is that games take ages to mod manually, for this reason I shortened the games to 3 innings (1 inning if a side is winning by three runs, two innings if a side is winning by 1 run, and more than 3 only if the game is tied), and even then it takes me 2 hours for a single game.

I was wondering how easy would it be to create a program where you could input the data, and it outputted the outcome. Probably just one for a given PitchervBatter outcome, but it could be extended to have as input all incoming batters and fielding positions, and it'd output an entire game.

What would be the best language to program this? The speed doesn't matter, several minutes of waiting would be fine given the saved time. I'd imagine perhaps something like a PHP page where one inputs the teams and it outputs the games. Maybe even one that could grab the numbers from random.org and output the game from them?

And finally, the question on the OP, would it be worth it? I mean, if one would spend hours and hours and hours programming this perhaps those hours would be better spent simulating games manually...

Thanks for your help!
Last edited by Vytron on Wed Jul 08, 2015 2:57 am UTC, edited 3 times in total.

User avatar
Xanthir
My HERO!!!
Posts: 5281
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Programing a Baseball simulator - worth it?

Postby Xanthir » Sat Aug 09, 2014 6:45 am UTC

You don't have to use random.org directly - I'll bet you anything that they're just using the string to seed a PRNG and popping out numbers based on that. If multiple runs start with the same seed, they'll generate the same values. You can do the same in the programming language of your choice.

It sounds like this would be a relatively simple program, with most of the complexity in making input and output easy and attractive; the actual logic is fairly easy (as almost all games are). Given how long it takes you to run even a reduced game manually, it's probably worth it to code it out, if you're going to do it more. There's, of course, an XKCD for that.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Dopefish
Posts: 854
Joined: Sun Sep 20, 2009 5:46 am UTC
Location: The Well of Wishes

Re: Programing a Baseball simulator - worth it?

Postby Dopefish » Sat Aug 09, 2014 8:32 pm UTC

Depending on how much coding experience you have, and if you enjoy programming itself at all, this seems like it could be a nice little project.

One of the woes lots of new programmers can have is that they often lack motivation to work on trivial little 'hello world'-esque programs since they'd rather work on something 'real', but many 'real' things seem beyond them since they haven't really grokked all the basics (that might otherwise come from little toy programs).

With this sort of thing it's a program you'd potentially actually use and be motivated to complete, and while it's probably not terribly difficult to program, it's still big enough that there's plenty to go wrong and be a learning experience as you troubleshoot the various bits and pieces.

Of course if you're an old vet at programming and/or dislike programming then it might just be busywork with relatively little gain, but otherwise it could be a good little project. I had a fun hobby project for a few months a ways back when I was simulating a certain aspect of a game I play, and as it went on it become a rather rewarding experience as I tried new things coding-wise and added various little features, so this seems like it might potentially offer a similar experience for you.

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator - worth it?

Postby Vytron » Sun Aug 10, 2014 2:45 pm UTC

@Xanthir: Thanks, so it seems whether it'd be worth trying depends heavily of how much time I'd need to code it and how many times I have to use it.

I absolutely have no idea.

This is a "for other people project"*, i.e. if people are interested in this sort of simulation and there's high demand, I could imagine creating a web page where people sign up and the system matches one against each other, creating baseball leagues and so on.

If the system flops and nobody cares, I think I'd use the program for 2 weeks or less and then it'd fade into obscurity. So, obviously if this is going to be the case and it's going to take me two weeks to program this, it's not worth it and I'm better just simulating games manually until people lose interest.

People tend to lose interest very quick, though, last iteration had 4 players signing up and one disappeared shortly and another disappeared afterwards, I can get more players somewhere else but it's still hard to device a system that keeps the players coming back every day (at least on weekdays.)

*Otherwise I could just simulate a game now and then manually without showing it to anyone else and be done with it. I could even simulate games manually now and then and go online and show them on some forum and even have players interested betting on the players, etc. But, yeah, if I'm going to simulate games at all I think it's better to think on a base that works from the ground up for people interested.

You don't have to use random.org directly - I'll bet you anything that they're just using the string to seed a PRNG and popping out numbers based on that. If multiple runs start with the same seed, they'll generate the same values. You can do the same in the programming language of your choice.


Thanks, I got it. Yeah, before this I used to use pi for my random number generation, because I've always despised nondeterministic randomness. Systems I've used before seemed to depend on the time that I used them, or their pseudorandomness produced "boring outcomes". I don't know about their quality, but I noticed an improvement of the randomness when I switched to pi.

So, I could make a system that would create player cards based on their names from number from pi, and they'd always be the same. I also have several unused numbers from pi saved somewhere, so I could also make the program use them as seed for the RNG and then use the name of the player as second seed, and I'd get cards just like the ones from random.org.

The problem is this would then become "black boxed". I.e. I could tell the players that a given name they send always produces the same card, and they'd believe me, but they wouldn't be willing download my program just to check for this.

No, I'd want them to be able to just input a name and see what card it creates, and decide to send it or not, without me being there. Random.org's persistent identifier works perfectly for this, interested players could check it out what kind of cards their names would create, so people considering sending Batman would always get that card and this "heh, Batman's Contact sucks, I'd never draft him, so I'm not going to send that name", or something.

But, anyway, I can always input the pre-built player cards on the program. After all, I'm creating these cards manually, and I use the longest time looking for the perfect pictures to use on the cards on Google images, because I'm like that.

From the program itself or Random.org the longest time would still be used looking for what image to use on the card so it wouldn't be a problem if I had to generate the cards outside and input the stats for each card.

I'll bet you anything that they're just using the string to seed a PRNG and popping out numbers based on that.


Well, they claim their numbers are produced from atmospheric noise, which is meant to be actual randomness, and I have no reason to doubt them. But, yeah, I don't care from where randomness comes from, as long as the output is good (for an example of bad one, just look at Winamp's "Shuffle mode". You can have 60000 different songs in a playlist, put them on shuffle, then listen to the same song 3 times in a day. You may say "well, that's how randomness works", but, yeah, it's annoying if 2 times per week you listen to some song over and over and others never seem to play, I have never seen such an effect when grabbing numbers from pi or from random.org, even if the pool is much smaller (usually roll numbers from 000 to 999, never have seen the winamp effect of the same number persistently popping up), so this isn't about randomness, Winamp's "Shuffle mode" just sucks and I'd never use it to produce player cards, I'd not be surprised if after creating 50 players two different named players produced the same card, even though I'm supposed to be able to crate 10^25 different cards...)

@Dopefish:

Depending on how much coding experience you have, and if you enjoy programming itself at all, this seems like it could be a nice little project.


I have enough experience with Turbo C to be able to program for it and write pseudocode. I have been able to write programs in pseudocode and have them being translated to Python by someone else. So I guess I know the basics.

But I'd really want this to be a webbased program, I'd imagine player cards to be saved in some database on the web, and then, retrieved to play the games, so you can visit some web page so look at the results. Then, I could tell the page to update games results at some points, so players can go after then to see how the games went, without me being there.

But I have no experience whatsoever in coding for the web. Would something like PHP be able to do here what is needed? Or Javascript? Or would I need to learn something like JAVA and have it running in the background whenever players want to know their results? etc.

Again, the hardest thing I need to do is to decide how to proceed. If this wouldn't be webbased I guess I could download turbo C and program something like a DOS application that reads text files with the players data on them, then does the simulation so I can hit ENTER to see one play after the other. Or something. It could be ugly because I'd be the only one seeing it and would only use it to relay the result to the players.

Basically, wouldn't know where to start and asking people for pointers.

With this sort of thing it's a program you'd potentially actually use and be motivated to complete, and while it's probably not terribly difficult to program, it's still big enough that there's plenty to go wrong and be a learning experience as you troubleshoot the various bits and pieces.


Thanks. I'm not into programming, so the learning I could get from the project wouldn't be useful to me (I mean, unless some other project pops up and now I know how to program for that project. But if this project flops this could be the last thing I program so all the learning of the process would be useless.)

I don't dislike programming, I'm just more of a designer.

User avatar
Xanthir
My HERO!!!
Posts: 5281
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Programing a Baseball simulator - worth it?

Postby Xanthir » Sun Aug 10, 2014 8:01 pm UTC

Vytron wrote:@Xanthir: Thanks, so it seems whether it'd be worth trying depends heavily of how much time I'd need to code it and how many times I have to use it.

I absolutely have no idea.

This is a "for other people project"*, i.e. if people are interested in this sort of simulation and there's high demand, I could imagine creating a web page where people sign up and the system matches one against each other, creating baseball leagues and so on.

If the system flops and nobody cares, I think I'd use the program for 2 weeks or less and then it'd fade into obscurity. So, obviously if this is going to be the case and it's going to take me two weeks to program this, it's not worth it and I'm better just simulating games manually until people lose interest.

That XKCD obviously only takes into account the worth of the program as a time-saver. If it's fun or educational to build, you can spend much more time on it and still consider it worthwhile. Like Dopefish said, this is a pretty good project for someone who's starting to get the hang of programming and wants something a little bigger and more involved, but not too complicated, to increase their skills with.

People tend to lose interest very quick, though, last iteration had 4 players signing up and one disappeared shortly and another disappeared afterwards, I can get more players somewhere else but it's still hard to device a system that keeps the players coming back every day (at least on weekdays.)

Note that having to wait while someone runs numbers manually would turn off lots of people who might like the concept if it was instantaneous.


Thanks, I got it. Yeah, before this I used to use pi for my random number generation, because I've always despised nondeterministic randomness. Systems I've used before seemed to depend on the time that I used them, or their pseudorandomness produced "boring outcomes". I don't know about their quality, but I noticed an improvement of the randomness when I switched to pi.

Pi isn't random (or rather, nobody's proved that it has the desirable "random" traits you're looking for yet), and it's harder to work with than using more traditional PRNGs. (I can imagine it might be easier when doing things manually, but that's not a constraint if you're programming.)

So, I could make a system that would create player cards based on their names from number from pi, and they'd always be the same. I also have several unused numbers from pi saved somewhere, so I could also make the program use them as seed for the RNG and then use the name of the player as second seed, and I'd get cards just like the ones from random.org.

The problem is this would then become "black boxed". I.e. I could tell the players that a given name they send always produces the same card, and they'd believe me, but they wouldn't be willing download my program just to check for this.

No, I'd want them to be able to just input a name and see what card it creates, and decide to send it or not, without me being there. Random.org's persistent identifier works perfectly for this, interested players could check it out what kind of cards their names would create, so people considering sending Batman would always get that card and this "heh, Batman's Contact sucks, I'd never draft him, so I'm not going to send that name", or something.

I'm not sure what you mean by the problem you're outlining here. You can easily create something online that generates a card from a given name using what I described.

I'll bet you anything that they're just using the string to seed a PRNG and popping out numbers based on that.


Well, they claim their numbers are produced from atmospheric noise, which is meant to be actual randomness, and I have no reason to doubt them.

That's for their actual randomness. The service you're looking at isn't random, it's procedural (or else it's random but cached, which means you shouldn't rely on it for any large length of time, as they could clear out old identifiers at any time, which would result in new values next time you asked for one).

But, yeah, I don't care from where randomness comes from, as long as the output is good (for an example of bad one, just look at Winamp's "Shuffle mode". You can have 60000 different songs in a playlist, put them on shuffle, then listen to the same song 3 times in a day. You may say "well, that's how randomness works", but, yeah, it's annoying if 2 times per week you listen to some song over and over and others never seem to play, I have never seen such an effect when grabbing numbers from pi or from random.org, even if the pool is much smaller (usually roll numbers from 000 to 999, never have seen the winamp effect of the same number persistently popping up), so this isn't about randomness, Winamp's "Shuffle mode" just sucks and I'd never use it to produce player cards, I'd not be surprised if after creating 50 players two different named players produced the same card, even though I'm supposed to be able to crate 10^25 different cards...)

That is indeed how randomness works. If there *aren't* suspicious runs and occasional close repetitions, you're not looking at random data. A good "Shuffle" isn't random, though, because humans are bad at detecting randomness, and see a random shuffle as non-random. A good music shuffle has some memory and prevents songs from replaying for a while after their last appearance, which makes the human brain's terrible random-number-recognizer happier.

You see this kind of thing when you ask people to *generate* random data too. It's extraordinarily easy to tell random coinflips from people pretending to flip a coin, with as few as 100 trials - in the real data you'll expect to see a run of 5-6 heads or tails, while people almost never generate a run that long when they're *trying* to be random.

I have enough experience with Turbo C to be able to program for it and write pseudocode. I have been able to write programs in pseudocode and have them being translated to Python by someone else. So I guess I know the basics.

Good, this sounds like a project that, at your level, will be challenging but not defeatingly so.

But I'd really want this to be a webbased program, I'd imagine player cards to be saved in some database on the web, and then, retrieved to play the games, so you can visit some web page so look at the results. Then, I could tell the page to update games results at some points, so players can go after then to see how the games went, without me being there.

But I have no experience whatsoever in coding for the web. Would something like PHP be able to do here what is needed? Or Javascript? Or would I need to learn something like JAVA and have it running in the background whenever players want to know their results? etc.

Javascript only runs in the browser, so you can save results on the user's computer, but won't be able to save it to a central database so multiple people can view it. You'll need something on the server end to do that. You can still use JS, actually, via the Node.js server, or you can use PHP or Python or Java or any number of other things.

However, I recommend you first write just the generation/simulation part of the code, to get some easy confidence-boosting wins out of the way and motivate you to finish the harder part where you're learning the entirely new model of web programming. Morale is very important when dealing with personal projects!

Again, the hardest thing I need to do is to decide how to proceed. If this wouldn't be webbased I guess I could download turbo C and program something like a DOS application that reads text files with the players data on them, then does the simulation so I can hit ENTER to see one play after the other. Or something. It could be ugly because I'd be the only one seeing it and would only use it to relay the result to the players.

Basically, wouldn't know where to start and asking people for pointers.

That is indeed where I would start, but I'd do it in the language you want to do the entire project in. That way you wont' have to rewrite anything, and you'll get some good experience learning a new language.

I'd recommend using either Python or PHP. PHP's a terrible language in many ways, but it's easy to learn and use for beginners (which is why I learned it first, too). Python's a much better language, but its web support is more difficult to get started with. Might still be worth using it, though.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator - worth it?

Postby Vytron » Thu Aug 14, 2014 4:57 am UTC

Thanks Xanthir.

Well, right off-the bat, I'll say that I liked how you threw the word "procedural" there, because that's exactly what I'm going for.

At the beginning of the OP, I complain about how all existing Baseball simulators rely on randomness, and how I'll want to build one that doesn't.

So, the player cards and game results would be procedurally generated depending on the player names :)

Heh, I can even imagine some meta-procedural generation, where, if the player doesn't want to have to create names for his players, I can take the player's username as seed, and use it to generate names of players, that then use their own names to generate its stats.

Note that having to wait while someone runs numbers manually would turn off lots of people who might like the concept if it was instantaneous.


Well so far I've only done this for Forum Games and it has worked well, because all other games have a mod doing exactly that, running games manually.

But, you're right, if players could just click a button and get a result it'd be much better.

I also guess I could learn something from current online Baseball simulators: they run 3 games a day. So, other than clicking a button and getting a result, people like scheduled things. If they know a game will run at 8AM, 4PM and 12AM, they will come back more often than if "not even god knows when the next game will be played."

Pi isn't random


I've read it's good enough to be a pseudorandomness source if used correctly. Though you need a seed from an outside source.

Say, you could use the time of the day, like, right now it's 2014/08/13/14:18:35. For this given time you can use 20140813141835 as a seed.

Then, you check the first time the string "20140813141835" appears on pi, and check the next number. That's your random number from 0-9.

If you are going to do this again, check the time, now it's 2014/08/13/14:22:25, so you check the next time 20140813142225 appears after the previous string that you rolled, and check the next number. That's your random number from 0-9.

Now, this way of rolling numbers will produce an output that matches nicely the output numbers from other pseudorandom number generators up to 11731392000 numbers rolled in a day. So once you get to 11731392001 numbers and beyond and you put them on software to check for randomness it'll start suspecting something is wrong (and they get worse the more you roll), but it works below the threshold.

And this can be scaled back if you need less number, i.e. you can chop off the seconds of the seed if you only need 195523200 numbers in a day, you can chop off the minutes if you need 3258720 numbers in a day, and you can just look at the date (using 20140813 as seed) if you roll less than 135780 numbers per day.

That is good enough for me (you can actually just use today's date and roll 135780 numbers right now and they'll be good if you don't use them in less than 24 hours, but for someone that wants to roll a number from 0 to 10^7 in a single shot, Pi is useless, though they can just keep increasing the seed. I have rolled them in batches of 1000 and haven't seen any abnormal behavior. I have even seen more abnormal behavior from pure randomness like the one from random.org, but guess that's just atmospheric noise being... random. While Pi will always give the same depending on the input.)

That's for their actual randomness. The service you're looking at isn't random, it's procedural (or else it's random but cached, which means you shouldn't rely on it for any large length of time, as they could clear out old identifiers at any time, which would result in new values next time you asked for one).


Yeah, it's random and cached, but they promise to keep your random identifiers up there for life, so it should be fine as long as random.org is online. I do get I could create my persistent identifiers myself and have the same effect myself without depending on random.org, though.

A good "Shuffle" isn't random, though, because humans are bad at detecting randomness, and see a random shuffle as non-random. A good music shuffle has some memory and prevents songs from replaying for a while after their last appearance, which makes the human brain's terrible random-number-recognizer happier.

You see this kind of thing when you ask people to *generate* random data too. It's extraordinarily easy to tell random coinflips from people pretending to flip a coin, with as few as 100 trials - in the real data you'll expect to see a run of 5-6 heads or tails, while people almost never generate a run that long when they're *trying* to be random.


Indeed. I'd be looking to create a non-random system for procedural generation of cards and games, otherwise there's just some kind of random cards that are going to be created more often than others and they're going to heavily influence the system (say, instead of "this song plays a lot" you get "lots of great pitchers", so the games end up having a lot of outs and it's much more harder to score a run), while the result are unreproducible (say, from the same initial conditions, next time you have lots of sucky pitchers, with too many runs and abnormal game scores.)

I'd basically need to have some kind of "Procedural Judge", that takes a look at the cards and says "nope, we have to many of these cards, reroll", or something. I had already done something like this for the interim generation (I went and generated 18 cards for the current system and play tested a game and it worked well, but I manually "rerolled" until all players had a total of at least 120.)

But in the end, the idea is if there's a lot of superb pitchers or sucky pitchers is because of the names that the players decided to send, and not some randomness. But if all players decide to let their cards be procedurally generated, the result should still be zany (don't keep playing the same song.)

However, I recommend you first write just the generation/simulation part of the code, to get some easy confidence-boosting wins out of the way and motivate you to finish the harder part where you're learning the entirely new model of web programming. Morale is very important when dealing with personal projects!


I guess I'd want to write the simulation first. I.e. I could program a simulator that simulated games for when the cards have 0 everywhere, then I could slowly add the 1s, then the twos... Once I'm done with the numbers I could use that simulator for manually created cards.

I'd recommend using either Python or PHP. PHP's a terrible language in many ways, but it's easy to learn and use for beginners (which is why I learned it first, too). Python's a much better language, but its web support is more difficult to get started with. Might still be worth using it, though.


Oh, I had no idea Python could be used like this for web projects, does it run on the server? (so the user sends input, the server does its thing on Python, and returns output to the user) or is it like Java? (where Python runs on the user's computer)

Anyway, I do like the sound of php, I did minimal twerking for a forum I used to host. Where would I need to start? Do I need to simulate a server that supports PHP on my computer? I remember doing it once and it was easy, I'd just need to find what program I used, I think I still have it installed (one where one visited some 128.1.1.1 website or something to run PHP pages on one's computer, or something.)

Volcano99
Posts: 56
Joined: Wed Dec 16, 2009 10:10 pm UTC
Location: 350 km SW of The Castle

Re: Programing a Baseball simulator - worth it?

Postby Volcano99 » Thu Aug 14, 2014 11:18 am UTC

I'd recommend strongly against PHP. Use Python instead. It's really easy to write a web server using Bottle or Flask (I have used flask more than bottle, but both work OK).

Also don't bother with pi, you can make random number generation deterministic by seeding the random number generator using the character name. Try this in the Python REPL:

Code: Select all

import random

random.seed("Batman")

random.randrange(10) # returns 1

for i in range(10):
    print random.randrange(10)
# prints 6, 3, 6, 6, 4, 0, 4, 5, 8, 2



Changing the character name returns different numbers, but Batman always gives the same sequence. It's also faster than looking up numbers in pi!

I could help you write it all if you are interested! :D

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator - worth it?

Postby Vytron » Fri Aug 15, 2014 6:23 pm UTC

Volcano99 wrote:Changing the character name returns different numbers, but Batman always gives the same sequence.


Oh, cool! So Python kind of has a "persistent identifier" thing already built in? That does seem really powerful!

Volcano99 wrote:I could help you write it all if you are interested! :D


Oh, really? That would be awesome! Thanks!

User avatar
Sizik
Posts: 1191
Joined: Wed Aug 27, 2008 3:48 am UTC

Re: Programing a Baseball simulator - worth it?

Postby Sizik » Fri Aug 15, 2014 6:36 pm UTC

Vytron wrote:
Volcano99 wrote:Changing the character name returns different numbers, but Batman always gives the same sequence.


Oh, cool! So Python kind of has a "persistent identifier" thing already built in? That does seem really powerful!


It's not that Python has "persistent identifiers", it's just how pseudorandom numbers work. Anybody who seeds the generator with, say, "Batman" will get the same sequence of "random" numbers out of it (assuming they use the same algorithm, of course).
gmalivuk wrote:
King Author wrote:If space (rather, distance) is an illusion, it'd be possible for one meta-me to experience both body's sensory inputs.
Yes. And if wishes were horses, wishing wells would fill up very quickly with drowned horses.

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Fri Aug 15, 2014 7:11 pm UTC

Okay, so I imagine we'd start from the bare bones, the core of the game:

Pitcher Vs. Batter Mechanism.

Because, in the end, all the sim will be doing is matching one pitcher card against one batter card over and over and over.

So at the base we need a way to represent the player cards. I'd like to start from cards that have 0s everywhere (we can easily code other numbers after this is at the base).

A player card would be represented like this:

Player 1 card: Array [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Player 2 card: Array [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

An array of 25 numbers (in this case all zeroes.)

The first 3 numbers are VY, the next 3 are CT, the next three are CL, the next three are PR, the next three are FG, the next three are SD, the next three are AT, the next 3 are DF, and the last one is E (but the sim doesn't need to know this.)

So, we'd have these players defined:

Player 1 card: Array [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Player 2 card: Array [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

Now, the game would start, the sim would have to make the Pitcher and Batter's array have those values, like.

Pitcher = Player 1 card
Batter = Player 2 card

And now we compare their numbers. We have to match the Pitcher's first VY with the batter's first CT. Something like:

Pitcher.pitching = first value on Pitcher's array.
(Pitcher.pitching = 0)
Batter.batting = third value on the Batter array.
(Pitcher.pitching = 0)

And we compare them:

If Pitcher.pitching==Batter.batting
Tie();

If both players send the same number we run Tie(); (we don't need to program any other scenario because all players have 0s everywhere)

Tie() just does the same thing, but now just matches the Pitcher's first CL with the batter's first PR. Something like:

Pitcher.pitching = seventh value on Pitcher's array.
(Pitcher.pitching = 0)
Batter.batting = 10th value on the Batter array.
(Pitcher.pitching = 0)

And Tie() has this chart:

If Pitcher.pitching=0 & Batter.batting=0
Return "Batter moves to 2nd, if there were players on 1st and/or 2nd, they're out."

Right now this doesn't do anything, but having a program that returns "Batter moves to 2nd, if there were players on 1st and/or 2nd, they're out" following this process would be the bare bones.

Sizik wrote:It's not that Python has "persistent identifiers", it's just how pseudorandom numbers work. Anybody who seeds the generator with, say, "Batman" will get the same sequence of "random" numbers out of it (assuming they use the same algorithm, of course).


Thanks. I see. I always thought only series of numbers could be used as seeds.

User avatar
Xenomortis
Not actually a special flower.
Posts: 1417
Joined: Thu Oct 11, 2012 8:47 am UTC

Re: Programing a Baseball simulator in Python

Postby Xenomortis » Fri Aug 15, 2014 7:34 pm UTC

Vytron wrote:
Sizik wrote:It's not that Python has "persistent identifiers", it's just how pseudorandom numbers work. Anybody who seeds the generator with, say, "Batman" will get the same sequence of "random" numbers out of it (assuming they use the same algorithm, of course).


Thanks. I see. I always thought only series of numbers could be used as seeds.

It's a computer.
Computers work by pretending everything is a number. :D
Image

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Fri Aug 15, 2014 7:50 pm UTC

That's interesting. So, there's some string of numbers equivalent to "Batman"? (so that, instead of using "Batman" you could use this string of number and it'd produce the same random numbers that "Batman" produces?)

User avatar
Xenomortis
Not actually a special flower.
Posts: 1417
Joined: Thu Oct 11, 2012 8:47 am UTC

Re: Programing a Baseball simulator in Python

Postby Xenomortis » Fri Aug 15, 2014 8:06 pm UTC

Sure, if you know how that block of code interprets input strings.
Image

User avatar
The Great Hippo
Swans ARE SHARP
Posts: 6990
Joined: Fri Dec 14, 2007 4:43 am UTC
Location: behind you

Re: Programing a Baseball simulator in Python

Postby The Great Hippo » Fri Aug 15, 2014 8:42 pm UTC

Presuming by 'string of numbers' you just mean 'a number' rather than 'a number represented via string'.

There is a difference between 3420 and "3420" -- the former is an integer, the latter is a string.

This is important, because if you discovered the string "Batman" is equivalent to the number 3420 -- and then inputed "3420" into the pseudonumber generator -- you might not get the same result. Because "3420" is a different value than 3420; the pseudonumber generator might not let you input 3420 if it's based off of string-identities (it would instead interpret 3420 as "3420", which would have its own numeric value, which would probably be completely different than "Batman"'s numeric value).

Or to put it another way:

int("Batman") == 3420
int("Batman") != "3420"

int("3420") == some other integer value.

EDIT: (If you totally already knew this, I beg your pardon!)

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Sat Aug 16, 2014 6:47 pm UTC

Thanks The Great Hippo, I'm learning here so please don't apologize about saying this I may have already known!

So, yeah, if there was a way to know which:

int("Batman") == int(n)

Produced the same output, and n was longer than 25 characters, I guess I'd want to use n as the number of the cards, instead of the output, as, I don't think anybody has done it ever and I think it's cooler to find a numeric equivalence to the string to produce the cards instead of producing them randomly.

Great Justice
Posts: 54
Joined: Sun Aug 15, 2010 5:28 am UTC

Re: Programing a Baseball simulator in Python

Postby Great Justice » Sun Aug 17, 2014 1:49 am UTC

I think what you're looking for is a cryptographic hash, not a random function.
For example, md5sum("Batman") always produces "cc72fc24056ced9ce13a287ca1243d48", and for any input always returns 32 (hex) digits.
It usually isn't Congress or the State that tries to abridge free expression or free speech, [...] actually, in the present situation, the main threat to expression comes from public opinion.
~Christopher Hitchens

User avatar
Xanthir
My HERO!!!
Posts: 5281
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Programing a Baseball simulator in Python

Postby Xanthir » Sun Aug 17, 2014 3:44 am UTC

A hash function works as long as you can divvy up the hash into chunks sufficient for your use, but it's not that convenient, and if you need more information than one hash result provides you've gotta twist things a bit to get more data.

Using a pseudo-random number generator and seeding it with your "tag" gives you the same outcome, but in an easier-to-consume way, and effectively infinite amounts of data per tag.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Mon Aug 18, 2014 2:33 am UTC

Thank you!

Xanthir wrote:A hash function works as long as you can divvy up the hash into chunks sufficient for your use, but it's not that convenient, and if you need more information than one hash result provides you've gotta twist things a bit to get more data.


Well, I think a hash is providing more than I need, if I do need more data (as per the "Judge" part of the code that would determine if a produced card is acceptable) I can just write the seed differently. Say, if "Batman" doesn't work, I tell the program to use "batman", and if that doesn't work, I tell it to use "BATMAN", etc.

I had to do something like this for manual generation of the cards, so that if after 6 rolls no card worked (total stats <120) I just went with the best one (highest total stats). I could tell the program to do this.

Is there a md5sum equivalent that returns decimal? Or would programming something that gets the hex hash, turns it into decimal and picks the last 25 digits from the card do the trick?

E.g. "Batman" returns cc72fc24056ced9ce13a287ca1243d48, which in decimal it's: 271759547003108890288895054575653109064.

The last 25 digits are: 8890288895054575653109064

The total (summing all the numbers) is: 125 (the card works)

So I just save this array (note, still no idea how this could be done in Python):

Batman card: Array [8,8,9,0,2,8,8,8,9,5,0,5,4,5,7,5,6,5,3,1,0,9,0,6,4]

And BAM! We got a Batman card!

And, yeah, the difference with this and random is noticeable. Do you see the 889 - 889 thing up there in the card? Batman would have 889 Velocity and 889 Contact.

That's the kind of thing I expect from a procedural generation of the card, as, that's just the kind of thing that you see when you produce the cards non-randomly from Pokémon stats.

From the previous incarnation, a player card looked like this:

Image

This is definitely not random. I.e. you can see there's sense and reason on this card (the card has a style, a "feeling", you can have some expectations about how this card would pitch and bat).

The card has meaning (if this was another Pokémon, the card would be different.)

This kind of effect seems to be replicated by hashes, so it looks like the solution I'm looking for! :)

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Mon Aug 18, 2014 2:46 am UTC

Well, odd, using MD5 online from this page:

http://onlinemd5.com/

Produces the string:

4A4566696CC81C6053EC708975767498

For Batman.

This produces:

98723217329725614397213493467943433368

Which is different from what Great Justice posted.

I was expecting MD5 to be universal :?

User avatar
phlip
Restorer of Worlds
Posts: 7550
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Programing a Baseball simulator in Python

Postby phlip » Mon Aug 18, 2014 4:05 am UTC

Great Justice was probably using some command-line tool:

Code: Select all

$ echo Batman | md5sum
cc72fc24056ced9ce13a287ca1243d48
This result is actually the hash of "Batman\n", with a bonus line feed on the end, due to the vagaries of how Unix-style pipelines traditionally send data around. If you do it without the trailing newline, then it agrees with your own result:

Code: Select all

$ echo -n Batman | md5sum
4a4566696cc81c6053ec708975767498


Vytron wrote:And, yeah, the difference with this and random is noticeable. Do you see the 889 - 889 thing up there in the card? Batman would have 889 Velocity and 889 Contact.

Well, it's still random... it's just a case of actual randomness not behaving the way humans usually expect it to happen. Coincidences occur, and clumping is normal. The classic example is flipping a coin repeatedly... if you flip a real coin, the chance that any two consecutive flips are the same is 50%, and you'll get runs of the same result from time to time. But if you tell someone to just write down a random sequence of heads and tails, then the pairs of consecutive "flips" tend to only match around 1/4 to 1/3 of the time, and you almost never get runs of the same result. It just doesn't "look random enough", and so you avoid it.

With that in mind... if you wanted to specifically avoid having these coincidences come up, then you could do so (and there are ways to do so without breaking the deterministic nature, so you'd still have a given name being turned into a specific set of stats in a repeatable way)... but it's worth keeping in mind that to do so is technically making it less random... though it would be potentially more fit-for-purpose.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

Volcano99
Posts: 56
Joined: Wed Dec 16, 2009 10:10 pm UTC
Location: 350 km SW of The Castle

Re: Programing a Baseball simulator in Python

Postby Volcano99 » Mon Aug 18, 2014 4:53 pm UTC

I made a thingy. You can save it as chargen.py and run it as a script or paste it directly into IDLE o any other python repl.
Spoiler:

Code: Select all

from __future__ import print_function
import random

class Character(object):
    def __init__(self, name):
        self.name = name
        self.generate_stats()

    def generate_stats(self):
        r = random.Random(self.name)
        for stat in "velocity control fielding attack power contact power speed defense".split():
            self.__dict__[stat] = tuple(r.randrange(10) for _ in range(3))
        self.energy = r.randrange(10)

    def __str__(self):
        return """
        Stats for card '{name}':
        Velocity: {velocity}    Contact: {contact}
        Control:  {control}    Power:   {power}
        Fielding: {fielding}    Speed:   {speed}
        Attack:   {attack}    Defense: {defense}
                    Energy: {energy}
        """.format(**self.__dict__)

    def __repr__(self):
        return 'Character("{name}")'.format(**self.__dict__)

def main():
    print("Hello! This is a really simple character generation demo.")
    print("Enter a character name, and you'll see the stats associated with the name.")
    print("Use Ctrl + C to exit (^C)")
    while True:
        name = input("name> ")
        print(Character(name))

if __name__ == "__main__":
    try:
        input = raw_input
    except NameError:
        pass

    try:
        import readline
    except:
        pass
    main()

For the ever present batman (on python 3.4.0, linux, 64 bit, monday), this code gives:

Code: Select all

name> batman

        Stats for card 'batman':
        Velocity: (2, 7, 5)    Contact: (1, 1, 6)
        Control:  (6, 2, 4)    Power:   (1, 0, 2)
        Fielding: (9, 0, 1)    Speed:   (0, 1, 5)
        Attack:   (9, 5, 1)    Defense: (9, 4, 6)
                    Energy: 4

It's really simple though, but you can see how using the same name across multiple PCs and sessions generates the same stats1.

1: results can vary across python versions, OS's, architecture, day of the week, amount of goats teleported by your browser and other variables. It is easily fixable, but wouldn't fit in 50 lines of code.

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Tue Aug 19, 2014 12:54 am UTC

Thanks Volcano99! Since that's the first working code for generation of the cards I think i can say that's the definitive version :)

You can save it as chargen.py and run it as a script or paste it directly into IDLE o any other python repl.


What is the meaning of this? I have no idea of how to run py files as a script, or what is IDLE, or what's a python repl.

I'd like to know how can I get a webpage to show some box where people enter player names and the thing returns a player card (at least to get a baseline working, since the plan would be for them to enter the player names on a website so the player card data is saved on the website - without my intervention). That's why I initially was going for php, but I assume people can interact with Python like they interact with the forum?

User avatar
Xenomortis
Not actually a special flower.
Posts: 1417
Joined: Thu Oct 11, 2012 8:47 am UTC

Re: Programing a Baseball simulator in Python

Postby Xenomortis » Tue Aug 19, 2014 9:18 am UTC

Vytron wrote:Thanks Volcano99! Since that's the first working code for generation of the cards I think i can say that's the definitive version :)

You can save it as chargen.py and run it as a script or paste it directly into IDLE o any other python repl.


What is the meaning of this? I have no idea of how to run py files as a script, or what is IDLE, or what's a python repl.


Python scripts are run by a python interpreter, you can download one here: https://www.python.org/download
IDLE is a small integrated development environment (IDE) that comes with python - it's intended for beginners. I've never used it, so cannot comment on it's worth (I chose to learn vim at the same time as python).

Vytron wrote:I'd like to know how can I get a webpage to show some box where people enter player names and the thing returns a player card (at least to get a baseline working, since the plan would be for them to enter the player names on a website so the player card data is saved on the website - without my intervention). That's why I initially was going for php, but I assume people can interact with Python like they interact with the forum?

Do you actually want a webpage you put online, or are you just interested in writing a program for this?
If the former, then php may have some merit - I understand it's easy to setup for that sort of thing. I also understand that php was designed by drunken monkeys and Satan.
However, you can still use Python in these cases; there are frameworks (Django?) that implement it. The basic idea is that your server executes the Python code and generates a resultant webpage that is shown to the user.

Edit:
Honestly, at this point, focus on getting a prototype together in Python and worry about web stuff later.
Start small and make your mistakes early.
Image

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Wed Aug 20, 2014 2:24 am UTC

Thanks Xenomortis.

Xenomortis wrote:Do you actually want a webpage you put online, or are you just interested in writing a program for this?


I guess I'd want a webpage, because otherwise getting working code for card generation would have been pointless (I already had random.org for generating the cards, and for a program I'd make I could have generated the cards manually and inserted the data manually into the program. The whole idea of having working code is so that players can generate their own cards without me being there, so that requires a webpage.)

Xenomortis wrote:If the former, then php may have some merit - I understand it's easy to setup for that sort of thing. I also understand that php was designed by drunken monkeys and Satan.


The reason I'm going Python is because Volcano99 has offered to help me and has helped me in Python. With PHP I'd be alone.

Xenomortis wrote:However, you can still use Python in these cases; there are frameworks (Django?) that implement it. The basic idea is that your server executes the Python code and generates a resultant webpage that is shown to the user.


I see, sounds good.

Xenomortis wrote:Edit:
Honestly, at this point, focus on getting a prototype together in Python and worry about web stuff later.


The thing here is I'd want to learn first how easy it is to have a working webpage in Python, or if it's actually difficult so doing it in PHP or Javascript would be easier. Because I'd want to avoid having to rewrite anything if it turns out Python on the web doesn't work or something.

Oh, hey, I haven't said the end result I'd be looking for, something like this:

http://www.simdynasty.com/boxscore.jsp? ... &cityid=23

(so at least I know this can be done in Javascript, I'd basically have to learn how to do it in Python)

So, yeah, if getting Python on the web is easy then I should start with that. That way, I can have working code that produces something and show the pages to Volcano99, so we work on it. After that is done it should be easy to add stuff to it. If getting Python on the web is hard and time consuming I'd be afraid to write stuff in it to begin with.

Xenomortis wrote:Start small and make your mistakes early.


Agreed. I'd then consider starting small as having a webpage where you insert a name and it comes up with a card.

Volcano99
Posts: 56
Joined: Wed Dec 16, 2009 10:10 pm UTC
Location: 350 km SW of The Castle

Re: Programing a Baseball simulator in Python

Postby Volcano99 » Wed Aug 20, 2014 8:02 am UTC

Vytron wrote:I'd then consider starting small as having a webpage where you insert a name and it comes up with a card.

Note: just a really crude python webserver demo!
http://baseball-pxndx.rhcloud.com/

Now you just need to make it pretty! Anyone with HTML/CSS/JS superpowers? I just know the basics...

source:

Spoiler:
It's actually shorter than the non-web version!

Code: Select all

from __future__ import print_function
import bottle
import random

app = bottle.Bottle()

class Character(object):
    def __init__(self, name):
        self.name = name
        self.generate_stats()

    def generate_stats(self):
        r = random.Random(self.name)
        for stat in "velocity control fielding attack power contact power speed defense".split():
            self.__dict__[stat] = tuple(r.randrange(10) for _ in range(3))
        self.energy = r.randrange(10)

    def __str__(self):
        return """
        Stats for card '{name}':
        Velocity: {velocity}    Contact: {contact}
        Control:  {control}    Power:   {power}
        Fielding: {fielding}    Speed:   {speed}
        Attack:   {attack}    Defense: {defense}
                    Energy: {energy}
        """.format(**self.__dict__)

    def __repr__(self):
        return 'Character("{name}")'.format(**self.__dict__)

@app.route("/<name>")
def chargen(name):
    return str(Character(name))

@app.route("/")
def index():
    return "hello! go to /<name> to see a card!"

def main():
    app.run(host='0.0.0.0', port=80)

if __name__ == "__main__":
    main()

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Sat Aug 23, 2014 9:18 am UTC

Thanks, that's very nice volcano! :)

Yeah, it's cool that one can get any card generated for any name by just changing the URL.

Volcano99 wrote:Now you just need to make it pretty! Anyone with HTML/CSS/JS superpowers? I just know the basics...


Nah, I'd think it'd be best to have a generator of games ready and worry about making it pretty till the very end :wink:

I guess next would be, matching the cards, I'm so glad you have the Python server running already, so we could start by something simple.

There's the batman card and there's the sylveon card.

So the very next step would be to have batman be the pitcher, and sylveon the batter, so when you match them somehow, you get a result of 2 and 1 (the 2 comes from the first velocity number of the pitcher, the 1 comes from the first contact number of the batter - so for any two input names it could show the first Velocity number of the first name, followed by the first contact number of the second name.)

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator in Python

Postby Vytron » Sat Aug 23, 2014 9:20 am UTC

(or maybe just 21, we could have an output that multiplies the first name's 1st velocity by 10, and sums it with the second's name 1st contact, and there we go, batman+sylveon=21)

User avatar
Vytron
Posts: 429
Joined: Mon Oct 19, 2009 10:11 am UTC
Location: The Outside. I use She/He/Her/His/Him as gender neutral pronouns :P

Re: Programing a Baseball simulator (Cancelled)

Postby Vytron » Mon Sep 08, 2014 8:58 pm UTC

Well, today is the day I start my Baseball league, and since I only have code for the generation of the cards, I'm going to just use that and cancel the rest of the project. Or, postpone it.

Thanks everyone for your help, and Volcano99 for all your coding! Let's see how the league goes with manual generation of games, I've settled in to not expect any player participation, so I'll be happy with whatever I get :wink:


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 6 guests