* [9front] games/mines: do not put a mine to the first clicked tile, add a cool option
@ 2021-07-10 23:11 kemal
2021-07-11 11:07 ` Philip Silva
2021-07-11 16:31 ` [9front] " kemal
0 siblings, 2 replies; 4+ messages in thread
From: kemal @ 2021-07-10 23:11 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 240 bytes --]
player has no way of knowing if the first clicked tile is a mine,
so don't put a mine there. in addition the og game and other
clones also do this. also do some style changes and renew
the prng seed more often.
(also a cool option hehehe)
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 5154 bytes --]
From: kemal <kemalinanc8@gmail.com>
Date: Sat, 10 Jul 2021 23:05:34 +0000
Subject: [PATCH] games/mines: do not put a mine to the first clicked tile, add a cool option
(thanks ori for giving me the idea for -f)
---
diff 2f8a59f4b5bfe028c022855acc19666d69eed909 b2fb9c95b569e3d8c4e0a004a11e9f4a8e0190ed
--- a/sys/man/1/mines Fri Jul 9 00:35:34 2021
+++ b/sys/man/1/mines Sun Jul 11 02:05:34 2021
@@ -4,7 +4,7 @@
.SH SYNOPSIS
.B games/mines
[
-.B -aeqg
+.B -aefgq
]
.SH DESCRIPTION
.I Mines
@@ -46,11 +46,16 @@
.B -e
Start at expert difficulty.
.TP
-.B -q
-Disable the query marker.
+.B -f
+It t-
+.I ahem
+I mean it makes the game faster the solve.
.TP
.B -g
It's a secret to everybody.
+.TP
+.B -q
+Disable the query marker.
.SH SOURCE
.B /sys/src/games/mines
.SH HISTORY
--- a/sys/src/games/mines/dat.h Fri Jul 9 00:35:34 2021
+++ b/sys/src/games/mines/dat.h Sun Jul 11 02:05:34 2021
@@ -23,15 +23,15 @@
};
enum {
- Empty0 = 0,
- Empty1 = 1,
- Empty2 = 2,
- Empty3 = 3,
- Empty4 = 4,
- Empty5 = 5,
- Empty6 = 6,
- Empty7 = 7,
- Empty8 = 8,
+ Empty0,
+ Empty1,
+ Empty2,
+ Empty3,
+ Empty4,
+ Empty5,
+ Empty6,
+ Empty7,
+ Empty8,
Query,
MouseQuery,
Mark,
--- a/sys/src/games/mines/mines.c Fri Jul 9 00:35:34 2021
+++ b/sys/src/games/mines/mines.c Sun Jul 11 02:05:34 2021
@@ -10,7 +10,7 @@
int MaxX, MaxY, Mines;
} Settings[] = { {8, 8, 10}, {16, 16, 40}, {30, 16, 99}, {0, 0, 0} };
-int MaxX, MaxY, Mines, Level, UnknownCell, Playing, MinesRemain, Time, Status, UseQuery = TRUE, UseGhost = FALSE, UseColor = TRUE;
+int MaxX, MaxY, Mines, Level, UnknownCell, Playing, MinesRemain, Time, Status, UseQuery = TRUE, UseGhost = FALSE, Trololo = FALSE, UseColor = TRUE;
Point Origin;
Mouse LastMouse;
@@ -159,21 +159,45 @@
}
void InitMineField(void) {
+ int x, y;
+ /* clean up mine field, make all cells unknown */
- /* clean up mine field, make all cells unknown and place new mines */
- {
- int i, x, y;
+ for(y = 0; y < MaxY; y++)
+ for(x = 0; x < MaxX; x++) {
+ MineField[x][y].Mine = FALSE;
+ MineField[x][y].Picture = Unknown;
+ }
- for(y = 0; y < MaxY; y++)
- for(x = 0; x < MaxX; x++) {
- MineField[x][y].Mine = FALSE;
- MineField[x][y].Picture = Unknown;
- }
+ /* reset status, remaining mines etc. */
+ Status = Game;
+ Playing = FALSE;
+ MinesRemain = Mines;
+ Time = 0;
+ UnknownCell = MaxX * MaxY - Mines;
+}
- for(i = 0; i < Mines; ) {
+void GenMines(int fcx, int fcy) {
+ srand(time(0));
+ /* plant mines */
+ {
+ int i = 0, x, y;
+
+ /*
+ * this option just trolls the user by increasing
+ * the chance of a mine in the first click from %0 to %90
+ */
+ if(Trololo){
+ i = nrand(9);
+ if(i){
+ MineField[fcx][fcy].Mine = TRUE;
+ i = 1;
+ }
+ }
+ while(i < Mines) {
x = nrand(MaxX);
y = nrand(MaxY);
if(MineField[x][y].Mine) continue;
+ if(x == fcx && y == fcy) continue;
MineField[x][y].Mine = TRUE;
i++;
}
@@ -196,12 +220,6 @@
if(x < MaxX - 1 && y < MaxY - 1 && MineField[x + 1][y + 1].Mine) MineField[x][y].Neighbours++;
}
}
-
- Status = Game;
- Playing = FALSE;
- MinesRemain = Mines;
- Time = 0;
- UnknownCell = MaxX * MaxY - Mines;
}
void NewMineField(int NewLevel) {
@@ -284,12 +302,17 @@
}
void LeftClick(Point Cell) {
+
+ int FirstClick;
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
+ if(Status != Game || Cell.x < 0 || Cell.y < 0) return;
+ FirstClick = !Playing;
Playing = TRUE;
switch(MineField[Cell.x][Cell.y].Picture) {
case Query:
case Unknown:
+ if(FirstClick)
+ GenMines(Cell.x, Cell.y);
if(MineField[Cell.x][Cell.y].Mine) {
MineField[Cell.x][Cell.y].Picture = Explosion;
DrawCell(Cell);
@@ -320,7 +343,7 @@
int Neighbours = 0;
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
+ if(Status != Game || Cell.x < 0 || Cell.y < 0) return;
Playing = TRUE;
switch(MineField[Cell.x][Cell.y].Picture) {
case Empty1:
@@ -359,9 +382,7 @@
void RightClick(Point Cell) {
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
-
- Playing = TRUE;
+ if(Status != Game || Playing != TRUE || Cell.x < 0 || Cell.y < 0) return;
switch(MineField[Cell.x][Cell.y].Picture) {
case Unknown:
MineField[Cell.x][Cell.y].Picture = Mark;
@@ -381,7 +402,7 @@
void Usage(void) {
- fprint(2, "Usage: %s [-aeq]\n", argv0);
+ fprint(2, "Usage: %s [-aefgq]\n", argv0);
exits("usage");
}
@@ -392,8 +413,9 @@
ARGBEGIN {
case 'a': Level = Advanced; break;
case 'e': Level = Expert; break;
- case 'q': UseQuery = FALSE; break;
+ case 'f': Trololo = TRUE; break;
case 'g': UseGhost = TRUE; break;
+ case 'q': UseQuery = FALSE; break;
default:
Usage();
} ARGEND
@@ -518,8 +540,6 @@
ImageCell[Fault] = allocimage(display, Rect(0, 0, 15, 15), RGB24, 0, DNofill);
loadimage(ImageCell[Fault], ImageCell[Fault]->r, SrcFault, CellBytes);
- srand(time(0)); /* initialize generator of random numbers */
-
NewMineField(Level);
eresized(0);
@@ -649,7 +669,7 @@
if(PushButton && CurrentButton) {
InitMineField();
eresized(0);
- }
+ }
Button = FALSE;
PushButton = FALSE;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] games/mines: do not put a mine to the first clicked tile, add a cool option
2021-07-10 23:11 [9front] games/mines: do not put a mine to the first clicked tile, add a cool option kemal
@ 2021-07-11 11:07 ` Philip Silva
2021-07-11 13:41 ` hiro
2021-07-11 16:31 ` [9front] " kemal
1 sibling, 1 reply; 4+ messages in thread
From: Philip Silva @ 2021-07-11 11:07 UTC (permalink / raw)
To: 9front
I also found this frustrating, but it's good that the player can still test the luck :D
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
kemal <kemalinanc8@gmail.com> schrieb am Sonntag, 11. Juli 2021 um 01:11:
> player has no way of knowing if the first clicked tile is a mine,
>
> so don't put a mine there. in addition the og game and other
>
> clones also do this. also do some style changes and renew
>
> the prng seed more often.
>
> (also a cool option hehehe)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [9front] Re: games/mines: do not put a mine to the first clicked tile, add a cool option
2021-07-10 23:11 [9front] games/mines: do not put a mine to the first clicked tile, add a cool option kemal
2021-07-11 11:07 ` Philip Silva
@ 2021-07-11 16:31 ` kemal
1 sibling, 0 replies; 4+ messages in thread
From: kemal @ 2021-07-11 16:31 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 190 bytes --]
just realised that middle+right click at the very beginning
will cause problems, and i saw a typo in the manpage
change, so um apply this instead:
(HOPEFULLY not a second games/glendy case)
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 5295 bytes --]
From: kemal <kemalinanc8@gmail.com>
Date: Sun, 11 Jul 2021 16:28:18 +0000
Subject: [PATCH] games/mines: some mechanism changes
1. do not put a mine to the first clicked tile.
2. do not allow middle/right clicks at beginning.
3. add a option that will make the game run "faster" :^)
(thanks ori for the idea of -f)
---
diff c3589ef3cf33189d342a3ab638b558fd9249b220 99536f642160327672971cf8606a64ddd12e02d3
--- a/sys/man/1/mines Sat Jul 10 21:34:22 2021
+++ b/sys/man/1/mines Sun Jul 11 19:28:18 2021
@@ -4,7 +4,7 @@
.SH SYNOPSIS
.B games/mines
[
-.B -aeqg
+.B -aefgq
]
.SH DESCRIPTION
.I Mines
@@ -46,11 +46,16 @@
.B -e
Start at expert difficulty.
.TP
-.B -q
-Disable the query marker.
+.B -f
+It t-
+.I ahem
+I mean it makes the game faster to solve.
.TP
.B -g
It's a secret to everybody.
+.TP
+.B -q
+Disable the query marker.
.SH SOURCE
.B /sys/src/games/mines
.SH HISTORY
--- a/sys/src/games/mines/dat.h Sat Jul 10 21:34:22 2021
+++ b/sys/src/games/mines/dat.h Sun Jul 11 19:28:18 2021
@@ -23,15 +23,15 @@
};
enum {
- Empty0 = 0,
- Empty1 = 1,
- Empty2 = 2,
- Empty3 = 3,
- Empty4 = 4,
- Empty5 = 5,
- Empty6 = 6,
- Empty7 = 7,
- Empty8 = 8,
+ Empty0,
+ Empty1,
+ Empty2,
+ Empty3,
+ Empty4,
+ Empty5,
+ Empty6,
+ Empty7,
+ Empty8,
Query,
MouseQuery,
Mark,
--- a/sys/src/games/mines/mines.c Sat Jul 10 21:34:22 2021
+++ b/sys/src/games/mines/mines.c Sun Jul 11 19:28:18 2021
@@ -10,7 +10,7 @@
int MaxX, MaxY, Mines;
} Settings[] = { {8, 8, 10}, {16, 16, 40}, {30, 16, 99}, {0, 0, 0} };
-int MaxX, MaxY, Mines, Level, UnknownCell, Playing, MinesRemain, Time, Status, UseQuery = TRUE, UseGhost = FALSE, UseColor = TRUE;
+int MaxX, MaxY, Mines, Level, UnknownCell, Playing, MinesRemain, Time, Status, UseQuery = TRUE, UseGhost = FALSE, Trololo = FALSE, UseColor = TRUE;
Point Origin;
Mouse LastMouse;
@@ -159,21 +159,45 @@
}
void InitMineField(void) {
+ int x, y;
+ /* clean up mine field, make all cells unknown */
- /* clean up mine field, make all cells unknown and place new mines */
- {
- int i, x, y;
+ for(y = 0; y < MaxY; y++)
+ for(x = 0; x < MaxX; x++) {
+ MineField[x][y].Mine = FALSE;
+ MineField[x][y].Picture = Unknown;
+ }
- for(y = 0; y < MaxY; y++)
- for(x = 0; x < MaxX; x++) {
- MineField[x][y].Mine = FALSE;
- MineField[x][y].Picture = Unknown;
- }
+ /* reset status, remaining mines etc. */
+ Status = Game;
+ Playing = FALSE;
+ MinesRemain = Mines;
+ Time = 0;
+ UnknownCell = MaxX * MaxY - Mines;
+}
- for(i = 0; i < Mines; ) {
+void GenMines(int fcx, int fcy) {
+ srand(time(0));
+ /* plant mines */
+ {
+ int i = 0, x, y;
+
+ /*
+ * this option just trolls the user by increasing
+ * the chance of a mine in the first click from %0 to %90
+ */
+ if(Trololo){
+ i = nrand(9);
+ if(i){
+ MineField[fcx][fcy].Mine = TRUE;
+ i = 1;
+ }
+ }
+ while(i < Mines) {
x = nrand(MaxX);
y = nrand(MaxY);
if(MineField[x][y].Mine) continue;
+ if(x == fcx && y == fcy) continue;
MineField[x][y].Mine = TRUE;
i++;
}
@@ -196,12 +220,6 @@
if(x < MaxX - 1 && y < MaxY - 1 && MineField[x + 1][y + 1].Mine) MineField[x][y].Neighbours++;
}
}
-
- Status = Game;
- Playing = FALSE;
- MinesRemain = Mines;
- Time = 0;
- UnknownCell = MaxX * MaxY - Mines;
}
void NewMineField(int NewLevel) {
@@ -284,12 +302,17 @@
}
void LeftClick(Point Cell) {
+
+ int FirstClick;
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
+ if(Status != Game || Cell.x < 0 || Cell.y < 0) return;
+ FirstClick = !Playing;
Playing = TRUE;
switch(MineField[Cell.x][Cell.y].Picture) {
case Query:
case Unknown:
+ if(FirstClick)
+ GenMines(Cell.x, Cell.y);
if(MineField[Cell.x][Cell.y].Mine) {
MineField[Cell.x][Cell.y].Picture = Explosion;
DrawCell(Cell);
@@ -320,8 +343,7 @@
int Neighbours = 0;
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
- Playing = TRUE;
+ if(Status != Game || Playing == FALSE || Cell.x < 0 || Cell.y < 0) return;
switch(MineField[Cell.x][Cell.y].Picture) {
case Empty1:
case Empty2:
@@ -359,9 +381,7 @@
void RightClick(Point Cell) {
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
-
- Playing = TRUE;
+ if(Status != Game || Playing == FALSE || Cell.x < 0 || Cell.y < 0) return;
switch(MineField[Cell.x][Cell.y].Picture) {
case Unknown:
MineField[Cell.x][Cell.y].Picture = Mark;
@@ -381,7 +401,7 @@
void Usage(void) {
- fprint(2, "Usage: %s [-aeq]\n", argv0);
+ fprint(2, "Usage: %s [-aefgq]\n", argv0);
exits("usage");
}
@@ -392,8 +412,9 @@
ARGBEGIN {
case 'a': Level = Advanced; break;
case 'e': Level = Expert; break;
- case 'q': UseQuery = FALSE; break;
+ case 'f': Trololo = TRUE; break;
case 'g': UseGhost = TRUE; break;
+ case 'q': UseQuery = FALSE; break;
default:
Usage();
} ARGEND
@@ -518,8 +539,6 @@
ImageCell[Fault] = allocimage(display, Rect(0, 0, 15, 15), RGB24, 0, DNofill);
loadimage(ImageCell[Fault], ImageCell[Fault]->r, SrcFault, CellBytes);
- srand(time(0)); /* initialize generator of random numbers */
-
NewMineField(Level);
eresized(0);
@@ -649,7 +668,7 @@
if(PushButton && CurrentButton) {
InitMineField();
eresized(0);
- }
+ }
Button = FALSE;
PushButton = FALSE;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-11 21:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-10 23:11 [9front] games/mines: do not put a mine to the first clicked tile, add a cool option kemal
2021-07-11 11:07 ` Philip Silva
2021-07-11 13:41 ` hiro
2021-07-11 16:31 ` [9front] " kemal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).