-
Notifications
You must be signed in to change notification settings - Fork 0
/
TODO
53 lines (48 loc) · 2.91 KB
/
TODO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Improvements
============
- Instead of arbitrarily placing the first longest line when starting, instead decide which would be best in some way.
- Oldest player goes first in the event of a tie in starting length is not implemented. Instead it is random.
- We are currently very trusting of Player that he has the tiles he says he has. We should separate out the strategy and the admin.
- Algorithm just maximizes points for now, very naive. Need to look at giving away good scoring opportunities, changing tiles, dumping dupes and keeping potentially good tiles as well at least.
- When the computer changes letters it should be strategic about it.
- Don't pass board around inside board at all. Just clone it where necessary.
- Board->score uses applyWithoutChecks rather than apply. Why are we scoring something that might be illegal? Can we speed up by cutting it earlier?
- Do you return to the bag then draw? Or set aside and then draw?
- interface or superclass for Line and Hand?
- Board->isLegal doesn't check the following things (it relies on Player->move?)
* Must have a placement on an adjoining square
* Mustn't overlay a tile
* All lines formed must be legal
- A "show thinking" flag that shows the board of every legal move considered.
// echo "For $direction $i $point ($tilesHand) ...\n";
// echo "Considering move: " . end($moves) . " with a score of " . $board->score(end($moves)) . "\n";
// $displayBoard = clone $board;
// $displayBoard->applyWithoutChecks(end($moves));
// echo $displayBoard;
// echo "----------\n";
// fgets(STDIN);
- Some way to treat colors and shapes as "properties" generally when looking for shared property.
- When we introduced the performance improvement of not checking all orderings once a legal move was found we radically changed the outcome of TestGames::FIRST. This implies that the order you place your move in from amongst the available legal moves is important to the outcome. Leaving less opportunity for others and more for yourself should be a consideration of the AI.
- Can we do something like tryFit for isLegal? Start at the attachment location and work outwards and reject sooner if possible?
Performance
===========
time php -f qwirkle.php >/dev/null
$players = [
new Player('Qwirky'),
new Player('Kwirkster'),
new Player('Mr. Three'),
new CautiousPlayer('Cautious Player')
];
$game = new Game($players, unserialize(TestGames::FIRST));
$game->go();
exit;
- Initial timing = 48s
- After quickCheckLocation = 28s
- After cache locations in board and update on apply = 20s
- Add a lot of timng calls = 28s
- After cache locations AND shared properties in board and updated on apply = 14s
- Moving isLegal check into permutations = 13s
- Break out of orderings loop when we find a legal move = 12s
- Remove Timer calls = 9s
- Only update locations when calling apply not all applyWithoutChecks = 5s
- tryFit for 3+ tiles to avoid checking endless illegal options = 4.2s