Skip to content

Commit

Permalink
Merge pull request #2 from banan314/smart-view
Browse files Browse the repository at this point in the history
dolar 1.2
  • Loading branch information
banan314 authored Oct 20, 2017
2 parents 1c5f290 + 3554f99 commit f1e1254
Show file tree
Hide file tree
Showing 69 changed files with 2,824 additions and 432 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ src/test/scala/
src/main/other/*

/laughing-engine.iml
/word count.sh
1 change: 0 additions & 1 deletion games/games/dolar/dolar.kif
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
(init (step 1))

(init(cell 1 1 white))
(init(cell 1 1 empty))
(init(cell 1 2 empty))
(init(cell 1 3 empty))
(init(cell 1 4 empty))
Expand Down
3 changes: 3 additions & 0 deletions games/games/dolar/scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/out
/.vscode
.vstags
6 changes: 6 additions & 0 deletions games/games/dolar/scripts/configuration.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[role]
player1 = white
player2 = black

[game]
maxIndex = 9
3 changes: 3 additions & 0 deletions games/games/dolar/scripts/count
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
perl count.pl white > out/count/white
perl count.pl black > out/count/black

59 changes: 59 additions & 0 deletions games/games/dolar/scripts/count.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use warnings;

use feature 'say';

my $player = shift;

my $min;
my $max;

if ($player eq "black") {
$min = 1; $max = 4;
} elsif ($player eq "white") {
$min = 6; $max=9;
} else {
die "wrong input! white or black";
}

sub nextSquare {
my ($x, $y) = @_;
if ($x == $max) {
$x = $min;
$y++;
} else {
$x++;
}
return ($x, $y);
}

sub lastSquare {
($x, $y) = @_;
return $x==$max && $y==$max;
}

sub buildCount {
($x, $y) = @_;
my @nextCoordinates = nextSquare($x, $y);

my $def = "<= (count $x $y ?num)";
my $checkCell = "(true (cell $x $y $player))";
my $succ = "\t(succ ?prevnum ?num)";
my $next = "\t(count $nextCoordinates[0] $nextCoordinates[1] ?prevnum)";

if (lastSquare($x, $y)) {
return join "\n", ("("."<= (count $x $y 1)", "\t(true (cell $max $max $player))".")", "",
"("."<= (count $x $y 0)", "\t(not (true (cell $max $max $player)))".")");
} else {
my $pieceProp = join "\n", ("(".$def, "\t$checkCell", $succ, $next.")");
$next =~ s/prevnum/num/; #replace prevnum with num, cause we don't increment
my $emptyProp = join "\n", ("(".$def, "\t(not ". $checkCell . ")", $next.")");
return join "\n", ($pieceProp, $emptyProp);
}
}

my ($x, $y) = ($min, $min);
do {
say buildCount($x, $y) . "\n";
($x, $y) = nextSquare($x, $y);
}until lastSquare($x, $y);
say buildCount($x, $y) . "\n";
Loading

0 comments on commit f1e1254

Please sign in to comment.