Mercurial > vba-clojure
comparison clojure/com/aurellem/run/bootstrap_0.clj @ 337:2dd40f6b6a1f
restore memoization.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 07 Apr 2012 07:43:17 -0500 |
parents | 25b7bb7da3b1 |
children | 92f0011925d2 |
comparison
equal
deleted
inserted
replaced
336:25b7bb7da3b1 | 337:2dd40f6b6a1f |
---|---|
430 (->> script | 430 (->> script |
431 (wait-until (partial set-cursor-relative 1)) | 431 (wait-until (partial set-cursor-relative 1)) |
432 (play-moves [[:a] []]))) | 432 (play-moves [[:a] []]))) |
433 | 433 |
434 (defn restart | 434 (defn restart |
435 "Two button presses after a restart event are lost when converting to | |
436 VBM format. To compensate, step the state forward two steps." | |
437 [[moves state :as script]] | |
438 (->> [(concat moves [[:restart]]) | |
439 (run-moves state [[:restart] | |
440 | |
441 | |
442 ;;[] [] | |
443 | |
444 ])] | |
445 (do-nothing 2))) | |
446 | |
447 (defn restart | |
448 "The two button presses after a restart event are converted to | 435 "The two button presses after a restart event are converted to |
449 blanks. Due to weirdness with the VBM format. To compensate, ensure | 436 blanks. Due to weirdness with the VBM format. To compensate, ensure |
450 that the two button presses after restart are both blanks." | 437 that the two button presses after restart are both blanks." |
451 [script] | 438 [script] |
452 (play-moves [[:restart] [] []] script)) | 439 (play-moves [[:restart] [] []] script)) |
453 | |
454 (defn restart-wrong | |
455 [[moves state :as script]] | |
456 [(concat moves [[:restart] [] []]) | |
457 (run-moves state [[:restart]])]) | |
458 | 440 |
459 (defn do-save-corruption | 441 (defn-memo do-save-corruption |
460 ([] (do-save-corruption | 442 ([] (do-save-corruption |
461 (walk-to-counter))) | 443 (walk-to-counter))) |
462 ([script] | 444 ([script] |
463 (->> script | 445 (->> script |
464 activate-start-menu | 446 activate-start-menu |
501 (first-difference [] [:a] AF) | 483 (first-difference [] [:a] AF) |
502 scroll-text | 484 scroll-text |
503 select-menu-entry | 485 select-menu-entry |
504 scroll-text)) | 486 scroll-text)) |
505 | 487 |
506 (defn corrupt-item-list | 488 (defn-memo corrupt-item-list |
507 "Corrupt the num-of-items variable by switching a corrupted pokemon | 489 "Corrupt the num-of-items variable by switching a corrupted pokemon |
508 into out-of-bounds memory." | 490 into out-of-bounds memory." |
509 ([] (corrupt-item-list | 491 ([] (corrupt-item-list |
510 ;;(corrupted-checkpoint) | 492 ;;(corrupted-checkpoint) |
511 (do-save-corruption) | 493 (do-save-corruption) |
523 (set-cursor 9) | 505 (set-cursor 9) |
524 select-menu-entry ; switch 6th with 10th | 506 select-menu-entry ; switch 6th with 10th |
525 close-menu | 507 close-menu |
526 close-menu))) | 508 close-menu))) |
527 | 509 |
528 (defn get-lots-of-money | 510 (defn-memo get-lots-of-money |
529 "Sell 0xFE cancel buttons to make a tremendous amount of money." | 511 "Sell 0xFE cancel buttons to make a tremendous amount of money." |
530 ([] (get-lots-of-money (corrupt-item-list))) | 512 ([] (get-lots-of-money (corrupt-item-list))) |
531 ([script] | 513 ([script] |
532 (->> script | 514 (->> script |
533 (first-difference [] [:a] AF) ; talk to shopkeep | 515 (first-difference [] [:a] AF) ; talk to shopkeep |
542 close-menu))) | 524 close-menu))) |
543 | 525 |
544 (defn note [str script] | 526 (defn note [str script] |
545 (println str) script) | 527 (println str) script) |
546 | 528 |
547 (defn buy-bootstrapping-items | 529 (defn-memo buy-bootstrapping-items |
548 "Buy items that will become part of the bootstrapping | 530 "Buy items that will become part of the bootstrapping |
549 program." | 531 program." |
550 ([] (buy-bootstrapping-items (get-lots-of-money))) | 532 ([] (buy-bootstrapping-items (get-lots-of-money))) |
551 ([script] | 533 ([script] |
552 (->> script | 534 (->> script |
572 close-menu ; stop talking to shopkeep | 554 close-menu ; stop talking to shopkeep |
573 (wait-until select-menu-entry) | 555 (wait-until select-menu-entry) |
574 (play-moves [[:b]]) | 556 (play-moves [[:b]]) |
575 end-text))) | 557 end-text))) |
576 | 558 |
577 (defn corrupt-item-list-again | 559 (defn-memo corrupt-item-list-again |
578 ([] (corrupt-item-list-again (buy-bootstrapping-items))) | 560 ([] (corrupt-item-list-again (buy-bootstrapping-items))) |
579 ([script] | 561 ([script] |
580 (->> script | 562 (->> script |
581 activate-start-menu | 563 activate-start-menu |
582 (set-cursor-relative 0) | 564 (set-cursor-relative 0) |
594 (set-cursor 9) ; goto 10th pokemon | 576 (set-cursor 9) ; goto 10th pokemon |
595 select-menu-entry ; do switch | 577 select-menu-entry ; do switch |
596 close-menu | 578 close-menu |
597 close-menu))) | 579 close-menu))) |
598 | 580 |
599 (defn leave-viridian-store | 581 (defn-memo leave-viridian-store |
600 ([] (leave-viridian-store (corrupt-item-list-again))) | 582 ([] (leave-viridian-store (corrupt-item-list-again))) |
601 ([script] | 583 ([script] |
602 (->> script | 584 (->> script |
603 ;; leave store | 585 ;; leave store |
604 (walk [↓ ↓ → ↓])))) | 586 (walk [↓ ↓ → ↓])))) |
607 (delayed-improbability-search | 589 (delayed-improbability-search |
608 600 | 590 600 |
609 #(search-string % "Wild") | 591 #(search-string % "Wild") |
610 (partial move direction) script)) | 592 (partial move direction) script)) |
611 | 593 |
612 (defn fight-wild-pokemon | 594 (defn-memo fight-wild-pokemon |
613 ([] (fight-wild-pokemon (leave-viridian-store))) | 595 ([] (fight-wild-pokemon (leave-viridian-store))) |
614 ([script] | 596 ([script] |
615 (->> script | 597 (->> script |
616 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ | 598 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ |
617 ← ← ← ← ← ← ← ← | 599 ← ← ← ← ← ← ← ← |
618 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓]) | 600 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓]) |
619 (force-encounter →)))) | 601 (force-encounter →)))) |
620 | 602 |
621 (defn run-from-pokemon | 603 (defn-memo run-from-pokemon |
622 ([] (run-from-pokemon (fight-wild-pokemon))) | 604 ([] (run-from-pokemon (fight-wild-pokemon))) |
623 ([script] | 605 ([script] |
624 (->> script | 606 (->> script |
625 (scroll-text) | 607 (scroll-text) |
626 (play-moves [[:a]]) | 608 (play-moves [[:a]]) |
628 (set-cursor 1) | 610 (set-cursor 1) |
629 (first-difference [] → AF) | 611 (first-difference [] → AF) |
630 (scroll-text) | 612 (scroll-text) |
631 (scroll-text)))) | 613 (scroll-text)))) |
632 | 614 |
633 29952 | 615 (defn-memo to-poke-center-computer |
634 | |
635 (defn to-poke-center-computer | |
636 ([] (to-poke-center-computer | 616 ([] (to-poke-center-computer |
637 (run-from-pokemon))) | 617 (run-from-pokemon))) |
638 ([script] | 618 ([script] |
639 (->> script | 619 (->> script |
640 (walk-thru-grass [→ → ↑]) | 620 (walk-thru-grass [→ → ↑]) |