[Pachi] wfm foreach but last was: 2 queries

jonathan chetwynd j.chetwynd at btconnect.com
Thu Jun 2 22:45:04 CEST 2011


only the first instance fails as f=0 and the , precedes each other instance.

nice!

		foreach_point(t->board) {
			if (board_at(t->board, c) != S_NONE) continue;
			floating_t rate = (floating_t) u->ownermap.map[c][S_BLACK] / u->ownermap.playouts;
 			fprintf(stderr, "%.0f", 1000*rate); 
			fprintf(stderr, "%s", f++ > 0 ? "," : ""); /* Please edit to prevent comma on last iteration */
		} foreach_point_end;\

~:"

still need Query 1 debug info


  	
Jonathan Chetwynd

j.chetwynd at btconnect.com
http://www.peepo.com/

+44 (0) 20 7978 1764


On 2 Jun 2011, at 12:57, jonathan chetwynd wrote:

> How to switch debug so that the only output is JSON? [1]
> 
> How to insert comma in all but last foreach loop? [2] 
> 
> best
> 
> Jonathan
> 
> [1] ie remove:
> 
> tree pruned in 0.242646 s, prev 0 s ago, dest depth 16 wanted 4, size 204597008->99756184/295279001, playouts 38867
> playing move F6
> Move:   1  Komi: 0.0  Handicap: 0  Captures B: 0 W: 0
>      A B C D E F G H J        A B C D E F G H J  
>    +-------------------+    +-------------------+
>  9 | . . . . . . . . . |  9 | , , , , , , , , , |
>  8 | . . . . . . . . . |  8 | , , , , x , , , , |
>  7 | . . . . . . . . . |  7 | , , , , x x , , , |
>  6 | . . . . . X). . . |  6 | , , , , , x , , , |
>  5 | . . . . . . . . . |  5 | , , , , , , , , , |
>  4 | . . . . . . . . . |  4 | , , , , , , , , , |
>  3 | . . . . . . . . . |  3 | , , , , , , , , , |
>  2 | . . . . . . . . . |  2 | , , , , , , , , , |
>  1 | . . . . . . . . . |  1 | , , , , , , , , , |
>    +-------------------+    +-------------------+
> 
> = F6
> 
> [2]
> 
> 		foreach_point(t->board) {
> 			if (board_at(t->board, c) != S_NONE) continue;
> 			floating_t rate = (floating_t) u->ownermap.map[c][S_BLACK] / u->ownermap.playouts;
> 			fprintf(stderr, "%.0f", 1000*rate); 
> 			fprintf(stderr, "%s", 1 ? "," : ""); /* Please edit to prevent comma on last iteration */
> 		} foreach_point_end;
> 
> advice I found is not to use foreach, particulary in this use-case
> 
> _______________________________________________
> Pachi mailing list
> Pachi at v.or.cz
> http://rover.ms.mff.cuni.cz/mailman/listinfo/pachi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rover.ms.mff.cuni.cz/pipermail/pachi/attachments/20110602/b3ea1051/attachment.html>


More information about the Pachi mailing list