diff options
| author | lonkaars <l.leblansch@gmail.com> | 2021-02-26 11:16:17 +0100 | 
|---|---|---|
| committer | lonkaars <l.leblansch@gmail.com> | 2021-02-26 11:16:17 +0100 | 
| commit | 16983d110e90972ceed4ca6d65473d038c9cb854 (patch) | |
| tree | 6518252492f186186b1446cb85f65fd60609c980 /voerbak/diewertje.c | |
| parent | 4979a5ec8b88f7a385b7ec6ed5a26bbcfe4ff7f3 (diff) | |
diewertje beginnings
Diffstat (limited to 'voerbak/diewertje.c')
| -rw-r--r-- | voerbak/diewertje.c | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/voerbak/diewertje.c b/voerbak/diewertje.c index 6290b5c..a0016fa 100644 --- a/voerbak/diewertje.c +++ b/voerbak/diewertje.c @@ -1,9 +1,34 @@  #include <stdio.h> +#include <memory.h>  #include "board.h" +#include "win.h"  #include "voerbak.h"  int diewertje(Board *b) { +	int pre_verbosity = verbosity;  	verbosity >= 2 && printf("Got a diewertje request, from a board that's %dx%d\n", b->width, b->height); +	 +	int outcome[b->width]; + +	verbosity = -1; +	Board *copy = createCopy(b); +	for (int c = 0; c < b->width; c++) { +		int drop = dropFisje(copy, c, 1); + +		printBoard(copy); + +		outcome[c] = drop == -1 ? 0 : checkWin(copy, drop); +		if(drop != -1) copy->board[drop] = 0; // remove disc from copy +	} +	verbosity = pre_verbosity; + +	printf("["); +	for(int i = 0; i < b->width; i++) { +		printf(i + 1 == b->width ? "%d" : "%d, ", outcome[i]); +	} +	printf("]\n"); +  	return 2;  } + |