Skip to content

Commit 74c0b8e

Browse files
committed
Squashed 'applications/external/' changes from 8c7d75571b..f232070e06
f232070e06 Explain multiple subtree remotes f1e3cee9eb Fix typo 0a277a49c3 Fix manifest bd712c367f Merge seader from https://github.com/xMasterX/all-the-plugins cd756a1d42 Merge reversi from https://github.com/xMasterX/all-the-plugins 8d2d345c4f Merge nfc_playlist from https://github.com/xMasterX/all-the-plugins b1102cb9be Merge hex_viewer from https://github.com/QtRoS/flipper-zero-hex-viewer 4554255059 Merge flipbip from https://github.com/xMasterX/all-the-plugins e96183c398 Merge cntdown_timer from https://github.com/0w0mewo/fpz_cntdown_timer edfe8fffc5 Merge cntdown_timer from https://github.com/xMasterX/all-the-plugins 333dcf9b2e Merge chess from https://github.com/xMasterX/all-the-plugins 30563727e8 Tone Generator: Add indicator (by Matt) 771d833721 Fix merge 798311b9b7 Add tone_gen from https://github.com/GEMISIS/tone_gen 024ba3e2b0 Second remote for tone_gen 815c2914eb Add tone_gen from https://github.com/xMasterX/all-the-plugins 0f0dd9c90a Add tone_gen with subtree instead 452d100 Merge pull request #6 from prplecake/fix-exit-crash 69be2f017d upd seader 768bbeab99 update nfc playlist 73d586d327 upd flipbip 9df1acbbf4 upd chess 6e82cea3bd update reversi 8834bfa Catch exception on 'expected_count' < 0 748c3e4 Bump to v1.4 2e37055 Minor changes ef535bc Minor changes. 1012b45 countdown timer: make digit selection wrap when pressing right fce19e3 countdown timer: Fix divide-by-zero crash when setting time to 00:00:00 2d24e1a countdown timer: use a custom alert sequence for time-up alarm d480fea016 countdown timer: make digit selection wrap when pressing right 163db32a21 countdown timer: Fix divide-by-zero crash when setting time to 00:00:00 670a5c6029 countdown timer: use a custom alert sequence for time-up alarm 1df1a17 Fix crash on exit 465a1eef2f add new apps 6dc1a23 Added Screenshots 52d5810 Update Application FAM + Add Settings Button Gif c9079ac Rename Wave Display Setting 98de19b Add Nicer Icons 2a2a1b6 Create LICENSE 22aadbc Update Volume String Allocation 811047a Add Volume + Actually Play Tone 01afdb3 Switch to Frequency + Rework Settings for Variable Item List Use 296928b Update App Context to Add Views to Dispatcher + Add SUpport for Variable Item Lists 7f004dc Update Settings to Use Submenu e6be51f Add Playback Scene + Tone Properties 82ea48e Re-architect View Management + Add Settings Scene e24f681 Add README a054c2a Rename Menus to Scenes c442af4 Setup Main Menu 6cc8608 Initial Commit git-subtree-dir: applications/external git-subtree-split: f232070e0641b5bdcc67849388c3a3709e1d0d07
1 parent 234c30a commit 74c0b8e

22 files changed

+245
-44
lines changed

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Many apps included in Momentum are modified (some lots more than others). This i
1717
- **Updating and fixing apps** that were abandoned by the original developers
1818

1919
### How?
20-
**Apps made by the our team are developed right here, the latest versions will always originate from this repository.**
20+
**Apps made by our team are developed right here, the latest versions will always originate from this repository.**
2121

2222
**For all other apps we use git subtrees to pull updates from the creator's repository / other sources such as [@xMasterX's pack](https://github.com/xMasterX/all-the-plugins), while also keeping our own tweaks and additions.**
2323

@@ -30,3 +30,14 @@ To make updating more manageable, we have added some scripts on top of subtrees:
3030
- add a new app with `.utils/add-subtree.sh <path> <repo url> <branch> [subdir]`, this will pull the history and create `path/.gitsubtree` to remember the url, branch and subdir
3131
- run `.utils/update-subtree.sh <path>` to pull updates for a subtree
3232
- or run `.utils/bulk-update-subtrees.sh` to do it for all subtrees
33+
34+
Most apps have a remote subtree URL for both the original repository, and for any forks / other sources such as [@xMasterX's pack](https://github.com/xMasterX/all-the-plugins).
35+
Unfortunately, this process is currently manual as our helper scripts don't cover it. We instead:
36+
- add from one remote
37+
- delete the directory in a commit
38+
- add from another remote
39+
- replace the new directory with the previous one
40+
- compare the changes between forks and keep the best of both
41+
- add any eventual edits we have on our end
42+
If you're an app developer wanting to add your app, or a third party who wants to include something they find useful, you don't need to bother with this cumbersome process.
43+
We will do it for you, just add from a single remote URL, or simply make an issue requesting an app to be added!

chess/views/flipchess_startscreen.c

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include "flipchess_icons.h"
77
#include "helpers/flipchess_fonts.h"
88

9-
// #include <assets_icons.h>
10-
119
struct FlipChessStartscreen {
1210
View* view;
1311
FlipChessStartscreenCallback callback;

cntdown_timer/application.fam

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ App(
1313
fap_category="Tools",
1414
fap_author="@0w0mewo",
1515
fap_weburl="https://github.com/0w0mewo/fpz_cntdown_timer",
16-
fap_version="1.3",
16+
fap_version="1.4",
1717
fap_description="Simple count down timer",
1818
)

cntdown_timer/utils/utils.c

+37-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,42 @@ static const NotificationSequence sequence_beep = {
1010
NULL,
1111
};
1212

13+
static const NotificationSequence sequence_timeup = {
14+
&message_force_display_brightness_setting_1f,
15+
&message_display_backlight_on,
16+
&message_vibro_on,
17+
18+
&message_note_c8,
19+
&message_delay_50,
20+
&message_sound_off,
21+
&message_delay_50,
22+
&message_delay_25,
23+
24+
&message_note_c8,
25+
&message_delay_50,
26+
&message_sound_off,
27+
&message_delay_50,
28+
&message_delay_25,
29+
30+
&message_note_c8,
31+
&message_delay_50,
32+
&message_sound_off,
33+
&message_delay_50,
34+
&message_delay_25,
35+
36+
&message_note_c8,
37+
&message_delay_50,
38+
&message_sound_off,
39+
&message_delay_50,
40+
&message_delay_25,
41+
42+
&message_vibro_off,
43+
&message_display_backlight_off,
44+
&message_delay_500,
45+
46+
NULL,
47+
};
48+
1349
void notification_beep_once() {
1450
notification_message(furi_record_open(RECORD_NOTIFICATION), &sequence_beep);
1551
notification_off();
@@ -20,7 +56,7 @@ void notification_off() {
2056
}
2157

2258
void notification_timeup() {
23-
notification_message(furi_record_open(RECORD_NOTIFICATION), &sequence_audiovisual_alert);
59+
notification_message(furi_record_open(RECORD_NOTIFICATION), &sequence_timeup);
2460
}
2561

2662
void parse_sec_to_time_str(char* buffer, size_t len, int32_t sec) {

cntdown_timer/views/countdown_view.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static void countdown_timer_view_on_draw(Canvas* canvas, void* ctx) {
9494

9595
int32_t count = model->count;
9696
int32_t expected_count = model->saved_count_setting;
97+
furi_check(expected_count > 0, "expected_count < 0");
9798

9899
CountDownViewSelect select = model->select;
99100

@@ -222,9 +223,7 @@ static void handle_time_setting_updown(CountDownTimView* cdv, CountDownViewCmd c
222223
break;
223224
}
224225

225-
if(count <= 0) {
226-
count = 1;
227-
}
226+
count = MAX(count, 1);
228227

229228
// update count state
230229
model->count = count;
@@ -307,13 +306,11 @@ static void handle_time_setting_select(InputKey key, CountDownTimView* cdv) {
307306
break;
308307

309308
case InputKeyRight:
310-
selection--;
311-
selection = selection % 3;
309+
selection = (3 + selection - 1) % 3;
312310
break;
313311

314312
case InputKeyLeft:
315-
selection++;
316-
selection = selection % 3;
313+
selection = (3 + selection + 1) % 3;
317314
break;
318315

319316
default:

nfc_playlist/application.fam

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ App(
99
fap_author="@acegoal07",
1010
fap_weburl="https://github.com/acegoal07/FlipperZero_NFC_Playlist/tree/main",
1111
fap_version="2.1",
12-
fap_icon="assets/icon.png",
12+
fap_icon_assets="assets",
13+
fap_icon="icon.png",
1314
fap_private_libs=[
1415
Lib(
1516
name="worker",
File renamed without changes.

nfc_playlist/assets/unknown_10px.png

312 Bytes
Loading

nfc_playlist/icon.png

304 Bytes
Loading

nfc_playlist/nfc_playlist.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <string.h>
66

7-
#include <assets_icons.h>
7+
#include "nfc_playlist_icons.h"
88

99
#include <gui/gui.h>
1010
#include <gui/view_dispatcher.h>

reversi/application.fam

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ App(
77
requires=[
88
"gui",
99
],
10-
stack_size=1 * 1024,
10+
stack_size=2 * 1024,
1111
order=90,
1212
fap_icon="game_reversi.png",
1313
fap_category="Games",
1414
fap_icon_assets_symbol="game_reversi",
1515
fap_author="@dimat",
1616
fap_weburl="https://github.com/zyuhel/flipperzero-racegame",
17-
fap_version="1.2",
17+
fap_version="1.3",
1818
fap_description="Reversi game, the game controls should be intuitive. Longs press on OK opens the menu to start a new game.",
1919
)

reversi/game_reversi.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#define FRAME_TOP 3
1313
#define FRAME_CELL_SIZE 7
1414

15-
#define SAVING_DIRECTORY STORAGE_APP_DATA_PATH_PREFIX
16-
#define SAVING_FILENAME SAVING_DIRECTORY "/game_reversi.save"
15+
#define SAVING_FILENAME APP_DATA_PATH("reversi.save")
1716

1817
typedef enum { AppScreenGame, AppScreenMenu } AppScreen;
1918

reversi/reversi.c

+106-26
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55

66
// Psst! Most of this file was written with Copilot
77

8+
const int weights[BOARD_SIZE][BOARD_SIZE] = {
9+
{100, -10, 10, 10, 10, 10, -10, 100},
10+
{-10, -20, -5, -5, -5, -5, -20, -10},
11+
{10, -5, 5, 1, 1, 5, -5, 10},
12+
{10, -5, 1, 0, 0, 1, -5, 10},
13+
{10, -5, 1, 0, 0, 1, -5, 10},
14+
{10, -5, 5, 1, 1, 5, -5, 10},
15+
{-10, -20, -5, -5, -5, -5, -20, -10},
16+
{100, -10, 10, 10, 10, 10, -10, 100}};
17+
818
// Check if the move is legal by checking if it results in any opponent pieces being captured
919
bool is_legal_move(int8_t board[BOARD_SIZE][BOARD_SIZE], int row, int col, int player) {
1020
if(board[row][col] != 0) return false;
@@ -53,52 +63,56 @@ bool has_legal_moves(int8_t board[BOARD_SIZE][BOARD_SIZE], int8_t player_color)
5363
return false;
5464
}
5565

56-
// Calculate the heuristic value of the current board. This function can
57-
// be replaced with a more complex evaluation function that takes into
58-
// account factors such as mobility, piece square tables, etc.
59-
int heuristic(int8_t board[BOARD_SIZE][BOARD_SIZE]) {
60-
int white = 0, black = 0;
66+
int evaluate_board(int8_t board[BOARD_SIZE][BOARD_SIZE], int player) {
67+
int score = 0;
6168
for(int i = 0; i < BOARD_SIZE; i++) {
6269
for(int j = 0; j < BOARD_SIZE; j++) {
63-
if(board[i][j] == 1) white++;
64-
if(board[i][j] == -1) black++;
70+
if(board[i][j] == player) {
71+
score += weights[i][j];
72+
} else if(board[i][j] == -player) {
73+
score -= weights[i][j];
74+
}
6575
}
6676
}
67-
return white - black;
77+
return score;
6878
}
6979

7080
// Make a move on the board and capture any opponent pieces
71-
void make_move(GameState* state, int x, int y, int player) {
72-
state->board[x][y] = player;
81+
void make_move(
82+
GameState* game_state,
83+
int8_t board[BOARD_SIZE][BOARD_SIZE],
84+
int x,
85+
int y,
86+
int player) {
87+
board[x][y] = player;
7388
int opponent = -player;
7489
for(int i = -1; i <= 1; i++) {
7590
for(int j = -1; j <= 1; j++) {
7691
if(i == 0 && j == 0) continue;
7792
int r = x + i, c = y + j;
78-
if(r >= 0 && r < BOARD_SIZE && c >= 0 && c < BOARD_SIZE &&
79-
state->board[r][c] == opponent) {
93+
if(r >= 0 && r < BOARD_SIZE && c >= 0 && c < BOARD_SIZE && board[r][c] == opponent) {
8094
int k = 2;
8195
while(true) {
8296
r += i;
8397
c += j;
8498
if(r < 0 || r >= BOARD_SIZE || c < 0 || c >= BOARD_SIZE) break;
85-
if(state->board[r][c] == player) {
99+
if(board[r][c] == player) {
86100
r -= i;
87101
c -= j;
88102
while(r != x || c != y) {
89-
state->board[r][c] = player;
103+
board[r][c] = player;
90104
r -= i;
91105
c -= j;
92106
}
93107
break;
94108
}
95-
if(state->board[r][c] == 0) break;
109+
if(board[r][c] == 0) break;
96110
k++;
97111
}
98112
}
99113
}
100114
}
101-
state->is_game_over = is_game_over(state->board);
115+
game_state->is_game_over = is_game_over(game_state->board);
102116
}
103117

104118
void init_game(GameState* state) {
@@ -136,31 +150,97 @@ void human_move(GameState* game_state) {
136150
game_state->cursor_y,
137151
game_state->current_player)) {
138152
make_move(
139-
game_state, game_state->cursor_x, game_state->cursor_y, game_state->current_player);
153+
game_state,
154+
game_state->board,
155+
game_state->cursor_x,
156+
game_state->cursor_y,
157+
game_state->current_player);
140158
game_state->current_player = -game_state->current_player;
141159
}
142160
}
143161

162+
int minimax(
163+
GameState* game_state,
164+
int8_t board[BOARD_SIZE][BOARD_SIZE],
165+
int depth,
166+
bool is_maximizing,
167+
int player,
168+
int alpha,
169+
int beta) {
170+
if(depth == 0 || is_game_over(board)) {
171+
return evaluate_board(board, player);
172+
}
173+
174+
if(is_maximizing) {
175+
int max_eval = -1000000;
176+
for(int i = 0; i < BOARD_SIZE; i++) {
177+
for(int j = 0; j < BOARD_SIZE; j++) {
178+
if(is_legal_move(board, i, j, player)) {
179+
int8_t temp_board[BOARD_SIZE][BOARD_SIZE];
180+
memcpy(temp_board, board, sizeof(temp_board));
181+
make_move(game_state, temp_board, i, j, player);
182+
int eval =
183+
minimax(game_state, temp_board, depth - 1, false, -player, alpha, beta);
184+
max_eval = max(max_eval, eval);
185+
alpha = max(alpha, eval);
186+
if(beta <= alpha) {
187+
break;
188+
}
189+
}
190+
}
191+
}
192+
return max_eval;
193+
} else {
194+
int min_eval = 1000000;
195+
for(int i = 0; i < BOARD_SIZE; i++) {
196+
for(int j = 0; j < BOARD_SIZE; j++) {
197+
if(is_legal_move(board, i, j, -player)) {
198+
int8_t temp_board[BOARD_SIZE][BOARD_SIZE];
199+
memcpy(temp_board, board, sizeof(temp_board));
200+
make_move(game_state, temp_board, i, j, -player);
201+
int eval =
202+
minimax(game_state, temp_board, depth - 1, true, player, alpha, beta);
203+
min_eval = min(min_eval, eval);
204+
beta = min(beta, eval);
205+
if(beta <= alpha) {
206+
break;
207+
}
208+
}
209+
}
210+
}
211+
return min_eval;
212+
}
213+
}
214+
144215
void computer_move(GameState* game_state) {
145216
if(game_state->current_player == game_state->human_color) {
146217
return;
147218
}
148219
int best_row = -1, best_col = -1, best_score = -1000000;
149220
for(int i = 0; i < BOARD_SIZE; i++) {
150221
for(int j = 0; j < BOARD_SIZE; j++) {
151-
if(!is_legal_move(game_state->board, i, j, game_state->current_player)) {
152-
continue;
153-
}
154-
int score = heuristic(game_state->board);
155-
if(score > best_score) {
156-
best_score = score;
157-
best_row = i;
158-
best_col = j;
222+
if(is_legal_move(game_state->board, i, j, game_state->current_player)) {
223+
int8_t temp_board[BOARD_SIZE][BOARD_SIZE];
224+
memcpy(temp_board, game_state->board, sizeof(temp_board));
225+
make_move(game_state, temp_board, i, j, game_state->current_player);
226+
int score = minimax(
227+
game_state,
228+
temp_board,
229+
3,
230+
false,
231+
-game_state->current_player,
232+
-1000000,
233+
1000000);
234+
if(score > best_score) {
235+
best_score = score;
236+
best_row = i;
237+
best_col = j;
238+
}
159239
}
160240
}
161241
}
162242
if(best_row != -1) {
163-
make_move(game_state, best_row, best_col, game_state->current_player);
243+
make_move(game_state, game_state->board, best_row, best_col, game_state->current_player);
164244
}
165245
if(has_legal_moves(game_state->board, game_state->human_color)) {
166246
game_state->current_player = -game_state->current_player;

reversi/reversi.h

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
#include <furi.h>
44
#include <stdbool.h>
55

6+
#ifndef __cplusplus
7+
#define max(a, b) (((a) > (b)) ? (a) : (b))
8+
#define min(a, b) (((a) < (b)) ? (a) : (b))
9+
#endif
10+
611
#define BLACK 1
712
#define WHITE -1
813
#define BOARD_SIZE 8

0 commit comments

Comments
 (0)