|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
[appleeaters]Player coordinate problems
I run through possible scenarios to determine the best course of action at times ...
php Code:
The problem with this is that the actual player coordinates are altered. That shouldn't happen, should it? I tracked it down to a line like I modified my robotslib.php to generate a new $game array with each call, so no matter what you do to it, the array won't be modified by the robot. I posted it on my PHP contest page (only up for the length of the contest) at http://rumkin.com/reference/php_contest/ in case someone else has this problem. Is this the best solution, or are there alternatives out there? |
|
#2
|
|||
|
|||
|
[appleeaters]RE: Player coordinate problems
Tyler, I spent three hours on Monday trying to figure that out.
This line: *Should* make a deep copy of every element in $game. But as you (and I) discovered, it doesn't, if an element in $game is a reference, then the corresponding element in $testGame points to the same value (not a copy). So then changing that value in $testGame will also change it in $game. This is a bug in PHP: http://bugs.php.net/bug.php?id=20993 The only workaround I've found to force a deep copy is: Which is sloww :-( Another workaround would be to change the players location, determine the score for that lcoation, and then move it back. Hmm.. that might be better than serilaize(); I would like if line 70 in robotslib.php would be changed to: (ie, no & symbol) That would speed up my algorithm. But if that can't be guranteed, then I think I'm going to have to abandon my recursive-score technique for something simpler and quicker. I hope that helps. Chris B (chris@mretc.net) |
|
#3
|
|||
|
|||
|
[appleeaters]RE: Player coordinate problems
You can use ...
and then you could just use the 'player_test' index instead of 'player'. Or, you could pass the new X and Y of the player to your test function. Or, you could use my modified robotslib.php -- still faster than even the newest version posted today! :-) http://rumkin.com/reference/php_contest/ |
|
#4
|
|||
|
|||
|
[appleeaters]RE: Player coordinate problems
Is fidian's improvement likely to be in the final library? I have a similar approach and it's a pain that the new library doesn't like it. I've been using fidian's but would obviously like to know if I can do that in the real thing!
thanks |
![]() |
| Viewing: Codewalkers Forums > PHP Contests > Older Contests > [appleeaters]Player coordinate problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|