Gury Posted October 25, 2021 Share Posted October 25, 2021 Great stuff! Nice work with new features. Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4931642 Share on other sites More sharing options...
zbyti Posted October 26, 2021 Share Posted October 26, 2021 recursion test uses crt; const size = 5; // permutations counter = (size+1)! var board : array [0..size] of byte; i : byte; counter : word = 0; procedure generate(n: byte); var i, tmp: byte; begin if n = 0 then begin for tmp in board do write(tmp); writeln; inc(counter); end else begin for i := 0 to n do begin tmp := board[i]; board[i] := board[n]; board[n] := tmp; generate(n-1); tmp := board[i]; board[i] := board[n]; board[n] := tmp; end; end; end; begin for i := 0 to size do board[i] := i; generate(size); writeln('permutations counter: ', counter); repeat until keypressed; end. 1 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4932037 Share on other sites More sharing options...
zbyti Posted October 26, 2021 Share Posted October 26, 2021 (edited) Eight queens puzzle Mad Pascal benchmark. No ZP optimization. https://en.wikipedia.org/wiki/Eight_queens_puzzle //Eight queens puzzle //link: https://en.wikipedia.org/wiki/Eight_queens_puzzle uses crt, sysutils, atari; const size = 8; var board : array [0..size] of byte; i : byte; ticks : word; //counter is word for boards size greater than 8x8 counter : word = 0; function check(n, c: byte): boolean; var i: byte; begin check := true; for i := 1 to (n - 1) do if (board[i] = c) or (board[i] - i = c - n) or (board[i] + i = c + n) then check := false; end; procedure generate(n: byte); var c: byte; begin if n > size then begin //for i := 1 to size do write(board[i]); writeln; inc(counter); colbaks := counter; end else for c := 1 to size do if check(n, c) then begin board[n] := c; generate(n + 1); end; end; begin colbaks := counter; for i := 0 to size do board[i] := 0; pause; ticks := GetTickCount; generate(1); ticks := word(GetTickCount) - ticks; writeln('solutions: ', counter); writeln('ticks: ', ticks); repeat until keypressed; end. 8queens.xex 8queens.pas Edited October 26, 2021 by zbyti 1 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4932230 Share on other sites More sharing options...
tebe Posted October 27, 2021 Author Share Posted October 27, 2021 (edited) function check(n, c : byte): boolean; var i: byte; begin check := true; for i := 1 to (n - 1) do if (board[i] = c) or (board[i] - i = c - n) or (board[i] + i = c + n) then begin check := false; Break end; end; Edited October 27, 2021 by tebe Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4932650 Share on other sites More sharing options...
tebe Posted October 27, 2021 Author Share Posted October 27, 2021 (edited) function check(n, c : byte): boolean; var i: byte; begin check := true; for i := 1 to (n - 1) do if (board[i] = c) or (byte(board[i] - i) = byte(c - n)) or (byte(board[i] + i) = byte(c + n)) then exit(false); end; 228 ticks Edited October 27, 2021 by tebe 1 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4932653 Share on other sites More sharing options...
zbyti Posted October 27, 2021 Share Posted October 27, 2021 (edited) 8queens.mp4 8queens-board.pas 8queens-board.xex Edited October 27, 2021 by zbyti Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4932687 Share on other sites More sharing options...
zbyti Posted October 29, 2021 Share Posted October 29, 2021 https://atariwiki.org/wiki/Wiki.jsp?page=Eight Queens ~40 sec. Mad Pascal - recursion & hi-res takes ~20 sec - but I can draw a chessboard faster Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4933959 Share on other sites More sharing options...
zbyti Posted October 29, 2021 Share Posted October 29, 2021 https://github.com/zbyti/a8-mad-pascal-bench-suite update. suite.xex Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4934030 Share on other sites More sharing options...
Estece Posted November 1, 2021 Share Posted November 1, 2021 function check(n, c : byte): boolean; var i: byte; dud: byte; tim: byte; tip: byte; begin check := true; tip:=c + n; tim:=c - n; for i := 1 to (n - 1) do begin dud:=board[i]; if (dud = c) or ((dud - i) = tim) or ((dud + i) = tip) then exit(false); end; end; 216 obvious simple things Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4935804 Share on other sites More sharing options...
zbyti Posted November 1, 2021 Share Posted November 1, 2021 (edited) 8 hours ago, Estece said: 216 obvious simple things The aim of the benchmark is to check how "fast code" will be generated by the compiler, not improvement of the algorithm I think you are now use more space on tiny Mad Pascal stack. Edited November 1, 2021 by zbyti Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4935975 Share on other sites More sharing options...
Estece Posted November 2, 2021 Share Posted November 2, 2021 The iron rule is : "never believe that tools alone will do the work for You" 1 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4936633 Share on other sites More sharing options...
zbyti Posted November 7, 2021 Share Posted November 7, 2021 (edited) Simple procedural map generator for my incoming (also simple) roguelike game. Maybe someone find it useful and tweak it :] uses crt; //----------------------------------------------------------------------------- var RTCLOK : byte absolute $14; SAVMSC : word absolute $58; COLOR4 : byte absolute $2c8; RANDOM : byte absolute $D20A; VCOUNT : byte absolute $D40B; seed1, seed2, seed3 : byte; level : byte; screen : word; //----------------------------------------------------------------------------- function pseudo_rnd_dir: byte; var tmp : word; begin tmp := 0; //workaround Inc(seed2); tmp := seed2 + seed2 + seed1; seed1 := lo(tmp); seed2 := (seed1 xor seed2) + hi(tmp); seed3 := seed2 - seed3; pseudo_rnd_dir := seed3 and 3; end; //----------------------------------------------------------------------------- procedure render_map(l, x, y, s1, s2, s3: byte); var dir : byte; i : word; begin FillByte(pointer(screen), 960, 0); GotoXY(0,0); write('level=', l,' x=', x, ' y=', y); GotoXY(0,24); write('s1=', s1,' s2=', s2, ' s3=', s3); seed1 := s1; seed2 := s2; seed3 := s3; for i := 800 downto 0 do begin dir := pseudo_rnd_dir; case dir of 0 : if y > 1 then Dec(y); 1 : if y < 22 then Inc(y); 2 : if x > 1 then Dec(x); 3 : if x < 38 then Inc(x); end; Poke(screen + x + y * 40, $80); end; end; //----------------------------------------------------------------------------- procedure slide_show; var x, y : byte; s1, s2, s3 : byte; begin level := 1; repeat //x := 19; y := 11; //play with x & y values ;) x := 12 + RANDOM and %111; y := 8 + RANDOM and %11; s1 := RANDOM xor level; s2 := RANDOM xor s1; s3 := RANDOM xor s2; render_map(level, x, y, s1, s2, s3); Inc(level); COLOR4 := s3; pause(200); until false; end; //----------------------------------------------------------------------------- begin screen := SAVMSC; CursorOff; slide_show; //render_map(1, 19, 11, 129, 137, 233); //pause(200); //render_map(2, 19, 11, 186, 14, 37); repeat until false end. map-generator.xex Edited November 7, 2021 by zbyti 4 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4940501 Share on other sites More sharing options...
zbyti Posted November 7, 2021 Share Posted November 7, 2021 you can also find map generator useful in the ASCII compo 2 2 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4940512 Share on other sites More sharing options...
zbyti Posted November 7, 2021 Share Posted November 7, 2021 (edited) With doors DIY :] map-generator-doors.xex Edited November 7, 2021 by zbyti 5 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4940679 Share on other sites More sharing options...
tebe Posted November 9, 2021 Author Share Posted November 9, 2021 (edited) https://github.com/tebe6502/Mad-Pascal/blob/master/samples/a8/graph_crossplatform/fern.pas OBX (Atari XE/XL), EXE (Windows) fern.obx fern.exe Edited November 9, 2021 by tebe 6 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4942518 Share on other sites More sharing options...
tebe Posted November 9, 2021 Author Share Posted November 9, 2021 https://github.com/tebe6502/Mad-Pascal/blob/master/samples/a8/graph_crossplatform/archimedean.pas OBX (Atari XE/XL), EXE (Windows) archimedean.obx archimedean.exe 5 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4942522 Share on other sites More sharing options...
tebe Posted November 10, 2021 Author Share Posted November 10, 2021 https://github.com/tebe6502/Mad-Pascal/blob/master/samples/a8/crt_console/ying_yang.pas OBX (Atari XE/XL), EXE (Windows) source code: http://rosettacode.org/wiki/Yin_and_yang#Pascal almost only copy and paste (integer replaced by shortint) ying_yang.exe ying_yang.obx 6 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4943256 Share on other sites More sharing options...
tebe Posted November 11, 2021 Author Share Posted November 11, 2021 https://github.com/tebe6502/Mad-Pascal/blob/master/samples/a8/graph_crossplatform/sierpinski_pentagon.pas OBX (Atari XE/XL), EXE (Windows) sierpinski_pentagon.exe sierpinski_pentagon.obx 7 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4943812 Share on other sites More sharing options...
tebe Posted November 28, 2021 Author Share Posted November 28, 2021 https://github.com/tebe6502/Mad-Pascal a lot of improvements, new Float16 type https://en.wikipedia.org/wiki/Half-precision_floating-point_format snowflake_single.obx snowflake_real.obx snowflake_float16.obx snowflake.pas 6 5 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4956343 Share on other sites More sharing options...
Gury Posted November 29, 2021 Share Posted November 29, 2021 Wonderful! This feature is useful for faster operation of float numbers. ? It will be good to go through new features of Mad Pascal for better understanding and using in new software. Great! Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4956819 Share on other sites More sharing options...
bocianu Posted November 29, 2021 Share Posted November 29, 2021 As a reminder, for those who are new here, I continue to develop, maintain, and extend a set of useful libraries for Mad-Pascal: https://gitlab.com/bocianu/blibs It gets updated every few months and now it can really help you develop new stuff. CHANGELOG : https://gitlab.com/bocianu/blibs/-/blob/master/CHANGELOG Documentation: https://bocianu.gitlab.io/blibs/ You can also find couple of examples for every library included. I hope some of you find it useful in your projects. 3 3 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4957001 Share on other sites More sharing options...
Gury Posted November 30, 2021 Share Posted November 30, 2021 These are great programming tools. I check them periodically and it is great to see they are actively maintained. Before that I was looking for a solution for xbios and thought of working on it myself, but I knew it would be big chore to do. I was happy to see its support with blibs libraries. I will go through all the features and probably make use of them in future projects, including support for extra memory and display lists. These are seen in Mad Pascal examples already. Thanks to you and Tebe for continuous work on these great development tools. And of course zbyti for making good example listings and benchmarks 1 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4957422 Share on other sites More sharing options...
Kenneth Cochran Posted December 14, 2021 Share Posted December 14, 2021 Haven't seen this asked yet but does Mad Pascal support targeting the Atari 2600? Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4966098 Share on other sites More sharing options...
zbyti Posted December 14, 2021 Share Posted December 14, 2021 17 minutes ago, Kenneth Cochran said: Haven't seen this asked yet but does Mad Pascal support targeting the Atari 2600? Nope Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4966114 Share on other sites More sharing options...
tebe Posted January 1, 2022 Author Share Posted January 1, 2022 dragon_curve.obx dragon_curve.pas 5 Quote Link to comment https://forums.atariage.com/topic/240919-mad-pascal/page/28/#findComment-4976013 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.