Author Topic: Want Play By Play (Help)  (Read 1734 times)

Offline lindhsky

  • Level 6
  • *
  • Posts: 26
  • Reputation: +0/-0
    • View Profile
Want Play By Play (Help)
« on: January 22, 2010, 09:39:21 AM »
Hello,

I am working on a hockey browser game and the game-engine is almost done, but one thing I want is a feature that allows the players to watch a game by watching a clock ticking up/or down while my game gets info from a DB and puts it on the screen for them. So my game-engine simulates the games and then afterwards the coaches(players) can watch the games in the browser with simple comments from a DB. If there is a goal at minute 5 for an example, then the clock should tick 1, 2, 3, 4, 5 and then show the goal-comments. Is this possible in PHP and if so what should I look up? Or do I need to learn java, flash or something else?

I am lousy at describing things like this in english, but I hope you understand. :)
« Last Edit: January 22, 2010, 09:41:25 AM by lindhsky »

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: Want Play By Play (Help)
« Reply #1 on: January 22, 2010, 10:01:05 AM »
Since the result of the game is pre-determined, you would pass the entire result to the browser then you would utilize JavaScript to create the timed release of the data to the user. Also, with a feature like this, you should probably allow a "skip animation" option for players, like myself, who would find it irritating.
Idiocy - Never underestimate the power of stupid people in large groups.


Offline lindhsky

  • Level 6
  • *
  • Posts: 26
  • Reputation: +0/-0
    • View Profile
Re: Want Play By Play (Help)
« Reply #2 on: January 22, 2010, 10:13:25 AM »
Thanks!

Ok, I'll look that up.

I'll give the players a chance to just watch the boxscore or playbyplay in one big text with statistics, but I just wanted something that allows players that likes that kind of excitement to have a chance to watch the game while a clock is running down. I am in a football league that has a feature like that and I like it, but I also know a lot of managers that just click on the result. :)

Offline saljutin

  • Level 22
  • *
  • Posts: 266
  • Reputation: +6/-0
    • View Profile
Re: Want Play By Play (Help)
« Reply #3 on: January 22, 2010, 11:15:36 AM »
yes I would agree with JGadrow: 1st read everything needed from DB and write into JS array or something then use JS counter to show minute to minute play :)
One more question ... did you simulate any game already? Try stress test and simulate 1000 or 10000 games and calculate time (using PHP) your script needs to simulate such amount of games and then check in DB and see how much KBs is such amount of games.
Some sport sim game I was doing some optimization on it had problems because 200-220 rows were inserted for each game :)

Offline lindhsky

  • Level 6
  • *
  • Posts: 26
  • Reputation: +0/-0
    • View Profile
Re: Want Play By Play (Help)
« Reply #4 on: January 22, 2010, 12:04:46 PM »
I have simulated games but at the moment I am not saving anything to the DB, I just print out text and stats in the browser to see that everything is working as intended. I'll not save everything that happens in the game, just the big highlights (fights, damaging hits, shots and penalties). The plan is not to save too much just enough to make it exciting to watch and a chance for the coaches to get to know their players on their team a little bit more. Not sure what I'll do with the shots though because in hockey sometimes you have 60+ shots and added together with the rest it might get too much.

Offline saljutin

  • Level 22
  • *
  • Posts: 266
  • Reputation: +6/-0
    • View Profile
Re: Want Play By Play (Help)
« Reply #5 on: January 22, 2010, 12:41:00 PM »
Parsing is good IMO
lets say you have events: fight 1, shoot 2, goal 3
1-A-B = would mean fight between players A and B
2-A = would mean shot by player A
3-A = would mean goal by player B

so these events together are 1-A-B#2-A#3-A#
every event finishes by # so when you parse you explode 1st by # then explode by - and then have some switch 1,2,3 which tells you which event there is and it outputs it :)
so its easy to save into DB, only 1 row per match, I already have similar (more advanced) engine done for my sport game (not hockey ;)) but dont have time and motivation to finish it :) and also some things with economy and competition type

Offline lindhsky

  • Level 6
  • *
  • Posts: 26
  • Reputation: +0/-0
    • View Profile
Re: Want Play By Play (Help)
« Reply #6 on: January 22, 2010, 01:17:17 PM »
Hmm, interesting! Thanks, I think I'll try that out. :)

Offline bbgames

  • Level 16
  • *
  • Posts: 138
  • Reputation: +1/-0
    • View Profile
    • Building Browsergames
Re: Want Play By Play (Help)
« Reply #7 on: January 22, 2010, 02:15:59 PM »
I've got a game that's getting close to closed beta that does something like this for combat - as saljutin describes, it's really easy to start running up your rowcount to the point where you can't run enough simulations to support your users.

One of the ways that I've worked around this has been to use JSON (Python's got a really nice JSON library), storing the entire fight inside an array - when I write it into the database, I just create the one row which has all of my serialized data inside of it. When it comes time to display it, I load it back up and I'm good to go.

Your mileage may vary, but switching to JSON dumps of entire fights instead of a row for each round made a pretty big impact on my project.

Offline dbest

  • Game Owner
  • Level 20
  • *
  • Posts: 211
  • Reputation: +3/-0
    • View Profile
    • Tennis Masters
Re: Want Play By Play (Help)
« Reply #8 on: September 19, 2010, 12:35:33 AM »
Since the result of the game is pre-determined, you would pass the entire result to the browser then you would utilize JavaScript to create the timed release of the data to the user. Also, with a feature like this, you should probably allow a "skip animation" option for players, like myself, who would find it irritating.

Reviving an old topic, but.. if the entire result is passed to the browser, would not the player be able to view the result in the page source?

I was thinking of implementing the "play-by-play" feature in my tennis game, and I cannot seem to figure out a nice implementation.

I have the commentary stored in a serialized format in the database, when the page is first loaded, the commentary is fetched and expanded. Where can I store this new commentary array, so that a) it is not sent in its entirety to the browser and b) I do not have to make a call to the db again to fetch the same?


Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: Want Play By Play (Help)
« Reply #9 on: September 19, 2010, 02:37:31 AM »
Since the result of the game is pre-determined, you would pass the entire result to the browser then you would utilize JavaScript to create the timed release of the data to the user. Also, with a feature like this, you should probably allow a "skip animation" option for players, like myself, who would find it irritating.

Reviving an old topic, but.. if the entire result is passed to the browser, would not the player be able to view the result in the page source?

Yes. Would that be a problem?

Offline dbest

  • Game Owner
  • Level 20
  • *
  • Posts: 211
  • Reputation: +3/-0
    • View Profile
    • Tennis Masters
Re: Want Play By Play (Help)
« Reply #10 on: September 19, 2010, 03:38:18 AM »
Well, then the result would be viewed by the user.

I am part of two games now, where the entire commentary is not in the source.. just what is showed to the user.

Offline Nox

  • Level 35
  • **
  • Posts: 768
  • Reputation: +12/-2
    • View Profile
Re: Want Play By Play (Help)
« Reply #11 on: September 19, 2010, 03:55:25 AM »
I thought about this too in past and "no" - player would get result only, he would be given only what we could see - in other words: send only and only presentation data (no calculations, just raw numbers, no path to actions, just actions themselves etc.)

Quote
If there is a goal at minute 5 for an example, then the clock should tick 1, 2, 3, 4, 5 and then show the goal-comments.
Would become something like
Code: [Select]
var game = [
   ["Player Foo scored goal! Score is currently 0:1", 5],
   ["Player Bar injured player Foo", 7]/* ,
   ... */
];
you can't derive anything from that
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: Want Play By Play (Help)
« Reply #12 on: September 19, 2010, 04:27:56 AM »
Well, then the result would be viewed by the user.


Isn't that the whole point? :/ Showing the user the result of a game, battle, ...

Offline dbest

  • Game Owner
  • Level 20
  • *
  • Posts: 211
  • Reputation: +3/-0
    • View Profile
    • Tennis Masters
Re: Want Play By Play (Help)
« Reply #13 on: September 19, 2010, 06:18:34 AM »
Well, then the result would be viewed by the user.


Isn't that the whole point? :/ Showing the user the result of a game, battle, ...

Yeah but rather than showing the entire game, I would like to show it as if it was streaming live.
So in the first 50 seconds, we have the first few lines of commentary..
next 50 seconds, additional lines are added...


@NOX: would be great if you could elaborate a bit more..please

Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: Want Play By Play (Help)
« Reply #14 on: September 19, 2010, 06:32:26 AM »
Well, then the result would be viewed by the user.


Isn't that the whole point? :/ Showing the user the result of a game, battle, ...

Yeah but rather than showing the entire game, I would like to show it as if it was streaming live.
So in the first 50 seconds, we have the first few lines of commentary..
next 50 seconds, additional lines are added...

Well, if the player is so desperate to look at the source code, wouldn't you think something is wrong then? Like JGadrow mentioned before you should really implement a "skip" button. I find it hard to explain because I don't see the problem, it's as if your just making extra problems where there are none.

It's obvious that as Nox says you don't send important information like equations etc to your browser. You calculate the result at the server, send it to the browser and use javascript to show it line by line or show it all if the user clicks the "skip" button. If you really don't want them to see it in the source code before they're supposed to I guess you could have a series of Ajax calls and keep track of the time passed on server side but as far as I am concerned that's a resource / performance killer -- you only do that if it's really necessary but I can't come up with a scenario where it would be useful.

Offline Nox

  • Level 35
  • **
  • Posts: 768
  • Reputation: +12/-2
    • View Profile
Re: Want Play By Play (Help)
« Reply #15 on: September 19, 2010, 06:47:37 AM »
Maybe I misunderstood the issue, but... in this case you don't even need AJAX

1) Load your serialized comments, convert to array
2) Calculate combat, store certain comments with time of occurence in array
3) Dump into JS by json_encode AND/OR store serialized as a replay of certain match
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

Offline dsheroh

  • Level 21
  • *
  • Posts: 235
  • Reputation: +6/-0
  • Perl Vicar
    • View Profile
    • Psi Rangers
Re: Want Play By Play (Help)
« Reply #16 on: September 19, 2010, 07:59:10 AM »
Maybe I misunderstood the issue, but... in this case you don't even need AJAX

dbest seems to be worried about players looking at the page source to find out how the game ends without first sitting through the entire play-by-play, which does need either AJAX or some form of streaming/server-push so that the result won't be present on the client machine until the play-by-play is complete.

But, as has already been said:

1) There should be a 'skip animation' button so that users don't have to sit through the play-by-play.  (Like JGadrow, if there wasn't a 'skip animation' button, I either would not play the game or I would open the page, then go do something else while the play-by-play ran and probably not get back to the game for at least half an hour to an hour.  So much for being engaged with it.)

2) If there's a 'skip animation' button which allows users to immediately see the results, then it doesn't matter if they can immediately see the results in the page source.

Offline dbest

  • Game Owner
  • Level 20
  • *
  • Posts: 211
  • Reputation: +3/-0
    • View Profile
    • Tennis Masters
Re: Want Play By Play (Help)
« Reply #17 on: September 19, 2010, 09:37:04 AM »
While the skip animation button might be needed, as I mentioned, most sports based games with huge following (players), just enjoy this sorta stuff. I can name battrick.org, fromthepavilion.org and gpro.se... players sit till the end of the commentary/race. Those are my targets..

I understand that such a feature might not attract loads of players, but it does have a market.

Thanks for helping out, however. :)

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: Want Play By Play (Help)
« Reply #18 on: September 19, 2010, 10:07:20 AM »
I'm coming into this discussion late (ironic since it was my original comment that sparked it) but the original solution I offered was the best of both worlds. You calculate and send the result to the user. Then, your javascript can do the timed events that some of your audience seems to enjoy. However, by allowing a user to skip the animation process, you're allowing your "core" audience the feature they want but you're doing it without alienating other players who may not like that functionality.
Idiocy - Never underestimate the power of stupid people in large groups.


Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Want Play By Play (Help)
« Reply #19 on: September 19, 2010, 11:15:12 AM »
I cannot say for certain how the other games do it but if you wanted to stream your results to your players I would do something like the following:

* Create events for the game
* Store said events into an array with a time stamp of when to display the result and the corresponding result
* Store that array in the players session data
* With AJAX or even a meta refresh poll that session data look for the time stamp that has expired and display that result.
* Remove displayed result from array

This system works only if it's the one player that gets to see the results of the game. If multiple players can see the results then it would need to be stored in database. The same idea would hold true except store it into a results table rather then the session. Hopefully its just the one player that sees the results that way it won't be a huge strain on database.

Hope that helps :)
Creating online addictions, one game at a time:

Offline dbest

  • Game Owner
  • Level 20
  • *
  • Posts: 211
  • Reputation: +3/-0
    • View Profile
    • Tennis Masters
Re: Want Play By Play (Help)
« Reply #20 on: September 20, 2010, 12:01:58 AM »
Thanks for explaining it like that, codestryke.

Since matches might be viewed by at least 2 users at a time, I might have to implement it, with the db.

What if I still store the results in each users' sessions. It could still work out? I will implement this and get back to you guys.
Thanks to all. You have been wonderful as usual.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal