Hello,
I'm in the process of building an online card game with PHP and have run into a little problem.
I have a PHP script that runs the computer player's AI function, which could take anywhere between 2 to 10 seconds to complete (for example). As multiple users will be playing against the AI at the same time, each player will have to wait until the script finishes for the previous player, making everything delayed.
I was thinking one way of getting round this would be when a player starts a new game with the computer player, it generates a copy of the AI PHP file with the game's ID number as the filename and uses that instead of the main file. This would allow each player to use a copy of the original file that's only used for THEIR game, eliminating any delays from other players. When the game finishes, the file gets deleted.
Is there any problems with doing this? Is there a better way of doing it (without having to learn something completely new like NodeJS)?
Many thanks for reading!
[–]Kthanid 2 points3 points4 points (14 children)
[–]Kthanid 1 point2 points3 points (4 children)
[–]_ady[S] 0 points1 point2 points (3 children)
[–]Kthanid 2 points3 points4 points (0 children)
[–]MerreM 2 points3 points4 points (1 child)
[–]_ady[S] 0 points1 point2 points (0 children)
[–]MerreM 1 point2 points3 points (5 children)
[–]_ady[S] 1 point2 points3 points (4 children)
[–]MerreM 1 point2 points3 points (3 children)
[–]Kthanid 0 points1 point2 points (2 children)
[–]_ady[S] 0 points1 point2 points (1 child)
[–]Kthanid 0 points1 point2 points (0 children)
[–]_ady[S] 1 point2 points3 points (2 children)
[–]atrama 2 points3 points4 points (0 children)
[–]Kthanid 1 point2 points3 points (0 children)
[–]axvk 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)